M1LKYWVY
Posts: 15
Joined: Fri Jan 04, 2019 2:02 pm

GPIO Alternate Functions

Thu May 16, 2019 6:50 pm

Hi all!

I faced strange behavior of alternate pins functions.
So, I have enabled SPI.
config.txt

Code: Select all

dtparam=spi=on
set it up to alternative pins

Code: Select all

gpio=35-39=a0
also tested this setting up

Code: Select all

sudo raspi-gpio set 35 a0
sudo raspi-gpio set 36 a0
sudo raspi-gpio set 37 a0
sudo raspi-gpio set 38 a0
sudo raspi-gpio set 39 a0
and this

Code: Select all

gpio -g mode 36 alt5
gpio -g mode 37 alt5
gpio -g mode 38 alt5
gpio -g mode 39 alt5

Tried to work with it through spidev python module (pip install spidev).

Everything good except one. CS always high. CS1 and CS0 (I am using only CS0).



I tested with simple python code listed below

Code: Select all

    spi = spi.SpiDev()
    spi.open(0, 0)
    spi.max_speed_hz = 976000
    spi.mode = 0b00

    while True:
        result = spi.xfer2([0x44, 0xBB], 976000, 80)
After that I used it with moving to alternate functions.

Everything fine.


So, as i understand both CS did not move to alt functions.Is this problem with my CM3 or may be with main board?

Thanks in advance for your replies
Attachments
waVExUINIxA-min-min.jpg
waVExUINIxA-min-min.jpg (78.24 KiB) Viewed 372 times
ILwre5a7wwU-min.jpg
ILwre5a7wwU-min.jpg (61.5 KiB) Viewed 372 times

User avatar
joan
Posts: 14073
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GPIO Alternate Functions

Thu May 16, 2019 8:11 pm

I'm not sure what you are worried about. It is not clear if CS is being toggled properly or not.

As far as the mode it will be set to mode OUTPUT by the kernel driver. The current kernel driver takes care of setting CS high/low in software. It only needs to be in an ALT mode if the SPI hardware is used to control CS.

Return to “Compute Module”