joshybaby
Posts: 1
Joined: Wed Sep 04, 2019 1:35 pm

Reading SPI commands

Wed Sep 04, 2019 1:40 pm

Good afternoon guys!!

I'm currently trying to use a raspberry pi to transmit some SPI commands but am not sure if they're being sent correctly.

I also have a second Pi laying around and I want to use it as a health checking monitor for all the information getting sent.

How would I go about recording what has been sent on the second Pi?

(it's preferable to be using the second Pi for readings due to location issues)

All I want to do is open a channel to read the GPIO traffic from the SPI specific pins (SCLK, CE0 and MOSI).


If anyone could advise I'll be eternally grateful.


Thanks!
Josh

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

Re: Reading SPI commands

Wed Sep 04, 2019 2:33 pm

If you can drop the SPI speed to 50kbps or so then you can monitor the GPIO on the Pi you are using for SPI.

http://abyz.me.uk/rpi/pigpio/piscope.html

or

http://abyz.me.uk/rpi/pigpio/examples.h ... monitor_py

or

http://abyz.me.uk/rpi/pigpio/examples.h ... SPI_mon_py

User avatar
HermannSW
Posts: 1656
Joined: Fri Jul 22, 2016 9:09 pm
Location: Eberbach, Germany
Contact: Website Twitter YouTube

Re: Reading SPI commands

Thu Sep 05, 2019 9:39 am

In addition to using Pi itself for that, you can use usb logic analyzer.

Cheap 8CH 24Msps ones start at 4$ (5$ with free shipping):
https://www.aliexpress.com/premium/logi ... _new_app=y

My 100Msps one did cost 20$, the 400Msps one 68$ (with free shipping).

I used logic analyzer sofar nearly only to analyze I2C traffic (from Raspberry to v1/v2 camera), but you can specify protocols as USB or SPI as well. The software does the decoding for you then.

I2C sample:
https://www.raspberrypi.org/forums/view ... 0#p1237647
Image Image

Code: Select all

Time	[s]	Analyz.	Name	Decoded	Protocol	Result	
1.21379535	I2C	Setup	Write	to	[l]	+	NAK
1.21390535	I2C	Setup	Read	to	[m]	+	NAK
1.21402639	I2C	Setup	Write	to	[l]	+	NAK
1.21413639	I2C	Setup	Read	to	[m]	+	NAK
1.21425728	I2C	Setup	Write	to	[l]	+	NAK
1.21436727	I2C	Setup	Read	to	[m]	+	NAK
1.21549542	I2C	Setup	Write	to	[l]	+	ACK
1.21558542	I2C	0	+	ACK			
1.21567542	I2C	\n	+	ACK			
1.21578542	I2C	Setup	Read	to	[m]	+	ACK
1.21587542	I2C	V	+	ACK			
1.21596542	I2C	G	+	NAK			
1.21658899	I2C	Setup	Write	to	[l]	+	ACK
1.21667899	I2C	'1'	+	ACK			
1.21676899	I2C	'3'	+	ACK			
1.21685899	I2C	'1'	+	ACK			
1.21697899	I2C	Setup	Write	to	[l]	+	ACK
1.21706899	I2C	'1'	+	ACK			
1.21715899	I2C	'0'	+	ACK			
1.21724898	I2C	'0'	+	ACK			
⇨https://stamm-wilbrandt.de/en/Raspberry_camera.html

https://github.com/Hermann-SW/Raspberry_v1_camera_global_external_shutter
https://stamm-wilbrandt.de/github_repo_i420toh264
https://github.com/Hermann-SW/fork-raspiraw
https://twitter.com/HermannSW

Return to “Interfacing (DSI, CSI, I2C, etc.)”