Hi!
What's the variable type of number_of_microseconds? It must be long int or unsigned long int. Otherwise the 150*number_of_microseconds multiplication is a short int multiplication giving a wrong result. I tested it and I got ticks_required=4294959968 when using int as data type. With a long int data type it worked fine (just tested on a f28335).
Regards,Edwin Krasser
It's a Uint32. My device is a 2812.
A bit more info. Using a figure of 10,000 microseconds, the 'stop_point' ends up as 4293467295, or 0xFFE9 1C9F. With this value, the higher 16-bits are being considered. Tests with lower delays end up with 'stop_point' figures that leave the higher 16-bits as 0xFFFF. This may be something to do with the problem.
I do not think that the 16-bit and 0xFFFF matter. You told that it worked with 1000 us wait time (150000 ticks, stop time will be 0xFFFD B60F). I do not know what else is running in your software, but the problem should derive from somewhere else (Watchdog? ISRs? Other functions accessing CPU timer 0? DSP-BIOS?).
Yes, you're right with the figures - my mistake! I'll take a look and see what else might be mangling things. Thanks for your help so far!
Dear all
I add the following line in my code.
#define DELAY_US(A) DSP28x_usDelay(((((long double) A * 1000.0L) / (long double)CPU_RATE) - 9.0L) / 5.0L)
When I want to build my project there is an error that "CPU_RATE" is undefined. However, the DSP2833x_Examples.h is included in my project and when I press Ctrl and click on "CPU_RATE", it directs me to to line "#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)" in file "DSP2833x_Examples.h" which means for me that "DSP2833x_Examples.h" is linked to my project. If I replace the "CPU_RATE" with "6.667L", there is not error. What is the problem?
Second problem, as I said if I replace the "CPU_RATE" with "6.667L", my code doesn't have any error. But if I use "DELAY_US(1000000)" in my code, the delay is not working any more but if I use "DSP28x_usDelay(1000000)", delay works.
Can you please help me
Arash
Hi Lori
When I want to build my project there is an error that "CPU_RATE" is undefined. However, theDSP2833x_Examples.h is included in my project and when I press Ctrl and click on "CPU_RATE", it directs me to to line "#define CPU_RATE 6.667L // for a 150MHz CPU clock speed (SYSCLKOUT)" in file "DSP2833x_Examples.h" which means for me that "DSP2833x_Examples.h" is linked to my project. If I replace the "CPU_RATE" with "6.667L", there is not error. What is the problem?
Can you please help me?
Hi,
as I already wrote in this thread: I strongly recommend not to use such delay loops because these loops do not have an exact wait time. It's better to use the 32 bit CPU timer (initialize it just after startup) und wait for a given number of ticks. That's exact, even if interrupts occur during waiting.
Best regards,Edwin Krasser