This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HAL_setupClks hal.c Update

Other Parts Discussed in Thread: MOTORWARE

 

Hello all,

I friendly forum member found an issue right off the bat with MotorWare _12 (this has actually been in every version of MotorWare).

The HAL_setupClks (formerly DRV_sertupClks) function needs the order of its commands adjusted slightly.
The CLK_setOscSrc function should be called before CLK_disableClkIn
Otherwise you can run into an issue if the device already has code running from flash.

This has been updated on our working branch and will be released in _13. If you would like to fix it now, just update the hal.c function in all of the board directories you are using:

C:\ti\motorware\motorware_1_01_00_12\sw\modules\hal\boards\..

 

void HAL_setupClks(HAL_Handle handle)

{

  HAL_Obj *obj = (HAL_Obj *)handle;

 

 

  // enable internal oscillator 1

  CLK_enableOsc1(obj->clkHandle);

 

  // set the oscillator source

  CLK_setOscSrc(obj->clkHandle,CLK_OscSrc_Internal);

 

  // disable the external clock in

  CLK_disableClkIn(obj->clkHandle);

 

  // disable the crystal oscillator

  CLK_disableCrystalOsc(obj->clkHandle);

 

  // disable oscillator 2

  CLK_disableOsc2(obj->clkHandle);

 

  // set the low speed clock prescaler

  CLK_setLowSpdPreScaler(obj->clkHandle,CLK_LowSpdPreScaler_SysClkOut_by_4);

 

  // set the clock out prescaler

  CLK_setClkOutPreScaler(obj->clkHandle,CLK_ClkOutPreScaler_SysClkOut_by_1);

 

  return;

} // end of HAL_setupClks() function

 

 

  • Hi Chris,

    Same issue with CLK_setLowSpdPreScaler. Since you are using an "OR", if there are bits already set there, it will go wrong.  The bits should be cleared first, or, in this particular case just use "=", since the register is only for that purpose (doesn't have different fields...)

    Second thing I have found - Since you are using an optimizer in the compiler, then in some occasions when trying to write to a register which is in a struct, the compiler will ignor the code. I've encountered this when trying to write to the SPITXBUF four times to fill the fifo. the compiler was writing only 2 times...

    The solution is to use the method as in the Control suit - define all register fields as "volatile".

  • Mojo,

    good catch...I have a feeling there are more peripheral set-up that we need to clear before we set.  We'll need to scrub this for _13.

    The volatile solution was logged the first time you mentioned it, just didn't make _12 release.