How can I read large amounts of data through an MCU configured as an SPI slave? - Page 1
Forum section: electronics / projects

author: peckett
author_rank: Newbie
timestamp: March 29, 2023, 11:08:14 pm
content: Hello,I am trying to send 20,000KB of data through some LED display panels.I am using SPI to send the data from the MCU and it is converted into RS485 so it can transmit the data through the length of the sign which is roughly about 8 meters.As I need to detect any errors in the sign the data is returned through each LED panel and back to the MCU.Currently only the data is returned and this limits the speed I can drive the sign to about 3MHz.As only the MOSI signal is being returned to the MCU the data is out of sync with the SCKAfter reading the application note from TI attached to this email it says by returning the clock signal and setting up the MCU as a slave the MOSI and SCK will still be in sync.I have tried this method with some development boards (teensy4.1 and ESP32) and have successfully sent data between a master and a slave at speeds up to 30MHz.The only issue is I was limited to the amount of data I was able to receive.I was using a few libraries for the slavehttps://github.com/hideakitai/ESP32SPISlaveandhttps://github.com/tonton81/SPISlave_T4and they are both limited to only receive about 32 bytes of data.Is there an easy way for me to read up to 20,000 bytes of data with any MCU configured as an SPI slave or is there a better solution to what I am trying to achieve?I have also attached a drawing for an example.ThanksCraig

author: Rainwater
author_rank: Regular Contributor
timestamp: March 30, 2023, 02:15:46 am
content: Esp32 referencehttps://www.espressif.com/sites/default/files/documentation/esp32_technical_reference_manual_en.pdfTo transmit data that distance the SPI protocol is not going to be practical.The esp32 has peripherals, which will help solve your problem.For instance, with 2 esp32 units, you can transmit the data over 2.4GHz wifi 8 meters very easily. You can even use encryption to secure the connection.Transfer rates around 20MBit/s TCP over IPv4.Bluetooth is another option.If you are wanting a wired connection, rs485 on the esp32 can transmit up to 4.5MBit/s at those distances, given the proper cable is used, and the default build settings are tweeked.Without modifing the compile setting you can expect 921600 bps.By using DMA and an isr call, you can setup your data in ram and send it, only using core time when the isr swaps out the pointers for dma. The same applies to receiving data.See 13.1 of the above linked document.13. UART Controllers.Here is a great article about how UART's workhttps://www.analog.com/en/analog-dialogue/articles/uart-a-hardware-communication-protocol.html

author: peckett
author_rank: Newbie
timestamp: March 30, 2023, 08:17:25 pm
content: sorry the data I need to send is 20kb*.the data also has to be sent to each display panel which could be as much as 126 per sign.if I used Wi-Fi I would have to have an ESP32 on each display panel... is that a bit too much?I guess the price would actually be cheaper than an RS485 receiver or similar, not sure how it would do for EMC though?we are currently using ribbon cable and am a bit limited for time so didn't want to change too much.default build settings are tweaked?I was thinking to maybe use LVDS receivers and drivers on each panel so I can boost the signal which should give me both the speed and distance needed.But I still need a way to set an MCU up as a slave.I haven't worked with DMA before but will do some research.thanks for your reply.