Hello Lori, Thank you for answer me. Now I write the program but it is not complete, the project consists in a timer wich toggle a led every minute, then I need to call an interrupt every second, and if the count reach 60 interrupts the light on GPIO3 is ON. In the following code my goal is to comment some pieces of the code from the System Control and Interrupts Reference Guide that I'm not understand at this moment: #include "DSP28x_Project.h" __interrupt void cpu_timer0_isr(void); int Control; int count; void main(void) { InitSysCtrl(); DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); EALLOW; PieVectTable.TINT0 = &cpu_timer0_isr; //Conect isr direction with PIE IER |= M_INT1; //Enable interrupt 1 that is connected to timer0 PieCtrlRegs.PIEIER1.bit.INTx7 = 1; // Enable TINT0 in the PIE: interrupt 7 group 1 EINT; // Enable the global interrupts EDIS; EALLOW; SysCtrlRegs.WDCR = 0X68; //watchdog disabled SysCtrlRegs.CLKCTL.bit.OSCCLKSRCSEL = 0; SysCtrlRegs.CLKCTL.bit.INTOSC1OFF = 0; //Enable On chip oscillator 1 -> 1/10M = 1*10^(-6) (usec) SysCtrlRegs.CLKCTL.bit.INTOSC2OFF = 1; //Disable On Chip Oscillator 2 to reduce power consumption SysCtrlRegs.PLLSTS.bit.OSCOFF = 0; SysCtrlRegs.PLLSTS.bit.PLLOFF = 0; // PLL is enabled SysCtrlRegs.PLLSTS.bit.MCLKOFF = 1; // Missing Clock detection is disabled before write on PLLCR SysCtrlRegs.PLLSTS.bit.DIVSEL = 0; //Must be 0 before to write on PLLCR SysCtrlRegs.PLLCR.bit.DIV = 0X000C; //FOSC = OSCCLK*10/n, DIV=[0,1,..,12] (0=bypass) SysCtrlRegs.PLLSTS.bit.PLLLOCKS = 1; //After this we write a new value to DIVSEL SysCtrlRegs.PLLSTS.bit.DIVSEL = 2; //FOSC = 10*12/2 = 60 MHz. n-[0,1,2,4] SysCtrlRegs.PLLLOCKPRD= 10000; //must be at least 10000 (On chip Oscillator 1 is enable) EDIS; //Input Clock Period = [Pll Output freq]^-1 = 16.67 ns Aprox EALLOW; CpuTimer0Regs.TCR.bit.TSS = 0; // Start timer CpuTimer0Regs.TCR.bit.TRB = 1; // load the timer0 with period value /RELOAD TIMER CpuTimer0Regs.TCR.bit.TIE = 1; // timer0 interrupt enable CpuTimer0Regs.TPRH.bit.TDDRH = ?; //Don't know how to set CPU time divide-down register. CpuTimer0Regs.TPR.bit.TDDR = ?; // the value to set the bit is a mistery for me. is an Integer, Hexadecimal or binary value? the manual says: To increase the overall timer count by an integer factor write this factor minus one to the TDDR bit. In addition, CpuTimer0Regs.TIM.half.LSW=?; //This bit represent value of 2^16 or 2^32 actually? CpuTimer0Regs.PRD.all = 0xFFFF; //This value set the time duration of the ON/OFF led light CpuTimer0.InterruptCount = 0; //reset interrupt counter CpuTimer0.RegsAddr = &CpuTimer0Regs; EDIS; EALLOW; GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 0; GpioCtrlRegs.GPADIR.bit.GPIO3= 1; EDIS; while(1) { if (Control == 60) //I need this statement to guarantee that led toggle in 1 minute { count = CpuTimer0Regs.TIM.all; } } } __interrupt void cpu_timer0_isr(void) { CpuTimer0.InterruptCount++; GpioDataRegs.GPATOGGLE.bit.GPIO3 = 1; PieCtrlRegs.PIEACK.all = PIEACK_GROUP1; // Acknowledge this interrupt to receive more interrupts from group 1 Control= CpuTimer0.InterruptCount; } // No more
↧