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

Stream data (file) over UART from a device to nRF52832, then send it to a peripheral using I2C

Hello,

I have a peripheral that is connected to nRF52832 using I2C, in which I want to send some file to its memory. However, for sending this file, I need to stream it using UART for instance.

Question 1: How can I send a file without being entirely saved on nRF52832 flash memory?

Question 2: Is it possible to send a packet once received over I2C?

Thanks in advance.

Parents
  • I want to send some file

    Where is this "file" located?  That will determine how to access it,  and hot to send it.

    I need to stream it using UART for instance

    The nRF52 UART - like any other UART - neither knows nor cares anything about files: all it sees is bytes arriving.

    How can I send a file without being entirely saved on nRF52832 flash memory

    Send it in smaller chunks - aka "blocks" or "packets".

    You will need some sort of protocol for the nRF to tell the sender when it is ready for more data ...

    Is it possible to send a packet once received over I2C?

    Of course it is:  again, as far as the I2C is concerned, it's all just bytes - where those bytes originated is irrelevant.

Reply
  • I want to send some file

    Where is this "file" located?  That will determine how to access it,  and hot to send it.

    I need to stream it using UART for instance

    The nRF52 UART - like any other UART - neither knows nor cares anything about files: all it sees is bytes arriving.

    How can I send a file without being entirely saved on nRF52832 flash memory

    Send it in smaller chunks - aka "blocks" or "packets".

    You will need some sort of protocol for the nRF to tell the sender when it is ready for more data ...

    Is it possible to send a packet once received over I2C?

    Of course it is:  again, as far as the I2C is concerned, it's all just bytes - where those bytes originated is irrelevant.

Children
  • Thanks for your reply.

    Where is this "file" located?  That will determine how to access it,  and hot to send it.

    File is saved on my PC. 

    Send it in smaller chunks - aka "blocks" or "packets".

    You will need some sort of protocol for the nRF to tell the sender when it is ready for more data ...

    How? Is there an example in the SDK to follow or use?

  • How?

    There is really nothing specific to nRF in this part - you have exactly the same requirement for sending any data to any UART.

    It's going to depend on your application.

    Maybe you could simply use the UART flow control?

  • Thank you for the fast response.

    Maybe you could simply use the UART flow control?

    Where can I find it?

    Also, to simplify the procedure, I will break down the activities:

    1- How to send file over UART?

    2- How to break the file into chunks according to my application requirement?

    3- How to send these received data to my I2C connected peripheral before receiving new data packet?

  • Hi,

    Bakry said:
    Maybe you could simply use the UART flow control?

    Where can I find it?

    The UART(E) peripheral has a HW Flow Control feature. This is enabled in the CONFIG register (or through the driver in the application). Note that this is handled by HW, and may not be very flexible for this task. It may be simpler to send a request packet back over UART to the file transmitting device when you are ready to receive a new packet.  

    Bakry said:

    1- How to send file over UART?

    2- How to break the file into chunks according to my application requirement?

    Depends on what is supported by the device where the file is stored, but you could use Python with PySerial. See the code suggested in this post.

    Bakry said:
    3- How to send these received data to my I2C connected peripheral before receiving new data packet?

    On the nRF-side, I would recommend that you configure either the UART driver (nrf_drv_uart/nrfx_uarte), or the libUARTE library for this task, instead of using the old app_uart library. The driver and libUART support reception of packets up to 255 bytes in a single buffer on nRF52832. app_uart only receives one byte at a time (and optionally stores this into a FIFO for later processing). Receiving larger chunks will reduce the work for the CPU, and reduce overall current consumption. 

    One the UART buffer is filled with a full packet, the event handler is called with information about the received packet. In this handler, you can setup a TWI transfer to send the received chunk to the I2C device, and request a new chunk on the UART lines.

    Best regards,
    Jørgen

Related