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

  • The error reported corresponds to the value in the ERRORSRC register in the UART peripheral. A value of 1 indicates that bit A is set, i.e. a OVERRUN error.

    If you are using UARTE peripheral (with EasyDMA support), you can fill a full buffer (up to 255 bytes) in the background, without the CPU needing to handle interrupts for each byte transferred. This would allow you to receive data while writing to flash. As stated in the NVMC documentation: "The CPU is halted while the NVMC is writing to the Flash."

    I'm not sure where you got the fstorage priority of 0xFE from, but the nRF52832 only have 3 priority bits, allowing for 8 priority levels (0-7 - 7 being the lowest priority). Anyways, the priority sould not matter, since the CPU is halted during flash write. Increasing the baudrate of the UART peripheral will only make things worse, as this will generate more interrupts that the CPU is not able to service during flash write.

    Using HW flow control should solve this issue, but this requires the sending side to respect these signals.

  • I am using UARTE but I am receiving data byte by byte. If I increase the baud rate then even I don't use any function related to fstorage the uart error occurs. SO I recieve the uart error on very first transaction. One more thing to add here is that even the HW flow control using RTS/CTS is on.

    The priority that is was talking about here is the snippet

    FS_REGISTER_CFG(fs_config_t fs_config) =
    		{
    			  .callback  = fs_evt_handler, // Function for event callbacks.
    				.num_pages = NUM_PAGES,      // Number of physical flash pages required.
    				.priority  = 0xFE            // Priority for flash usage.
    		};

    Also can you please tell me if the fstorage also use NVMC ? I mean even if I am writing using fstorage the CPU is halted during the process?

  • From what device do you transmit the bytes to the nRF? If this device is not configured to also use HWFC, it will not prevent overrun errors on the nRF.

    The priority field in fs_config_t is not related to the interrupt priority for the flash write, this is from the documentation:

    The priority with which fstorage should assign flash pages to this application, with respect to other applications. Applications with higher priority will be assigned flash pages with a higher memory address. The highest priority is reserved. Must be unique among configurations. 

    All flash write/erase operations eventually go through the NVMC peripheral, the fstorage library is just a top layer above this.

Reply
  • From what device do you transmit the bytes to the nRF? If this device is not configured to also use HWFC, it will not prevent overrun errors on the nRF.

    The priority field in fs_config_t is not related to the interrupt priority for the flash write, this is from the documentation:

    The priority with which fstorage should assign flash pages to this application, with respect to other applications. Applications with higher priority will be assigned flash pages with a higher memory address. The highest priority is reserved. Must be unique among configurations. 

    All flash write/erase operations eventually go through the NVMC peripheral, the fstorage library is just a top layer above this.

Children
No Data
Related