2021-05-12 09:00 AM
Hi everyone,
I am working on project involving Raspberry Pi, STM32, FPGA and MIPI Cameras. The goal is to capture images and store temporarily data from those cameras in the FPGA.
The RPI (Master) has to communicate with the STM32 (Slave) via an SPI protocol.
The STM32 has to communicate with the FPGA via an SPI Protocol too. In this case, the STM32 is the Master and the FPGA is the Slave.
The only way to communicate with the cameras is via an I2C Protocol. So, the STM32 needs to communicate with them in I2C.
I hope you undertand what I explained. The STM32 acts like an SPI to I2C "Bridge". So first, I would like to know if it is possible to make these two protocols coexist in the same STM32. If this is the case, I would like to know how I can do that in terms of software.
Thank you for your time.
Regards
2021-05-12 04:54 PM
Moving data between multiple serial interfaces is the staple of microcontroller programming.
Develop a protocol on the SPI between STM32 and RPi, which uses packetization/framing, checksumming, handshake; so that data for FPGA/SPI and I2C can be safely encapsulated. Handle the raw data in interrupts, later on you can proceed to use DMA to reduce processor load. Decapsulate data received from SPI and move them into FIFOs which are subsequently transmitted towards FPGA/SPI and I2C respectively, in interrupt-driven routines of those interfaces. Do the same with the data in the opposite direction.
JW
2021-05-15 05:45 AM
Hi, Thank you very much for your help.
But I'm not sure to understand what you've explained. Do you have any tips about how to do it or examples?
I am new in the STM32/Microcontroller world.
Plus, I am looking for an STM32 which is Low Power and have a maximum clock frequency of 500 MHz at least. Any advice about which one to use?
Thank you for your time.
2021-05-16 01:54 AM
You design communication protocols based on the particular requirements of your application. That's why there are no examples around - there are universal protocols like TCP/IP (or, just the IP part of it), but they exchange the "universal" for being generally inefficient for a given particular task. Fits all means fits none.
You should start with RPi/SPI communicating with STM32, use interrupt-driven communication in STM32, you will find examples for that in Cube. Move blocks of data to and from the RAM first. Then add communication to the FPGA, make a transparent bridge, with buffering the data. Try then adding a header to the data (one byte with some particular value, plus perhaps a couple of bytes indicating number of data bytes to follow), so that they can be distinguished that they go into/from the FPGA. Then add the I2C part.
500MHz and low consumption are mutually exclusive. The STM32H7 family is the highest performing amongst the STM32. I don't know how did you arrive at that 500MHz, but if you are sure you need that high operation frequency, you probably have to look into different solutions instead of using a microcontroller.
Maybe you could do things slightly differently - connect RPi to FPGA directly, make the "bridge" out of the FPGA, which would forward only data for I2C to a microcontroller which would then relay them through I2C. In that way, the bulk of the communication would go where it belongs - into the FPGA - and them microcontroller would handle the relatively algorithmically complex I2C. Any of the STM32 would then be able to cope with this, and it would be also a low-consumption solution in this part.
JW
2021-05-17 07:05 AM
Since the transfert speed of MIPI Cameras is around 900 Mbps and the FPGA Clock is around 600 MHz, I thought it would be better to use a microcontroller (an STM32 for example) with approximatively the same frequency. This µc will then store, definitely, the data in an SD Card. But with your previous comment, I might be wrong. You said I have to look into different solutions instead of using a microcontroller.
So would you advise me to use a microprocessor instead?
You gave me good ideas. Thank you very much for your help.
Regards
2021-05-17 08:21 AM
> Since the transfert speed of MIPI Cameras is around 900 Mbps and the FPGA Clock is around 600 MHz, I thought it would be better to use a microcontroller
If an FPGA can't keep up with a data streem, any microcontroller or microprocessor won't either.
JW