Uncategorized

SPI pin clashing problem

Asked 
Active today
Viewed 13 times
0

I’ve done some research, but not probably not enough, as I’m still confused some.

First of all, I’ve got a Pi rev 1 Model B (with the 26 pin connector) and two devices: The Waveshare AD/DA board and e-ink display HAT form factors. They share the MOSI and SCLK pins, but the AD/DA board appears to use gpio pins 15 and 16 for CS0 and CS1, whereas the display uses spi pin 24. If I understand correctly, should I be able to get both devices to work as long as I get the timing on the chip selects right? I saw one post that specifically mentioned not using pin 24 (CEO) when trying to get more than 2 devices working together. Is there a reason for that???

Lastly, the devices also share pin 11, but I have a free gpio, pin 7. The next question is, via wiringPi (or something else?), can I reassign that pin for the display while not confusing the AD/DA board? I can easily physically wire that (pin 7) to the pin position that the HAT expects it, but I’m not sure if assigning a different pin via software is universal or can be done for a particular instance (ie display and not the ad/da board).

I know I’ve got to read up more on this, but it’d be nice to know if I’m trying something impossible.

Thanks

 New contributor
  • Hi @klatk, Welcome. Let me see. Yes, the standard method is to use CE0, CE1, and CE2 to enable/select chips and devices. But you can also forget the standard CE0~2 and have your own CE3, 4, 5, … using GPIO pins. Actually you can also use GPIO expanders such a MCP23017 GPIO pins as CE pins to select SPI devices. (Yes, I did it since my Arduino Decimilla days.). Coming back to SPI LCDs, there are some problems: (1) If the LCD driver is hard coded to use SPI0, then you need to modify the driver or write your own driver. (2) / to continue, … – tlfong01 8 hours ago   
  • (2) The LCD module’s hardware CS0 signal wire might be hardwired to ground (ie, chip always selected), and it is difficult to disconnect the CE line and extract it out to your CS0, … CSn lines. Some small LCDs, eg ST7789 based, are not that difficult, and some actually have the CS line in the input connector for hackers to use: (3) raspberrypi.stackexchange.com/questions/104846/…, (4) raspberrypi.org/forums/viewtopic.php?f=91&t=233311#p1429189. – tlfong01 8 hours ago   
  • And messing around the SPI LCD driver/kernel is for sure not for the faint of heart newbies. For the over ambitious ninjas, I would recommend to start with the very popular ILI9341 based LCD modules: (1) raspberrypi.stackexchange.com/questions/98549/… (2) raspberrypi.stackexchange.com/questions/104600/… (3) raspberrypi.stackexchange.com/questions/99134/…. Good luck and cheers! 🙂 – tlfong01 8 hours ago    
  • For newbies wanting to learn how to write a LCD driver the easiest way, I would recommend the Piromoni’s ST7789 LCD module, for which you can use their Python library to control the LCD. Actually the python functions used in their library are not that difficult, I mean by ninja standards: (1) “How to connect ST7789 LCD to Raspberry Pi: raspberrypi.stackexchange.com/questions/105364/…. Note: there is no answer in the post, but read my comments in the CHAT record. – tlfong01 7 hours ago    
  • 2
    @tlfong01 why are you filling up the comments about LCDs? That has nothing to do with the question. Perhaps you could make one comment and then wait for a response from the questioner before making another? – joan 45 mins ago
  • Take a look in /boot/overlays/README there are supplied overlays to enable more than two SPI interfaces. You’re right the problem is CS/CE pins. – Dougie 36 mins ago
  • @joan, Ah my apologies for not reading the OP’s question carefully. The OP asks about using two SPI devices, one DA/AD board, and the other eInk Display, using different or same CS0, 1, and another GPIO pin (as CS2, I am not sure, because I did not read the eLink Display spec. My answer uses the wrong example of using two identical LCD Displays. Luckily my wrong example of two generic LCDs, though not answering the question’s exact, specific requirement, but do answer the general requirement, which the OP’s specific requirement also satisfies. / to continue, … – tlfong01 11 mins ago   
  • Actually when I was answering, I thought about using an example simple SPI ADC MCP3208, instead of the OP’s more complicated AD/DA which the OP does not give any link. I thought about using two identical MCP3208, which has no address decode pins and only one CS pin. So my answer of two LCDs actually apply to general case of two ADCs, and also to general case of same of different devices with CS pin clashes. I must confess I have not organized and explained in detail my not very appropriate answer. My apologies causing everybody’s confusion. Perhaps the OP can comment and me make changes. – tlfong01 23 secs ago   Edit   

1

You can use any spare GPIO as a chip select as far as the Linux kernel SPI driver on the Pi is concerned.

Whether a HAT or other device can use that GPIO as a chip select depends on several things.

  • Is the GPIO used by the HAT or other device hard wired by the HAT or other device
  • Have you got access to the HAT or other device software to make the needed change

You will need to investigate on a case by case basis.

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: