Other Parts Discussed in Thread: CONTROLSUITE
I'm puzzled about how to use CPU timer0. I've looked at the example program included in controlSUITE but I find the comments very lacking.
The timer's ISR fires periodically but seems to take maybe 4-5 times longer between interrupts than it should. For example a one-second delay results in interrupts every five seconds.
I thought that maybe CPU_RATE was set to a smaller value than it should be at 60 MHz (i.e., 16.6 ns) but it looks to be okay unless I'm missing some included location in the project.
Here's how I'm trying to program timer0 hardware:
#include "DSP28x_Project.h" // DSP28x header file #include "f2802x_common/include/F2802x_SWPrioritizedIsrLevels.h" #include "f2802x_common/include/cpu.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/adc.h" #include "f2802x_common/include/clk.h" #include "f2802x_common/include/gpio.h" #include "f2802x_common/include/pie.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/timer.h" #include "f2802x_common/include/pll.h" #include "f2802x_common/include/sci.h" #include "f2802x_common/include/sci_io.h" #include "f2802x_common/include/wdog.h" #ifdef _FLASH // _FLASH is defined in the project properties memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); #endif // Select the internal oscillator 1 as the clock source. CLK_setOscSrc(myClk, CLK_OscSrc_Internal); // Set up the PLL for x12/2 which will yield 60 MHz (10 MHz*12/2). PLL_setup(myPll, PLL_Multiplier_12, PLL_DivideSelect_ClkIn_by_2); ... ... ... TIMER_setPeriod(myTimer0, 60L*1000L); // Sample rate TIMER_setPreScaler(myTimer0, 0); TIMER_reload(myTimer0); TIMER_setEmulationMode(myTimer0, TIMER_EmulationMode_StopAfterNextDecrement); TIMER_enableInt(myTimer0); TIMER_start(myTimer0);