Use multiple SPIs on RPI (Raspberry Pi) 4B?

조회 수: 5 (최근 30일)
Arish Yaseen
Arish Yaseen 2022년 4월 14일
댓글: Arish Yaseen 2022년 4월 14일
I am using a RPI 4B board to connect and use multiple SPI devices simultaneously. The RPI 4B board provides upto 6 SPI connections.
My question is that is it possible to switch between SPIs (for eg select SPI1, SPI2...) using MATLAB® Support Package for Raspberry Pi™?
I have already installed the "mathworks_raspbian_R21.1.0" image on the RPI and successfully booted the device. I am also able to connect to the device on the IP address. However, it only shows two CE {CE0, CE1} which I assume are only for SPI0 and there is no option to select SPI1 or others.
P.S. When connected to my RPI, the boardname is detected as "Raspberry Pi 2 Model B" instead of "Raspberry Pi 4 Model B", which I also don't understand why?

답변 (1개)

Sylvain
Sylvain 2022년 4월 14일
편집: Sylvain 2022년 4월 14일
Hi Arish,
I faced the same issue and found that the Raspberry Pi is limited with GPIOs. Hence I am using microcontrollers to handle the SPI buses and bridge back to the Rpi using i2c. This works like a charm but require you to program microcontrollers.
An alternative would be to use the GPIO as CS lines, but you won't have a lot of them available. You could use a multiplexer for the SPI0 and SPI1 using an i2c intergrated circuit.
I learned the hard way the limitation of the RPi, PWM frequency capped to 8 kHz, only few GPIOs, and timing might be an issue (models running below 0.1s time step require some care).
No idea about why Rpi 4 is detected as Rpi 2, I just figured out I have the same issue:
  댓글 수: 1
Arish Yaseen
Arish Yaseen 2022년 4월 14일
Hey Sylvain,
Thanks alot for the response.
I understand the logic behind your approach but if we have atleast 4 SPI lines available at the same time of the RPI 4 board, it would have been easier to just switch between them rather than using a single line and an additional multiplexer.
My question is how can we select our RPI to communicate on SPI1 or SPIx rather than SPI0 (which is by default)?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for Raspberry Pi Hardware에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by