• Not Answered

driverlib issue

I am porting code over to CCS5 and using the driverlib for MSP430F5436A microcontroller. While debugging and going into "privateUCSComputeCLKFrequency()" function the execution of

"----------------------------------------

case SELM__XT2CLK:

CLKFrequency =

(XT2ClockFrequency / CLKSourceFrequencyDivider);

"----------------------------------------

gives a truncated result. The "XT2ClockFrequency" is 3686000 and "CLKSourceFrequencyDivider" is 1. So the result in "CLKFrequency" should be 3686000, but I am getting 15984. Is there any any setting in the CCS5 that I am missing?

2 Replies

  • 3686000 is 0x383e70. 15984 is 0x3e70. Seems like CLKFrequency is a 16 bit variable only.

    Maybe its purpose is using it in a 16 bit register later (e.g. a counter). So any result that exceeds 65535 is too much anyway.

    But it's also possible that just the debugger shows a wrong value, interpreting CLKFrequency as 16 bit variable where it indeed is 32 bit.

    That's why I try to not use libraries wher eit is not really necessary. They are usually introducing unnecessary overhead, are slower than optimized code, and even if the documentation is really good (and it often isn't), there's still some doubt whether it really does what one thinks it should.

  • In reply to Jens-Michael Gross:

    I did check the variable sizes as that was my first doubt.

    CLKFrequency is defined as "unsigned long CLKFrequency;" in function "privateUCSComputeCLKFrequency()".

    I feel like there are some optimization setting need to be changed in the driverlib project and recompiled to resolve the issue.

    I agree the driverlib for 5xx/6xx seem to be not stable at this point.