不知道怎么回事,自己的28027Luanchpad 加载TI epwm例程中断都进不去了(以前调试的时候都可以),自己在网上找了个简单的程序,感觉没有错误,下载进去后,程序一直进不了中断;跪求大神指导
#include "DSP28x_Project.h" // Device Headerfile and Examples Include File
/*******************************************************************************
全局变量
*******************************************************************************/
volatile Uint32 Num;
int SinceTable[200] = { 0, 23, 47, 70, 94, 117, 141, 164, 187, 211, 234, 257,
281, 304, 327, 350, 373, 395, 418, 441, 463, 485, 508, 530, 552, 574,
595, 617, 638, 659, 680, 701, 722, 743, 763, 783, 803, 823, 843, 862,
881, 900, 919, 937, 956, 974, 991, 1009, 1026, 1043, 1060, 1077, 1093,
1109, 1125, 1140, 1155, 1170, 1185, 1199, 1213, 1227, 1240, 1253, 1266,
1278, 1291, 1302, 1314, 1325, 1336, 1347, 1357, 1367, 1376, 1385, 1394,
1403, 1411, 1419, 1426, 1433, 1440, 1446, 1452, 1458, 1463, 1468, 1473,
1477, 1481, 1485, 1488, 1490, 1493, 1495, 1497, 1498, 1499, 1499, 1499,
1499, 1499, 1498, 1497, 1495, 1493, 1490, 1488, 1485, 1481, 1477, 1473,
1468, 1463, 1458, 1452, 1446, 1440, 1433, 1426, 1419, 1411, 1403, 1394,
1385, 1376, 1367, 1357, 1347, 1336, 1325, 1314, 1302, 1291, 1278, 1266,
1253, 1240, 1227, 1213, 1199, 1185, 1170, 1155, 1140, 1125, 1109, 1093,
1077, 1060, 1043, 1026, 1009, 991, 974, 956, 937, 919, 900, 881, 862,
843, 823, 803, 783, 763, 743, 722, 701, 680, 659, 638, 617, 595, 574,
552, 530, 508, 485, 463, 441, 418, 395, 373, 350, 327, 304, 281, 257,
234, 211, 188, 164, 141, 117, 94, 70, 47, 23, };
/*******************************************************************************
函数声明
*******************************************************************************/
void EPWM_init();
interrupt void epwm1_timer_isr(void);
/*
* main.c
*/
int main(void)
{
// Step 1. Initialize System Control:
// PLL, WatchDog, enable Peripheral Clocks
// This example function is found in the DSP2802x_SysCtrl.c file.
InitSysCtrl();
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EALLOW;
PieVectTable.EPWM1_INT = &epwm1_timer_isr;
EDIS;
EALLOW;
GpioCtrlRegs.GPAPUD.bit.GPIO0 = 1;
GpioCtrlRegs.GPAPUD.bit.GPIO1 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 1;
GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 1;//设置GPIO0/GPIO1为EPWM1A/EPWM1B
EDIS;
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 0;
EDIS;
EPWM_init();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC = 1;
EDIS;
IER|=M_INT3;
PieCtrlRegs.PIEIER3.bit.INTx1 = 1;
EINT;
ERTM;
Num = 0;
while(1);
}
/************************************************************************************************
***
**Function: ** void EPWM_init(void)
**Description: ** 初始化EPWM模块
**Input: ** Null
**Output: ** Null
**Others: ** Null
*************************************************************************************************
**/
void EPWM_init()
{
EPwm1Regs.TBPRD = 1500; // Set timer period
EPwm1Regs.TBPHS.half.TBPHS = 0x0000; // Phase is 0
EPwm1Regs.TBCTR = 0x0000; // Clear counter
// Setup TBCLK
EPwm1Regs.TBCTL.bit.CTRMODE = TB_COUNT_UPDOWN; // Count up/down
EPwm1Regs.TBCTL.bit.PHSEN = TB_DISABLE; // Disable phase loading
EPwm1Regs.TBCTL.bit.HSPCLKDIV = TB_DIV1; // Clock ratio to SYSCLKOUT
EPwm1Regs.TBCTL.bit.CLKDIV = TB_DIV1; //TBCLK = SYSCLKOUT / (HSPCLKDIV × CLKDIV)
//TBCLK = SYSCLKOUT
// Load registers
EPwm1Regs.CMPCTL.bit.SHDWAMODE = CC_SHADOW; // Load registers every ZERO
EPwm1Regs.CMPCTL.bit.LOADAMODE = CC_CTR_ZERO;
// Setup compare
EPwm1Regs.CMPA.half.CMPA = 1000;
// Set actions
EPwm1Regs.AQCTLA.bit.CAU = AQ_CLEAR;
EPwm1Regs.AQCTLA.bit.ZRO = AQ_SET;
EPwm1Regs.AQCTLA.bit.CAD = AQ_SET;
//set interrupt
EPwm1Regs.ETSEL.bit.INTSEL =ET_CTR_ZERO; // 计数值等于0时产生中断
EPwm1Regs.ETSEL.bit.INTEN = 1; // 使能中断
EPwm1Regs.ETPS.bit.INTPRD = ET_1ST; // 第一次时产生中断
}
interrupt void epwm1_timer_isr(void)
{
int count = 0;
count++;
if (Num > 200)
{
Num = 0;
}
EPwm1Regs.CMPA.half.CMPA = SinceTable[Num];
Num++;
EPwm1Regs.ETCLR.bit.INT = 1;
PieCtrlRegs.PIEACK.all = PIEACK_GROUP3;
}
此帖出自
小平头技术问答
一周热门 更多>