大家好、我有一个连接到 BeagleBone 的 CC1312。 BeagleBone 通过 UART 向 CC1312发送命令。 一切都正常、但如果发送过多命令(在短时间内)写入 CC1312的闪存、CC1312会复位、并且在其闪存中数据错误。 当 CC1312在无线电接收器上时、会发生这种情况。 很遗憾、我无法发送整个程序、但它如下所示:
// I use UART2_Mode_CALLBACK;
void readCallbackUart(UART2_Handle handle, void *buf, size_t count,
void *userArg, int_fast16_t status)
{
device.isUartRead = status == UART2_STATUS_SUCCESS ? 1 : 0;
// I tried to add following but it did not help
if (status != UART2_STATUS_SUCCESS)
{
UART2_flushRx(uartHandle);
}
}
// radio receiving and uart processing
RF_postCmd(rfHandle, (RF_Op *)&RF_cmdPropRx, RF_PriorityNormal,
radioCallback,
RF_EventRxEntryDone);
while (((volatile RF_Op *)&RF_cmdPropRx)->status < 4)
{
if (device.isUartRead)
{
// here is called a function performing writing to flash
// it uses two region, one si a mirror to allow change only some without
// having the whole region in ram hence there are commands NVS_erase
// and NVS_write
// after processing the command ACK via uart is sent
device.isUartRead = 0;
UART2_read(uartHandle, &uartBuffer, sizeof(uartBuffer), NULL);
}
}
// radio callback
void radioCallback(RF_Handle h, RF_CmdHandle ch, RF_EventMask e)
{
if (e & RF_EventRxEntryDone)
{
memcpy(rxPacket, (uint8_t *)¤tDataEntry->data,
(*(uint8_t *)(&(currentDataEntry->data))) + NUM_APPENDED_BYTES);
RFQueue_nextEntry();
// I added following, it helped but only a bit
if (device.isUartRead)
{
return;
}
processData();// processing the received data
}
}
我猜这是由于 UART 输入缓冲区已满而导致器件复位(此时可能正在执行闪存擦除/写入)、但我不确定。 无论如何、在我处理当前 UART 数据之前、我应该如何轻松地避免将任何其他数据接收到 UART 输入缓冲器中?