Other Parts Discussed in Thread: CC2530
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Other Parts Discussed in Thread: CC2530
void MT_UartProcessZToolData ( uint8 port, uint8 event )
{
OSALSerialData_t *pMsg;
uint8 flag=0; //flag 是判断有没有收到数据,j 记录数据长度
uint8 DataSize=0; //数据大小
uint8 buf[MT_UART_DEFAULT_MAX_RX_BUFF]; //串口buffer 最大缓冲默认是256,我们这里用256.
(void)event; // Intentionally unreferenced parameter
// if (event & HAL_UART_RX_TIMEOUT)
// {
while (Hal_UART_RxBufLen(port)) //检测串口数据是否接收完成
{
HalUARTRead (port,&buf[DataSize], 1); //把数据接收放到 buf中
DataSize++; //记录字符数
flag=1; //已经从串口接收到信息
}
if(flag==1) //已经从串口接收到信息
{ /* Allocate memory for the data */
//分配内存空间,为机构体内容+数据内容+1 个记录长度的数据
pMsg = (OSALSerialData_t *)osal_msg_allocate( sizeof ( OSALSerialData_t )+DataSize+1);
pMsg->hdr.event = SERIAL_DATA_MSG; //事件号用原来的CMD_SERIAL_MSG
pMsg->msg = (uint8*)(pMsg+1); // 把数据定位到结构体数据部分
pMsg->msg [0]= DataSize; //给上层的数据第一个是长度
for(uint16 i=0;i<DataSize;i++) //从第三个开始记录数据
pMsg->msg [i+1]= buf[i];
osal_msg_send( App_TaskID, (byte *)pMsg ); //登记任务,发往上层
}
// }
// /* deallocate the msg */
// osal_msg_deallocate ( (uint8 *)pMsg ); //释放内存
}
应该不是这个问题,我仿真调试过。断点打在这个函数里,电脑发给该设备发送数据,有时会等几秒才函数。接收到的数据是对的。
if (dmaCfg.txShdwValid)
{
uint8 decr = ST0;
decr -= dmaCfg.txShdw;
if (decr > dmaCfg.txTick)
{
// No protection for txShdwValid is required
// because while the shadow was valid, DMA ISR cannot be triggered
// to cause concurrent access to this variable.
dmaCfg.txShdwValid = FALSE;
}
}
这段代码decr可能没有读取到ST0的值或者ST0工作异常,导致dmaCfg.txShdwValid值不能赋值为FALSE,从而不能发送数据。(本来我想用watch查看decr的值和dmaCfg.txShdwValid的值,但是一用watch查看dmaCfg.txShdwValid的值,软件就无响应弹出了。我重装软件还是不行)所以想请问你一下,什么原因会导致decr读取ST0值异常呢?又或者其他原因?