CC2530运行几天之后,无线部分接收不到数据,单片机还运行正常。之前我测试过,无线接收溢出就会接收不到数据,不知,接收和发送缓冲区如何编写,我参照SimpliciTI-IAR-1.2.0中断接收,初始化如下,这样还是死机。
uint8 halRfInit(void)
{
// Enable auto ack and auto crc
FRMCTRL0 = 0;
//FRMCTRL0 |= (AUTO_ACK | AUTO_CRC|RX_MODE);
FRMCTRL0 |= (AUTO_ACK | AUTO_CRC);
FRMCTRL0 = (FRMCTRL0 & ~RX_MODE_MASK) | RX_MODE_NORMAL;
MDMCTRL1 = CORR_THR;
#ifdef NONE_INCLUDE_PA
CCACTRL0 = CCA_THR;
#else
CCACTRL0 = CCA_THR_HGM;
#endif
CSPT = 0XFF;
// Recommended RX settings
TXFILTCFG = 0x09;
AGCCTRL1 = 0x15;
FSCAL1 = 0x00;
FSMCTRL = 0; //接收之后用12超时周期。防止接收溢出
FIFOPCTRL = 80; /** 接收数据阀值 */
#if(NODETYPE == COORD)
FRMFILT0 |= 0x02; /** 设置为协调器 */
#endif
// Enable random generator -> Not implemented yet
MAC_MCU_RFERR_ENABLE_INTERRUPT();
// Enable CC2591 with High Gain Mode
halPaLnaInit();
// Enable RX interrupt
halRfEnableRxInterrupt();
return SUCCESS;
}
#ifndef MRFI
/************************************************************************************
* @fn rfIsr
*
* @brief Interrupt service routine that handles RFPKTDONE interrupt.
*
* @param none
*
* @return none
*/
HAL_ISR_FUNCTION( rfIsr, RF_VECTOR )
{
uint8 x;
HAL_INT_LOCK(x);
if( RFIRQF0 & IRQ_RXPKTDONE )
{
if(pfISR)
{
(*pfISR)(); // Execute the custom ISR
}
S1CON= 0; // Clear general RF interrupt flag
RFIRQF0 &= ~IRQ_RXPKTDONE; // Clear RXPKTDONE interrupt }
HAL_INT_UNLOCK(x);
}
HAL_ISR_FUNCTION( macMcuRfErrIsr, RFERR_VECTOR )
{
uint8 x;
uint8 rferrm;
HAL_INT_LOCK(x);
rferrm = RFERRM;
if ((RFERRF & RFERR_RXOVERF) & rferrm)
{
RFERRF = (RFERR_RXOVERF ^ 0xFF);
//macRxFifoOverflowIsr();
while(1);
}
//CLEAR_SLEEP_MODE();
HAL_INT_UNLOCK(x);
}
#endif
UINT8 RxMpdu[80];
static void ZNetworkRfRxFrmeDoneIsr(void)
{
UINT8 len;
do
{
/**< 循环读取,确保换成区空这样可以防止缓冲区溢出 */
while (!(RFIRQF0 & IRQ_FIFOP));
/**< Check for Rx overflow. Checking here means we may flush a valid frame */
if ((FSMSTAT1 & FIFOP) && (!(FSMSTAT1 & FIFO)))
{
/**< flush receive FIFO to recover from overflow (per datasheet, flush must be done twice) */
ISFLUSHRX();ISFLUSHRX();
break;
}
/**< clear interrupt flag so we can detect another frame later. */
RFIRQF0 &= ~IRQ_FIFOP;
/**< Read payload length. */
halRfReadRxBuf(&RxMpdu[0],1);
if(RxMpdu[0] < 64)
{
len = RxMpdu[0]; /**< 数据长度 */
halRfReadRxBuf(&RxMpdu[1],len);
/**< CRC IS OK AND 接收到的帧类型小于 MAC_FRAME_TYPE_CMD */
if((RxMpdu[len]&AUTO_CRC_BIT_MASK)&&((MAC_FRAME_TYPE&RxMpdu[1]) <= MAC_FRAME_TYPE_CMD))
{
if((len < 64)&&(len >5)) /**< MAC_FRAME_TYPE_ACK 去除ACK帧、和网络中大的数据帧 */
{
len++; /**< 包含长度+数据(数据+CRC) */
RxMpdu[len++] = 'R'; /**< RxStatus */
RxMpdu[len++] = 'C'; /**< CRC */
PHY_HandleRxFrameIrq(len,RxMpdu); }
}
}
else
{
ISFLUSHRX();ISFLUSHRX();
}
}while(RXFIFOCNT > 0);
}
我参照TIMAC1.5中断接收,初始化如下,这样还是死机。
HAL_ISR_FUNCTION( rfIsr, RF_VECTOR )
{
uint8 x;
uint8 rfim;
HAL_INT_LOCK(x);
rfim = RFIRQM1;
/* The CPU level RF interrupt flag must be cleared here (before clearing RFIRQFx).
* to allow the interrupts to be nested.
*/
S1CON = 0x00;
if ((RFIRQF1 & IRQ_CSP_MANINT) & rfim)
{
/*
* Important! Because of how the CSP programs are written, CSP_INT interrupts should
* be processed before CSP_STOP interrupts. This becomes an issue when there are
* long critical sections.
*/
/* clear flag */
RFIRQF1 = (IRQ_CSP_MANINT ^ 0xFF);
//macCspTxIntIsr();
}
else if ((RFIRQF1 & IRQ_CSP_STOP) & rfim)
{
/* clear flag */
RFIRQF1 = (IRQ_CSP_STOP ^ 0xFF);
//macCspTxStopIsr();
}
else if ((RFIRQF1 & IRQ_TXACKDONE) & rfim)
{
/* disable interrupt – set up is for "one shot" operation */
RFIRQM1 &= ~IM_TXACKDONE;
//macRxAckTxDoneCallback();
}
rfim = RFIRQM0;
/* process RFIRQF0 next */
if ((RFIRQF0 & IRQ_FIFOP) & rfim)
{
/* continue to execute interrup t handler as long as FIFOP is active */
do
{
if(pfISR)
{
(*pfISR)(); // Execute the custom ISR
}
//macRxThresholdIsr();
RFIRQF0 = (IRQ_FIFOP ^ 0xFF);
} while (FSMSTAT1 & FIFOP);
}
//CLEAR_SLEEP_MODE();
HAL_INT_UNLOCK(x);
}
HAL_ISR_FUNCTION( macMcuRfErrIsr, RFERR_VECTOR )
{
uint8 x;
uint8 rferrm;
HAL_INT_LOCK(x);
rferrm = RFERRM;
if ((RFERRF & RFERR_RXOVERF) & rferrm)
{
RFERRF = (RFERR_RXOVERF ^ 0xFF);
//macRxFifoOverflowIsr();
while(1);
}
//CLEAR_SLEEP_MODE();
HAL_INT_UNLOCK(x);
}
#endif
tao feng2:
为什么没有解答
tao feng2:
昨天晚上定位了一下问题,AF_DataRequest 在发送的时候 会出现 0x10 和0x00 这两种状态,但是MAC层的发送接口 macTxFrame是没有被调用到。也就是发送数据死掉在网络层。请问这是什么情况导致,求TI技术大师支持。
VV:
回复 tao feng2:
已经在另外一个帖子里面回复你了
http://www.deyisupport.com/question_answer/wireless_connectivity/zigbee/f/104/p/80720/201803.aspx#201803