Shop OBEX P1 Docs P2 Docs Learn Events
ez_spi question — Parallax Forums

ez_spi question

I'm trying to use the ez_spi driver in a program and getting some confusing results. Trying to get to ground level in troubleshooting, I'm testing the following:
repeat i from 0 to 9
spi.shiftout(spi.LSBFIRST,i,8)

So the values I should get on my logic analyzer are 0,1,2,3,etc.
Instead, it appears the first bit is at the end, but everything else is in alignment.
So my values (bitwise) on the line look like:
00000000
00000001
10000000
10000001
01000000
01000001
11000000
11000001
etc

If I instead switch to MSBFIRST, it looks like I have a padded 0:
00000000
00000010
00000100
00000110
00001000
00001010
00001100
00001110
etc

The results are the same even if I put it to 32 bits (just more empty bits in between). I'm using flexprop for compilation so I'm not sure if there's a bug in that or I'm doing something wrong. I grabbed the ez_spi driver from the obex, but it also was last updated in 2020, so not sure if something changed between then and now as far as smart pins or hardware goes?

Any help would be appreciated.

Comments

  • RaymanRayman Posts: 16,223
    edited 2026-04-03 15:41

    You might try messing with the SPI clock frequency... Things can go wrong if too fast..

    Also, the SPI mode should match the analyzer..

    I'm using JM_SPI.spin2 and it seems to work. Although defs for sdo and sdi seem backwards to me..

  • kwagnerkwagner Posts: 50
    edited 2026-04-03 15:51

    My frequency is 1MHz, I tried lowering it to 100kHz with the same results.
    Here's a pic of what it looks like on the analyzer for LSBFIRST (ignore the two noise bits from me breaking out the signals)

Sign In or Register to comment.