请教CC1100E的同步字检测中断的设置问题:
试验发现,采用以下的中断设置和函数,当TI_CCxxx0_IOCFG2=0x07、即接收到CRC_OK时产生中断,程序能正常地待机和接收到数据;但当TI_CCxxx0_IOCFG2=0x06、即设置为接收到同步字时产生中断,则会不断地进入中断,而此时并没有模块在发送,即很容易地误触发同步字中断。
请问如果需要采用检测到同步字时才产生中断,应该如何设置(包括各相关的寄存器的设置)?
//====================== GDO2的外部中断设置 ====================
void GDO2_ISR(void)
{
TI_CC_GDO2_PxSEL &=~TI_CC_GDO2_PIN; // 普通IO
TI_CC_GDO2_PxDIR &=~TI_CC_GDO2_PIN; // input
TI_CC_GDO2_PxREN |= TI_CC_GDO2_PIN; //
TI_CC_GDO2_PxOUT &=~TI_CC_GDO2_PIN; // Set P2.1 as pull-Down resistance TI_CC_GDO2_PxIES &=~TI_CC_GDO2_PIN; // P2.1 Lo->Hi edge
TI_CC_GDO2_PxIFG &=~TI_CC_GDO2_PIN; // P2.1 IFG cleared
TI_CC_GDO2_PxIE |= TI_CC_GDO2_PIN; // P2.1 interrupt enabled,GDO2
}
//*******************以下为中断函数**************************
// P2.1 GDO2中断服务(Lo->Hi上升沿中断)
#pragma vector = PORT2_VECTOR
__interrupt void port2_ISR (void)
{
if(P2IFG & TI_CC_GDO2_PIN) // Command received from RF
{ // RX active
P2IFG &= ~TI_CC_GDO2_PIN; // Clear Receive flag
__bic_SR_register_on_exit(LPM3_bits); // Clear LPM3 bits from 0(SR)
TACCTL0 &= ~CCIE; // Disable timer Interrupt P2IFG &= ~BIT1; // P2.1 IFG cleared
P2IE &= ~BIT1; // P2.1 interrupt disabled,GDO2
}
}
TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG2, 0x07);
TI_CC_SPIWriteReg(TI_CCxxx0_IOCFG0, 0x06);
Shu Davin:
测试通过的代码,你试试
#define BIT2 (0x0004u)
#define GDO2 BIT2 //I //P1IN
void InitPort1Interrupt(void)
{
P1IFG &= ~GDO2; // Clear flag
P1IES |= GDO2; // Int on falling edge (end of pkt)
P1IE |= GDO2; // Enable int on end of packet
}
#pragma vector=PORT1_VECTOR
__interrupt void ISR_PORT1 (void)
{
if (P1IFG&GDO2)
{
P1IFG &= ~GDO2;
radioRxFlag = 1;
LPM3_EXIT;
}
}