Potential Pico Pin Conflict

I’m building a project that uses a LoRa wan module.

And a 4 digit LED display.

It appears to me the there is some overlap with the pin assignments.
The Display uses GPIO 9, 10, and 11
The LoRa module uses GPIO 2, 3, 10, 11, 12, 15, 20, 26
Am I stuck with this approach or can the pins be reassigned some how?
If Necessary is there an alternate display I could use?
Thanks for any assistance
David

1 Like

If you are connecting then to a Raspberry Pi Pico …
The display uses SPI1 (pins 8,9,10,11).
You could change the display software to use SPI0, (pins 4,5,6,7).

Then Mount the display separately and wire the 5 pins the display needs.
But, it takes away the ability to nicely place them on top of each other.

Regards
Jim

EDIT: ‘pins’ should be ‘GPIO’ above.

Display Driver code.

from machine import Pin,SPI,PWM
import framebuf
import time

MOSI = 11
SCK = 10    
RCLK = 9

Change to Display Driver code.

from machine import Pin,SPI,PWM
import framebuf
import time

MOSI = 7
SCK = 6    
RCLK = 5
2 Likes

Hi Jim,
That makes sense. I kind of reached the same conclusion while sleeping on it :cowboy_hat_face:
I was hoping for some magic solution.
I’ll post again if I come up with anything interesting
Thanks for
Responding
David

1 Like

Hi Jim,
It seems I’m making another newbie mistake.
Looking at the specs for the LED module and the LoRa Module it seems that the only conflict is GP10 and GP11 which is used by both devices. I have my pico modules mounted on a PICO OMNI Bus.


I have removed the two pins GP10 and GP11 from the OMNI Bus Board under the LED Display and then run two jumper wires from the those two sockets under the LED module across to the unused pins GP6 and GP7 on the LoRa module this is just to save me trying to solder to the top of the Pico.

I changed my code to match the new pin assignment.

#MOSI = 11  # Conflict with LORA Module.  Pin moved to GP7
#SCK = 10   # Conflict with LORA Module. Pin moved to GP6
MOSI = 7
SCK = 6

Now when I execute the code I receive the following error code

File "<stdin>", line 45, in __init__
ValueError: bad SCK pin

This is line 45

        self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None)

I removed the LoRa Module from the bus and the error remains so it’s not conflicting with that module.

I notice in your message above you have grouped pins 8 9 10 11 into SPI0 and pins 4 5 6 7 into SPI0. The LED module spec. doesn’t seem to mention GP8 at all. Do I need to use these pins in a group?
Below is the code I modified from the example code supplied with the LED Module.
Any suggestions what I should try next?
Thanks David

from machine import Pin,SPI,PWM
import framebuf
import time

#MOSI = 11  # Conflict with LORA Module.  Pin moved to GP7
#SCK = 10   # Conflict with LORA Module. Pin moved to GP6
MOSI = 7
SCK = 6

RCLK = 9

THOUSANDS   = 0xFE
HUNDREDS  = 0xFD
TENS      = 0xFB
UNITS     = 0xF7
Dot       = 0x80

SEG8Code = [
    0x3F, # 0
    0x06, # 1
    0x5B, # 2
    0x4F, # 3
    0x66, # 4
    0x6D, # 5
    0x7D, # 6
    0x07, # 7
    0x7F, # 8
    0x6F, # 9
    0x77, # A (10)
    0x7C, # b (11)
    0x39, # C (12)
    0x5E, # d (13)
    0x79, # E (14)
    0x71, # F (15)
    0x00, # Blank (16)
    0x00, # Decimal Point (17)
    0x64  # Minus Sign (18)
    ] 
class LED_8SEG():
    def __init__(self):
        self.rclk = Pin(RCLK,Pin.OUT)
        self.rclk(1)
        self.spi = SPI(1)
        self.spi = SPI(1,1000_000)
        self.spi = SPI(1,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None)
        self.SEG8=SEG8Code
    '''
    function: Send Command
    parameter: 
        Num: bit select
        Seg:segment select       
    Info:The data transfer
    '''
    def write_cmd(self, Num, Seg):    
        self.rclk(1)
        self.spi.write(bytearray([Num]))
        self.spi.write(bytearray([Seg]))
        self.rclk(0)
        time.sleep(0.002)
        self.rclk(1)
        
def decodeString(displayString):
    displayList=[]
    for character in displayString:
        if character == '0': code=0     
        if character == '1': code=1
        if character == '2': code=2     
        if character == '3': code=3     
        if character == '4': code=4     
        if character == '5': code=5     
        if character == '6': code=6    
        if character == '7': code=7     
        if character == '8': code=8     
        if character == '9': code=9     
        if character == 'A' or character == 'a' : code=10     
        if character == 'B' or character == 'b' : code=11     
        if character == 'C' or character == 'c' : code=12     
        if character == 'D' or character == 'd' : code=13     
        if character == 'E' or character == 'e' : code=14     
        if character == 'F' or character == 'f' : code=15     
        if character == ' ': code=16
        if character == '.': code=17
        if character == '-': code=18
        if code != 17: displayList.append(code)
    return displayList

