Hi all:
I need a "wasting of time" code for my application. I am writing in C, using EZ430 RF2500 development kit. Anyone know a "doing nothing" just waste a few clock cycle code?
Thanks
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.
Hi all:
I need a "wasting of time" code for my application. I am writing in C, using EZ430 RF2500 development kit. Anyone know a "doing nothing" just waste a few clock cycle code?
Thanks
In the "intrinsics.h" file there is a delay cycle function that can just add delay. If you add the following line it adds 200 CPU cycles of delay.
__delay_cycles(200); // Normal delay between bytes
The other alternative is using a bunch of NOPs:
__no_operation();
May be the community has more tricks to share :)
seadreamer said:Does anyone know if this code could do the trick?
But a better way is to have a timer running at a known frequency (e.g. 1MHz) in continuous mode. Then set a CCR register (e.g. TACCR2) to TAR+delay and wait for the CCRIFG flag being set. This allows an exact delay of 'delay' microseconds. And as long as the init code ensure that the tiemr runs at 1MHz (even if the core or crystal frequency might be different), the code using this type of delay will work the same on all projects. No need to adjust it then depending on the current MCLK.
**Attention** This is a public forum