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 am getting familiar with the CPU timer on the F28335. I read the SPRUFB0 technical note and implemented the timer0 on my device. The ISR should occur every 300ns, in which I am toggling a GPIO. What makes me wonder is that the scope waveforms do not really match with the way I intented to implement it. Am I having a fundamental misunderstanding in my code? Thank you.
My code:
/* This example uses the CPU timer to cause an interrupt and to toggle a pin on GPIO12 */ #include "DSP28x_Project.h" // Device Headerfile and Examples Include File __interrupt void timer0_isr(void); void main(void) { // Step 1: Setting the PLL, Watchdog, enable peripheral clocks InitSysCtrl(); // Step 2: Initialize your GPIO InitGpio(); // Step 3: Initialize the PIE control registers // DINT; // Only necessary here if InitPieCtrl() does not have DINT; included InitPieCtrl(); IER = 0x0000; IFR = 0x0000; // Step 4: Initialize the PIE vector table to default ISR InitPieVectTable(); // Step 5: Initialize other device peripherals // Set GPIO as an output and initialize its state as logic 0 EALLOW; GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; EDIS; GpioDataRegs.GPACLEAR.bit.GPIO12 = 1; // Remap the ISR function to the PIE vector table EALLOW; PieVectTable.TINT0 = &timer0_isr; EDIS; // Initializes timer 0 peripherals using the CpuTimers.c function InitCpuTimers(); // Configures CPU timer 0 using the CpuTimers.c function. 150Mhz CPU freq. and 300ns period ConfigCpuTimer(&CpuTimer0,150,0.3); // Starting the counter and enabling the CPU timer interrupt CpuTimer0Regs.TCR.bit.TSS = 0; // Clears TSS bit and starts CPU timer CpuTimer0Regs.TCR.bit.TIE = 1; // Enables the CPU timer interrupt // Enable TINT0 in PIE // PieCtrlRegs.PIECTRL.bit.ENPIE = 1; // Enables PIE vector table. Already enabled in InitPieVectTable(); PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Group 1, bit 7 for timer0 IER |= M_INT1; // Sets the interrupt enable bit of group 1 EINT; // Enable global interrupts INTM for(;;) { } } __interrupt void timer0_isr(void) { // Set GPIO12 during ISR GpioDataRegs.GPASET.bit.GPIO12 = 1; // Acknowledge interrupt to receive more interrupts from group 1 PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; GpioDataRegs.GPACLEAR.bit.GPIO12 = 1; }
The two scope pictures: