Hello,
I’m using nRF51-DK with SDK 12.3 with softdevice S130 (BLE is advertising). I would like to talk with a serial device that starts up with no HW flow control and later switches to HW flow control, after receiving a specific command. I’m using APP_UART with the following code, but:
- The UART always displays an overrun error and it’s not able to receive any single byte either before or after the device turns on HW flow control.
- The UART correctly transmits commands to the device (I’m actually able to transmit the command enabling HW flow control of the device).
// UART interrupt handler function
void uart_handle(app_uart_evt_t * p_event)
{
//Error processing
if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR){
if(NRF_UART0->ERRORSRC==1) NRF_UART0->ERRORSRC=1;
uint8_t readbyte;
for(uint32_t i = 0; i < 6; i++) app_uart_get(&readbyte);
app_uart_flush();}
else if (p_event->evt_type == APP_UART_FIFO_ERROR) APP_ERROR_HANDLER(p_event->data.error_code);
//Processing of received byte
if (p_event->evt_type == APP_UART_DATA_READY){
uint8_t readbyte;
while(app_uart_get(&readbyte)==NRF_SUCCESS){
...PROCESSING...}}
}
main(){
...
// Initializes UART
const app_uart_comm_params_t comm_params = {RX_PIN_NUMBER,TX_PIN_NUMBER,RTS_PIN_NUMBER,CTS_PIN_NUMBER,APP_UART_FLOW_CONTROL_ENABLED,false,UART_BAUDRATE_BAUDRATE_Baud115200};
APP_UART_FIFO_INIT(&comm_params,256,256,uart_handle,APP_IRQ_PRIORITY_LOWEST,err_code);
APP_ERROR_CHECK(err_code);
...
for (;;){...}
}
I tried:
- To clear the error as displayed in the above code;
- To comment out the IF blocks pertaining to APP_UART_COMMUNICATION_ERROR and APP_UART_FIFO_ERROR in the interrupt handler (leaving only the IF block if (p_event->evt_type == APP_UART_DATA_READY);
- To move all processing into main, so that only the line if (p_event->evt_type == APP_UART_DATA_READY) SerialRX_EventFlag=true is left in the interrupt handler;
- To start APP_UART with either HW flow control turned on or off.
In all cases, the result is the same: the code never completes successfully the app_uart_get(&readbyte) command.
What am I missing? Thank you for any help!