最经在IAR环境下对CC4330F6137单片机编程,有一个设备发送无线正弦波数据过来,经过解调模块后变为方波呈现在该MCU一个引脚上(P4IN&EOB),下面的是数据接收代码,现在问题出现了,debug模式下数据接收完全正确,但是退出debug模式后单独硬件运行就收不到数据。哪位大神能不能帮帮忙找找问题,小弟不胜感激...
FDCOCLK 配置为8mhz
ACLK时钟源为FDCOCLK,方波段为先高后低最后为低,对低电平计时,高于400us认为数据1低于400us认为数据0
boolean LF_LFdataRec(uint8 *LFrecBuf,uint8 LFrecBufSiz)
{
uint8 RecBufIdx,RecBitIdx,rec_byte;
TA1CCTL0 = 0;
TA1CCR0 = 50000; //Timeout 50ms
TA1CTL = TASSEL__ACLK + ID_3 + MC_1 +TACLR; //select ACLK/8=1MHZ UP MODE
while(!(P4IN&EOB))
{
if(Bit_IS_Set(TA1CCTL0,CCIFG))
{
Clear_Bit(TA1CCTL0,CCIFG); //CCIFG CLEAR
TA1CTL = 0;
return FALSE;
}
}
while((P4IN&EOB));
for(RecBufIdx=0;RecBufIdx<LFrecBufSiz;RecBufIdx++)
{
TA0CCTL0 = 0x0000;
TA0CCR0 = 20000; // 20ms timeout to receive a byte data
TA0CTL = TASSEL__ACLK + MC_1 + ID_3 + TACLR; // ACLK/8, UP_MODE, CLR TIMER.
rec_byte=0;
for(RecBitIdx=0;RecBitIdx<8;RecBitIdx++)
{
rec_byte<<=1;
TA1CTL|=TACLR; //RESET TIMER1
TA1CTL = TASSEL__ACLK + MC_1 + ID_3 + TACLR;
while((!(P4IN&EOB)) && (Bit_IS_Clear(TA0CCTL0,CCIFG)));
if(TA1R>417) rec_byte|=0x01;
if(Bit_IS_Set(TA0CCTL0,CCIFG))
{
TA0CTL = 0; TA0CCTL0 = 0; TA1CTL=0; TA1CCTL0=0;
return FALSE;
} //timeout
while((P4IN&EOB) && (Bit_IS_Clear(TA0CCTL0,CCIFG)));
if(Bit_IS_Set(TA0CCTL0,CCIFG))
{
TA0CTL = 0; TA0CCTL0 = 0; TA1CTL=0; TA1CCTL0=0;
return FALSE;
} //timeout
}
LFrecBuf[RecBufIdx]=rec_byte;
}
TA0CTL = 0; TA0CCTL0 = 0; TA1CTL=0; TA1CCTL0=0;
return TRUE;
} |