DSP

【DSP】TMS320F28035 定时器中断例程

2019-07-13 10:22发布

#include "DSP28x_Project.h" //extern Uint16 RamfuncsLoadStart; //extern Uint16 RamfuncsLoadEnd; //extern Uint16 RamfuncsRunStart; interrupt void Cpu_Timer0_ISR(void); int main(void) { InitSysCtrl(); EALLOW; GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 0; GpioCtrlRegs.GPADIR.bit.GPIO12 = 1; GpioDataRegs.GPADAT.bit.GPIO12 = 0; GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 0; GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1; GpioDataRegs.GPBDAT.bit.GPIO34 = 0; EDIS; DINT; InitPieCtrl(); IER = 0x0000; IFR = 0x0000; InitPieVectTable(); // MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart); // InitFlash(); EALLOW; PieVectTable.TINT0 = &Cpu_Timer0_ISR; EDIS; InitCpuTimers(); ConfigCpuTimer(&CpuTimer0,360,100000); //360为Freq,单位Hz;100000为Period,单位us;定时时长=Freq*Period/(pll时钟,单位Hz),单位s; StartCpuTimer0(); IER|=M_INT1; PieCtrlRegs.PIEIER1.bit.INTx7= 1; EINT; while(1) { } } interrupt void Cpu_Timer0_ISR(void) { GpioDataRegs.GPADAT.bit.GPIO12 =~ GpioDataRegs.GPADAT.bit.GPIO12; GpioDataRegs.GPBDAT.bit.GPIO34 =~ GpioDataRegs.GPBDAT.bit.GPIO34; PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;//写1清0,写0无效 CpuTimer0Regs.TCR.bit.TIF=1; CpuTimer0Regs.TCR.bit.TRB=1; }