Hello, I have a CC1312 connected to BeagleBone. BeagleBone sends command to the CC1312 via UART. Everything works fine, but in case of sending too much commands (in short time) which writes to flash of the CC1312, the CC1312 resets and in its flash are wrong data. It happens when CC1312 is on the radio receiving. Unfortunately I cannot you send the whole program, but it looks like following:
// 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 } }
I guess it happens due to the uart input buffer is full and it causes reset of device (at that time probably a flash erase/write is performing) but I am not sure. Anyway how should I easily avoid to receive any other data to uart input buffer till I process the current uart data?