gc986
Posts: 7
Joined: Sun Mar 18, 2018 8:01 pm

Test SPI - not working

Sun Mar 18, 2018 8:13 pm

I compile prgram and run for testing SPI, how in this - https://importgeek.wordpress.com/2017/0 ... k-testing/
But after run program i see only three strings:
./a.out --device /dev/spidev0.0
spi mode: 0
bits per word: 8
max speed: 500000 Hz (500 KHz)

Why matrix not showing how in example?
(I included SPI)

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

Re: Test SPI - not working

Sun Mar 18, 2018 9:08 pm

Try the following commands

sudo pigpiod

pigs spio 0 50000 0

pigs spix 0 10 20 30 40 50
pigs spix 0 10 20 30 40 50

What do the spix commands return?

gc986
Posts: 7
Joined: Sun Mar 18, 2018 8:01 pm

Re: Test SPI - not working

Mon Mar 19, 2018 6:12 pm

joan wrote:
Sun Mar 18, 2018 9:08 pm
Try the following commands

sudo pigpiod

pigs spio 0 50000 0

pigs spix 0 10 20 30 40 50
pigs spix 0 10 20 30 40 50

What do the spix commands return?

Code: Select all

[email protected]:~ $ sudo pigpiod
[email protected]:~ $ pigs spio 0 50000 0
0
[email protected]:~ $ pigs spix 0 10 20 30 40 50
5 10 20 30 40 50
[email protected]:~ $ pigs spix 0 10 20 30 40 50
5 10 20 30 40 50
[email protected]:~ $ pigs spix 0 10 20 30 40 50
5 0 0 0 0 0
[email protected]:~ $ pigs spix 0 10 20 30 40 50
5 10 20 30 40 50

If the pins are connected, it returns the same result as passed in the command, if the disconnect get zeros. Is this a compiled application with an error or missing rights?

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

Re: Test SPI - not working

Mon Mar 19, 2018 6:17 pm

That is showing the loop back test is working okay. If you remove the link between MOSI and MISO you will get all 0s, otherwise you get what you send.

That means the SPI hardware is okay.

The spidev test program you were using is faulty, perhaps it needs updating.

gc986
Posts: 7
Joined: Sun Mar 18, 2018 8:01 pm

Re: Test SPI - not working

Mon Mar 19, 2018 7:24 pm

joan wrote:
Mon Mar 19, 2018 6:17 pm
That is showing the loop back test is working okay. If you remove the link between MOSI and MISO you will get all 0s, otherwise you get what you send.

That means the SPI hardware is okay.

The spidev test program you were using is faulty, perhaps it needs updating.
Thank You!

Return to “Beginners”