📄 timer.c
字号:
#include "DSP281x_Device.h" // DSP281x Headerfile Include File
#include "DSP281x_Examples.h" // DSP281x Examples Include File
#include "timer.h"
interrupt void cpu_timer0_isr(void);
void init_gpio(void){
EALLOW;
GpioMuxRegs.GPAMUX.all=0x0000;
GpioMuxRegs.GPADIR.all=0xffff; // PA DIR: 1=output,0=input
GpioMuxRegs.GPAQUAL.all=0x0000; // PA Input Qualification:
GpioMuxRegs.GPBMUX.all=0x0000;
GpioMuxRegs.GPBDIR.all=0xffff; // PA DIR: 1=output,0=input
GpioMuxRegs.GPBQUAL.all=0x0000; // PA Input Qualification:
EDIS;
}
interrupt void cpu_timer0_isr(void)
{
CpuTimer0.InterruptCount++;
// Acknowledge this interrupt to receive more interrupts from group 1
PieCtrlRegs.PIEACK.all = PIEACK_GROUP1;
cputimer0_f = 1;
}
void main(void)
{
InitSysCtrl();
init_gpio();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW; // This is needed to write to EALLOW protected registers
PieVectTable.TINT0 = &cpu_timer0_isr;
EDIS; // This is needed to disable write to EALLOW protected registers
InitCpuTimers();
ConfigCpuTimer(&CpuTimer0, 150, 25000);
StartCpuTimer0();
IER |= M_INT1; // for TINT0
PieCtrlRegs.PIEIER1.bit.INTx7 = 1;
EINT;
ERTM;
for(;;) {
if(cputimer0_f == 1) {
GpioDataRegs.GPATOGGLE.bit.GPIOA0 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA1 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA2 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA3 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA4 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA5 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA6 =1;
GpioDataRegs.GPATOGGLE.bit.GPIOA7 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB0 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB1 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB2 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB3 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB4 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB5 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB6 =1;
GpioDataRegs.GPBTOGGLE.bit.GPIOB7 =1;
cputimer0_f = 0;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -