Hi you all!
I have tried to write a simple delay function (CCSv4.2 for MSP430) like:
void Delay_ms(unsigned short usMilliseconds) {
while ( usMilliseconds-- ) {
__delay_cycles(32768); }
}
I didnt inspect the resulting assembly code but it does not work (release/debug) . After second loop "usMilliseconds" is reset but the delay will be still executed (it stays there indefinitely).
Is this a known problem?
Thank you
Tech.
Did you disable the watchdog timer prior to this code being run? It sounds like the watchdog is resetting the device, which happens after every 32768 cycles for MSP430 devices.
If a post answers your question please mark it with the "Verify Answer" button
Search the wikis for common questions: CGT, BIOS, CCSv3, CCSv4Track a known bug with SDOWP. Enter the bug id in the "Find Record ID" box
Also note that you should probably be using a low power mode rather than __delay_cycles for delays of that magnitude. See http://processors.wiki.ti.com/index.php/Compiler/diagnostic_messages/MSP430/1527
Yes, of course I have disabled the WDT. It seems to be a bug pls. see my answer below. Thanks!
Yes I disabled it. It seems to be a bug in CCS see Post "CCS 5.1.1.00031 "Step Over" doesn't work for MSP430 __delay_cycles intrinsic"
I have tested it again but with CCS Version: 5.2.0.00044 and it seems to work properly!
Thank you very much.
hi.. i have a question, if i use a external cristal of 8MHz, and i divide it in 8 for give 1MHz, how works the funcion "__delay_cycles();"?, what cycles use of based? in the internal cycles or in the external cristal?
The __delay_cycles intrinsic consumes the given number of CPU cycles. Cycles lost to system effects such as memory wait states are not considered.
Thanks and regards,
-George
TI C/C++ Compiler Forum ModeratorPlease click Verify Answer on the best reply to your question.The Compiler Wiki answers most common questions.Track an issue with SDOWP. Enter your bug id in the "Find Record ID" box.