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

Sending via Uart

Hi, I need to be able to communicate between two boards via UART. I had a look at the example from Ole provided here: devzone.nordicsemi.com/.../ as well as other references here on the Dev zone and code examples in the SDK.

I am running the PCA10001 and also tested it on the N5 chip from Dynastream. The chip is using SDK v6.1 and SD s110 v7.

I need to use hardware flowcontrol and to simplify things I am currently testing it against a PC. Using Ole's code and importing it into a clean IAR project and running it on the PCA10001 the software goes into the app_error_handler after trying to run app_uart_put for the second time, the reason is a NRF_ERROR_NO_MEM error as the current state is not UART_READY. This happens for both HFC on/off.

uint8_t len = strlen((char *) str);
for (uint8_t i = 0; i < len; i++)
{
    APP_ERROR_CHECK(app_uart_put(str[i]));
}

Here is a copy of the app_uart_put function from app_uart.c

uint32_t app_uart_put(uint8_t byte){
    uint32_t err_code = NRF_SUCCESS;

    if (m_current_state != UART_READY)
    {
      err_code = NRF_ERROR_NO_MEM;
    }
    else
    {
      m_tx_byte = byte;
      on_uart_event(ON_UART_PUT);
    }

    return err_code;
}

By adding something like this into the app_uart_put function the problem is solved but I would rather not want to change the SDK. Could also put a fixed delay into the send function but that is an even worse hack in my opinion.

while (m_current_state != UART_READY)
{
    // Wait until uart is ready again
}

Am I using the framework incorrectly or can someone suggest a cleaner solution for this issue, the best thing would be to be able to use the app_uart library from the SDK without modification for future releases.

Thanks!

Parents
  • Yes, I think I may have made it even more confusing with the 6 byte buffer comment. That's a receiver buffer. If you switch the uart driver you use there's a different uart driver implementation with built in fifo. So if you go in the source folder and app_common and use the driver name "app_uart_fifo.c" you'll find the exact same function calls as you are using, but implemented with fifo to buffer both tx and rx UART. Then you should be able to write to the uart as you are trying to do.

Reply
  • Yes, I think I may have made it even more confusing with the 6 byte buffer comment. That's a receiver buffer. If you switch the uart driver you use there's a different uart driver implementation with built in fifo. So if you go in the source folder and app_common and use the driver name "app_uart_fifo.c" you'll find the exact same function calls as you are using, but implemented with fifo to buffer both tx and rx UART. Then you should be able to write to the uart as you are trying to do.

Children
No Data
Related