def decimalPlace(displayString):
    currentPosition=4
    for character in displayString:
        if character == '.':
            break
        currentPosition=currentPosition -1
    return currentPosition
    
def displayLED(displayNumber,displayTimer):
    try:
        outputDisplay(displayNumber,displayTimer)
    except:
        print("Error")
        LED=LED_8SEG()
        LED.write_cmd(THOUSANDS,LED.SEG8[14])    # Display E
        time.sleep(0.0005)
        
def outputDisplay(displayNumber,displayTimer):
    displayTimer = displayTimer* 110  # Convert timer to seconds
    displayString=str(displayNumber)

    # Left Pad with blanks
    noDecimal=displayString.replace('.','')    # Remove decimal point
    stringLength=len(noDecimal)
    if stringLength==3: displayString=' ' + displayString
    if stringLength==2: displayString='  ' + displayString
    if stringLength==1: displayString='   ' + displayString
    #print("displayString="+displayString)
    
    displayList= decodeString(displayString)
    decimalPosition=decimalPlace(displayString)
    
    LED=LED_8SEG()        
    while displayTimer > 0:
        time.sleep(0.0005)
        if decimalPosition == 0:
            LED.write_cmd(UNITS,LED.SEG8[displayList[3]]|Dot)
        else:
            LED.write_cmd(UNITS,LED.SEG8[displayList[3]])
        time.sleep(0.0005)
        if decimalPosition == 1:
            LED.write_cmd(TENS,LED.SEG8[displayList[2]]|Dot)
        else:
            LED.write_cmd(TENS,LED.SEG8[displayList[2]])
        time.sleep(0.0005)
        if decimalPosition == 2:
            LED.write_cmd(HUNDREDS,LED.SEG8[displayList[1]]|Dot)
        else:
            LED.write_cmd(HUNDREDS,LED.SEG8[displayList[1]])
        time.sleep(0.0005)
        if decimalPosition == 3:
            LED.write_cmd(THOUSANDS,LED.SEG8[displayList[0]]|Dot)
        else:
            LED.write_cmd(THOUSANDS,LED.SEG8[displayList[0]])
        time.sleep(0.0005)
        displayTimer = displayTimer-1
        
    # Once finished blank out the fist left most digit
    # as it's the only one that sticks
    LED.write_cmd(UNITS,LED.SEG8[16])
    time.sleep(0.0005)


# TEST
print("Debug 1: Start")
displayNumber = '12.47'
displayTimer = 20   # Display time in seconds (Aproximate)
displayLED(displayNumber,displayTimer)

1 Like

Below is the official pin out for the Pico from the Raspberry Pi corporation.
Oops I got pins confused with GPIO numbers. (comes from rushing to post, sorry)
Change ‘pins’ to GPIO.

SPI0 can be
pins (1,2,4,5) GPIO (0,1,2,3) or
pins (6,7,9,10) GPIO (4,5,6,7) or
pins (21,22,24,25) GPIO (16,17,18,19)
Your pic shows you figured that out.

But you will also need to wire GPIO 9 (Display) to GPIO 5 (Pico), it latches the data to the display.

Should be RCLK = 5

This would be used if the display sent data to the Pico, it doesn’t so its not needed. It would be labelled MISO if used. (master in slave out etc)

This is because the code is using SPI1. Change the following.

class LED_8SEG():
    def __init__(self):
        self.rclk = Pin(RCLK,Pin.OUT)
        self.rclk(0)
        self.spi = SPI(0)
        self.spi = SPI(0,1000_000)
        self.spi = SPI(0,10000_000,polarity=0, phase=0,sck=Pin(SCK),mosi=Pin(MOSI),miso=None)
        self.SEG8=SEG8Code

Regards
Jim

2 Likes

Jim,
All makes sense once you see it :slight_smile:
I added another variable named SPI_Channel = 0
Then applied it to all the places that set it to 1.
I’m assuming my terminology is correct to call this a channel?
The strange part is it now works without me changing the cabling from GP9 to GP5. I’m wondering if this is a convention and not an absolute requirement?
In any case it’s now working. I could have reached this conclusion eventually.
Thanks for explaining it and saving me the hours of pain pain :cowboy_hat_face:
Thanks
David
PS
This is device is to help monitor a free community BBQ provided to a country town and its tourists by The Lions Club.

1 Like

Yeah. Since posting I realised it’s not necessary to change this pin and I was about to edit my post.
It is only be used as a general purpose pin in the library and does not conflict with the LORA module.

Cheers
Jim

Excellent !!!

1 Like