SD Card and LoRa module on same SPI bus #12633
Replies: 2 comments 4 replies
-
This is puzzling because electrically an SPI peripheral should never hold the bus. The CS, SCK and TX pins are host outputs. The only pin that the peripheral can grab is RX, and it should never do so if CS is False, to allow bus sharing. I would examine the Lora driver (or put a meter/scope on the CS line) to make sure the driver is deasserting CS after a transmission. If it's not, maybe you can force it to by issuing |
Beta Was this translation helpful? Give feedback.
-
Hi, |
Beta Was this translation helpful? Give feedback.
-
Hi,
i am using an ESP32-S3-WROOM-1 with Micropython v1.20.0. I have a custom made PCB with a LoRa Module (AI-Thinker Ra-01H) and an SD card on the same SPI bus. The used pins are:
cs_lora=21
cs_sd=10
sck=12
mosi=11
miso=13
Both modules on their own work, however if I want to use both in the same code, I get some Errors.
I made some Testcode to illustrate the issue:
I used the uLoRa library (https://github.com/fantasticdonkey/uLoRa) and added the spi_init() and spi_deinit() functions:
In state 1 the message is sent properly, but communication with the sd card doesn't work. Output:
In state 2 everything works as expected, but it feels hacky.
I think the main issue is that in state 1 the LoRa library occupies the SPI bus and does not allow communication with the sd card. Is there a way to get the SPI object back from the SDCard function so I can hand it over to the LoRa library?
Thanks in advance and sorry for the long post.
Beta Was this translation helpful? Give feedback.
All reactions