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

UART AND FSTORAGE IS NOT WORKING TOGETHER

Hello ALL,

I have been using UART module and fstorage module in an application. I've been sending a bin file from PC to NRF52 using UART but when I tried to save it using fstorage the module event handler cause the UART error. In uart error I am just setting a flag. In the main loop, I am counting the number of bytes and after 1kB of data, I am calling fstorage fstore function. but as soon as I call the function the uart module gives the error. The solution that I have done is that I am calling fstore,  and after that I wait for a flag to set(blocking the code) that I am setting in the fstorage event handler and once that is completed then I continue the uart communication but obviously, this is not a clean solution. One more thing to add here is that after doing this way I cannot increase the baud rate above 38400. If I go beyond this baud rate I got the uart error immediately even I don't run the fstoarge module at all. The error mask is NRF_UART_ERROR_PARITY_MASK. Note that easydma is true for UART and hardware flow control is also true. I want that initiate the fstorge erase process, get the uart data in the mean time, then call the fstore function to store the received data in the background while continue receiving uart communication. Can you help me with that?

Thank you to the whole community.

Parents
  • Hi,

    Which UART module are you using? If you are using app_uart, this will only receive a single byte for each transfer, before a new interrupt will happen. If you are writing to flash, the UART might not get enough CPU time to handle the interrupts/events. Are you sure that it is a parity error you get and not a overrun error? Can you post the code you are using?

    Best regards,
    Jørgen

  • Hello Jorgen,

    Thank you for your reply,

    I am using nrf driver for the uart and instance is UART0_INSTANCE_INDEX. I am using this command to get the error code in the uart_error case in the event handler. 

    NRF_LOG_INFO("UART ERROR MASK %i\r\n",  ((nrf_drv_uart_event_t *)p_event)->data.error.error_mask); and it shows the value 1 in the logger window. Moreover I am just changing a value of integer in the uart event interrupt and do all ther related changes in the while(1). You said the cpu are not getting enough time for the uart interrupt/events. First I am transferring data byte by byte and not using brust mode. 2nd How the low priority event (fstorage with priority 0xFE) can ca cause the error for higher priority event(uart with default priorirty which is 7). One more thing if the cpu is not getting time then increasing the uart speed would be benificial and should work.
Reply
  • Hello Jorgen,

    Thank you for your reply,

    I am using nrf driver for the uart and instance is UART0_INSTANCE_INDEX. I am using this command to get the error code in the uart_error case in the event handler. 

    NRF_LOG_INFO("UART ERROR MASK %i\r\n",  ((nrf_drv_uart_event_t *)p_event)->data.error.error_mask); and it shows the value 1 in the logger window. Moreover I am just changing a value of integer in the uart event interrupt and do all ther related changes in the while(1). You said the cpu are not getting enough time for the uart interrupt/events. First I am transferring data byte by byte and not using brust mode. 2nd How the low priority event (fstorage with priority 0xFE) can ca cause the error for higher priority event(uart with default priorirty which is 7). One more thing if the cpu is not getting time then increasing the uart speed would be benificial and should work.
Children
No Data
Related