This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NRF51822 RS485 uart tranfer complete event

I'm using RS485 driver on NRF51822 uart. I started software developing with ble_uart exapmle. RS485 as always has direction control inputs. Before data transfer to uart I have to switch driver on transmitting, after transfer complete over uart I have to switch driver on receiving. I can't find transfer complete event. At this time I'm using for experiments APP_UART_TX_EMPTY, but it's not what I need. APP_UART_TX_EMPTY event occurs when FIFO is empty, but last byte transmission is not completed.

Parents
  • Hi, backtracking the driver in code I find that the APP_UART_TX_EMPTY in nRF5 SDK v11 is set by the NRF_UART_EVENT_TXDRDY event, which is set after the last byte is transmitted over UART. This is also inline with the figure 68 in the nRF51 Reference Manual v3.0. Are you sure that the APP_UART_TX_EMPTY is set before the last byte is transmitted?

    Edit: After further looking at the code, I think your observation is right. There is most likely a race condition, where the APP_UART_TX_EMPTY can be set when second to last byte is sent. The reason for this is most likely because the UART0_IRQHandler() can't be processed before the nus_data_handler() is completed. I see no quick fix other than to add a dummy byte after each transmission, or possible try to increase the priority level of the UART to high by APP_UART_FIFO_INIT().

Reply
  • Hi, backtracking the driver in code I find that the APP_UART_TX_EMPTY in nRF5 SDK v11 is set by the NRF_UART_EVENT_TXDRDY event, which is set after the last byte is transmitted over UART. This is also inline with the figure 68 in the nRF51 Reference Manual v3.0. Are you sure that the APP_UART_TX_EMPTY is set before the last byte is transmitted?

    Edit: After further looking at the code, I think your observation is right. There is most likely a race condition, where the APP_UART_TX_EMPTY can be set when second to last byte is sent. The reason for this is most likely because the UART0_IRQHandler() can't be processed before the nus_data_handler() is completed. I see no quick fix other than to add a dummy byte after each transmission, or possible try to increase the priority level of the UART to high by APP_UART_FIFO_INIT().

Children
No Data
Related