Official v7.1.0 MSP430X Demos are Broken

incoherent wrote on Friday, March 16, 2012:

The unmodified CCS MSP430X demo was failing with “Err: COM test” on my EXP5438 board.  After some investigation, I found that the code was attempting to set the clock to 25MHz without first setting the VCORE voltage to an appropriate value.

#define configCPU_CLOCK_HZ				( 25000000UL )

Also, the Init_FLL_Settle function is called with a ‘magic number’ that is the incorrect for the desired clock rate:

	unsigned long ulCPU_Clock_KHz = ( configCPU_CLOCK_HZ / 1000UL );
 	LFXT_Start( XT1DRIVE_0 );
	Init_FLL_Settle( ( unsigned short ) ulCPU_Clock_KHz, 488 );

To fix this, I added a #define to FreeRTOSConfig.h:

#define configLFXT_CLOCK_HZ       ( 32768L )

Replaced the Init_FLL_Settle function call in main.c with this:

hal430SetSystemClock(configCPU_CLOCK_HZ, configLFXT_CLOCK_HZ);

Added HAL_PMM.C and HAL_PMM.H from TI’s F5xx/6xx core library to the F5XX_6XX_Core_Lib folder.

And added this code to hal_board.c:

 * @brief  Set function for MCLK frequency.
 * @return none
void hal430SetSystemClock(unsigned long req_clock_rate, unsigned long ref_clock_rate)
    /* Convert a Hz value to a KHz value, as required
   *  by the Init_FLL_Settle() function. */
  unsigned long ulCPU_Clock_KHz = req_clock_rate / 1000UL;
  //Make sure we aren't overclocking
  if(ulCPU_Clock_KHz > 25000L)
    ulCPU_Clock_KHz = 25000L;
  //Set VCore to a level sufficient for the requested clock speed.
  if(ulCPU_Clock_KHz <= 8000L)
  else if(ulCPU_Clock_KHz <= 12000L)
  else if(ulCPU_Clock_KHz <= 20000L)
  //Set the DCO
  Init_FLL_Settle( ( unsigned short )ulCPU_Clock_KHz, req_clock_rate / ref_clock_rate );

rtel wrote on Friday, March 16, 2012:

Thanks for the feedback.  I have made the changes so they don’t get lost, but have not yet tried compiling.