贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
yong mao:
IER I=M_INT3
EINT; //开全局中断 ERTM; //开实时中断
放在这两句指令前,这个使能这组中断怎么都没有呢?多看下例程
贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
user1890059:
回复 yong mao:
怎么没有,主函数里
贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
user1890059:
回复 yong mao:
M_INT3就是0x0004
贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
alisa song:
回复 user1890059:
谢谢你的分享,调试了几天的程序进不了中断,现在终于找到原因了。
贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
user3726176:
回复 alisa song:
能分享一下吗?我现在也遇到这个问题了
贴出部分程序跟中断配置相关的,求解答,连上板子,在中断函数里加了断点,怎么也进不去,程序直接在主函数那等待
void main()
{
InitSysCtrl();
DINT;
InitPieCtrl();
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
InitEPwm();
InitAdc();
EALLOW;
SysCtrlRegs.PCLKCR0.bit.TBCLKSYNC=1; //ePWM模块与基准时钟同步
PieVectTable.EPWM1_INT=&EPWM1_isr; //重新映射中断地址
EDIS;
IER|=0x0004; //使能PIE组3向量 PieCtrlRegs.PIECTRL.bit.ENPIE=1; //使能PIE模块
PieCtrlRegs.PIEIER3.bit.INTx1=1; //使能PIE组3中中断1
PieCtrlRegs.PIEACK.all=0x0004; //确保组1中的PIEACK位被清除
EINT; //开全局中断
ERTM; //开实时中断
for(; 😉
{ }
}
void InitEPwm(void)
{
// Initialize ePWM1/2/3/4/5/6
//tbd…
InitEPwmGpio(); EPwm1Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm1Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm1Regs.TBCTR=0; //计数初值为0
EPwm1Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm1Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm1Regs.CMPB=0; //比较初始值为0
EPwm1Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm1Regs.AQCTLA.all=0x0050; //输出强制低
EPwm1Regs.AQCTLB.all=0x0050; //输出强制低
EPwm1Regs.DBCTL.all=0x000B; //死区控制寄存器,00 1011,EPWMxA为输入,主高互补,死区对EPWMxA
//的上升沿和EPWMxB的下降沿完全使能
EPwm1Regs.DBRED=0x0064; //上升沿加死区2us 0x0064=100
EPwm1Regs.DBFED=0x0064; //下降沿加死区2us 0x000A=10
EPwm1Regs.ETSEL.bit.INTEN=1; //使能EPwm1中断
EPwm1Regs.ETSEL.bit.INTSEL=2; //使能TBCTR=TBPRD事件
EPwm1Regs.ETPS.bit.INTPRD=1; //第一个事件产生中断,EPWM1中断
EPwm1Regs.ETCLR.bit.INT=1; //清楚中断标志位
EPwm2Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm2Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm2Regs.TBCTR=0; //计数初值为0
EPwm2Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm2Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm2Regs.CMPB=0; //比较初始值为0
EPwm2Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm2Regs.AQCTLA.all=0x0050; //输出强制低
EPwm2Regs.AQCTLB.all=0x0050; //输出强制低
EPwm2Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm2Regs.DBRED=0x0064; //上升沿加死区
EPwm2Regs.DBFED=0x0064; //下降沿加死区
EPwm3Regs.TBPRD=3750; //150Mhz/2=75Mhz 增减模式3750*2=7500 10K载波
EPwm3Regs.TBPHS.half.TBPHS=0; //相位置0
EPwm3Regs.TBCTR=0; //计数初值为0
EPwm3Regs.TBCTL.all=0x0082; //时间基准2分频变为75Mhz 对称PWM 无初始相位 同步输出 EPwm3Regs.CMPA.half.CMPA=3000; //比较初始值为0
EPwm3Regs.CMPB=0; //比较初始值为0
EPwm3Regs.CMPCTL.all=0x0000; //CTR=0时加载比较值,映射寄存器加载模式
EPwm3Regs.AQCTLA.all=0x0050; //输出强制低
EPwm3Regs.AQCTLB.all=0x0050; //输出强制低
EPwm3Regs.DBCTL.all=0x000B; //死区控制寄存器
EPwm3Regs.DBRED=0x0064; //上升沿加死区
EPwm3Regs.DBFED=0x0064; //下降沿加死区
}
interrupt void EPWM1_isr()
{
EPwm1Regs.CMPA.half.CMPA=2000;
ADSAMPLE();
PLL_PI();
if(k<=1600); //延时四个电网周期发脉冲
{
k++; //EPwm初始化里已强制低
if(k==1600)
{
EPwm1Regs.AQCTLA.all=0x0060; //比较匹配CMPA时高有效
EPwm1Regs.AQCTLB.all=0x0090; //比较匹配CMPA时低有效
EPwm2Regs.AQCTLA.all=0x0060;
EPwm2Regs.AQCTLB.all=0x0090;
EPwm3Regs.AQCTLA.all=0x0060;
EPwm3Regs.AQCTLB.all=0x0090;
k=1601;
}
}
CURRENT_PI();
SVPWM();
EPwm1Regs.ETCLR.bit.INT=1; //清楚EPWM那个相应的中断标志
PieCtrlRegs.PIEACK.bit.ACK3=1; //响应同组中断
EINT; //开全局中断
}
he ren:
回复 user1890059:
因为软件的原因吗