avafinger / bananapi-zero-ubuntu-base-minimal

BananaPi M2 Zero - Ubuntu Focal Base Minimal Image (Experimental) - U-Boot 2017.09 / Kernel 4.18.y / Kernel 4.19.y / Kernel 4.20.y / Kernel 5.3.y / Kernel 5.6.y / Kernel 5.7.y / Kernel 5.11.y
88 stars 17 forks source link

Unusual SPI behaviour in Mode 1 #50

Open aronfeher opened 4 years ago

aronfeher commented 4 years ago

Hello! I have a Bpi zero with the latest kernel, and I'm trying to set and get data from ADS1294 IC through SPI communication. The IC expects SPI in mode 1. When I set the spidev0.0 to mode1 and start the data transfer, only junk came back, so I took out the logic analyzer and here is the interesting part.

If I set mode1 the clk line has an initial anomaly (first figure) which may confuse the ADS1294. At least the logic analyzer software was confused. If I set mode3 everything works as expected (second figure). Just for my sanity’s sake I’ve took out an Arduino nano, and started an SPI communication in mode1 (third figure). The waveform behaved as expected, and I could communicate with the ADS1294.

I have a feeling that some register is messed up, because this is my first time working with SPI in embedded OS, but I can’t figure out how to get rid of the problem.

I've tried this in both Python (py-spidev) and C, with the same result.

Any help would be appreciated.

mode1_bpi mode3_bpi mode1_arduino