D52 in use with multiple SPI devices

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
vhavard
 
Posts: 20
Joined: Mon May 16, 2022 5:25 pm

D52 in use with multiple SPI devices

Post by vhavard »

Trying to use two SPI devices from a Metro M4 Grand Central. Device1 is the AirLift WiFi FeatherWing Co-Processor, Device 2 is the HX8357D TFT.

I have never tried to use 2 SPI devices at the same time before, but I was unable to get the 8-bit interface working correctly for the TFT.

I have connected both devices' MISO, MOSI, and SCK pins to the same row on a breadboard and separated out the CS and C/D line for each onto their own pins on the metro.

Metro M4 MISO (aka D50) -> Breadboard -> Airlift MISO
\-> HX8357D MISO

Metro M4 MOSI (aka D51) -> Breadboard -> Airlift MOSI
\-> HX8357D MOSI

Metro M4 SCK (aka D52)-> Breadboard -> Airlift SCK
\-> HX8357D SCK

Metro M4 D14 -> Airlift ESPCS
Metro M4 D15 -> Airlift ESPRST
Metro M4 D16 -> Airlift ESPBUSY

Metro M4 D9 -> HX8357D CS
Metro M4 D10 -> HX8357D D/C

When I run the simpletest python script the output shows "ValueError: D52 in use"

All the docs I read indicate that multiple devices should be able to share the same SCK, MISO, and MOSI so long as they have different CS pins.

Am I reading this wrong or am I doing something wrong? Any help is appreciated.

User avatar
neradoc
 
Posts: 542
Joined: Wed Apr 27, 2016 2:38 pm

Re: D52 in use with multiple SPI devices

Post by neradoc »

Yes, they can share the same SPI bus, if you init it only once and share it between both drivers.
Additionally displays setup with displayio are retained between reloads along with their bus.
Thats why you need to call displayio.release_displays() before creating the SPI object.

If your issue is neither of those, you can show your code here.

User avatar
vhavard
 
Posts: 20
Joined: Mon May 16, 2022 5:25 pm

Re: D52 in use with multiple SPI devices

Post by vhavard »

This worked. Just have to define it once in main.py and import it wherever else it needs to be used. Thanks for the tip.

Locked
Please be positive and constructive with your questions and comments.

Return to “Metro, Metro Express, and Grand Central Boards”