void Drv_Hrcap1Init(void)
{
//------------------------HRCAP1初始化------------------------------------
EALLOW;
HRCap1Regs.HCCTL.bit.SOFTRESET = 1;
HRCap1Regs.HCCTL.bit.HCCAPCLKSEL = 1; //0: HCCAPCLK = SYSCLK = 60MHZ
HRCap1Regs.HCCTL.bit.RISEINTE = 1; //关闭上升沿捕获事件中断
HRCap1Regs.HCCTL.bit.FALLINTE = 0;
HRCap1Regs.HCCTL.bit.OVFINTE = 0;
EDIS;
}
在FOR中执行Hrcap1Detec ();利用查询标识位的方式来检测PWM的频率,Hrcap1Detec 代码如下:
#pragma CODE_SECTION(Hrcap1Detec,"ramfuncs"); //位置1
void Hrcap1Detec (void)
{
u16Cap1PulsPeriod = 0;
u16Hrcap1Riseflag = HRCap1Regs.HCIFR.bit.RISE;
if(0x01 == u16Hrcap1Riseflag)
{
EALLOW;
if (HRCap1Regs.HCIFR.bit.RISEOVF == 1)
{
}
if (u16Hrcap1First==0)
{
u16Hrcap1First = 1;
}
else
{
u16Cap1PulsHigh = HRCap1Regs.HCCAPCNTFALL1 + 1;
u16Cap1PulsLow = HRCap1Regs.HCCAPCNTRISE0 + 1;
u16Cap1PulsPeriod = u16Cap1PulsHigh + u16Cap1PulsLow;
}
HRCap1Regs.HCICLR.all = 0x001F;
EDIS;
}
}
问题:1、调试仿真运行正常,写入到FLASH中运行中,如果把<位置1>处的代码去掉,就不会产生上升沿捕获标识位RISE;
2、单个例程运行没什么问题,但是把这部分代码放到自已的工程中去,就有问题了(感觉不会产生上升沿标识位RISE),即使把工程中其它的代码屏蔽掉也一样,不知道什么原因 |