Shop OBEX P1 Docs P2 Docs Learn Events
ADC with SPI interface problems — Parallax Forums

ADC with SPI interface problems

gsenesacgsenesac Posts: 3
edited 2007-10-07 08:24 in Propeller 1
I'm attempting to interface a Propeller with a MAX1162 ADC that has a SPI interface. However, I'm having considerable difficulty in making it operate successfully. I've been poking around the object available for other SPI interfaced ADC's and I've attempted using the bs2 object in order to get the data from the ADC. Here's what I've arrived at after several iterations:

CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
rxPin = 31
txPin = 30

VAR
Long stack1[noparse][[/noparse]50] ' Stack for 2nd BS2 Cog

OBJ
BS2 : "BS2_Functions" ' Create BS2 Object
comms : "FullDuplexSerial"

PUB Start | temp
BS2.start (31,30) ' Initialize BS2 Object timing, Rx and Tx pins for DEBUG
outa[noparse][[/noparse]0] := 1
waitcnt(1_000+cnt)
outa[noparse][[/noparse]0] := 0 '' set max 1162 cs low
temp := bs2.SHIFTIN(2, 1, BS2#MSBPOST,24) '' shift data in
outa[noparse][[/noparse]0] := 1 '' set max 1162 cs high
comms.start(rxPin, txPin, 0, 9600)
repeat
comms.bin(temp,24)
waitcnt(50_000_000+cnt)

I was receiving all zeros before when I read the data through HyperTerminal but now I'm getting nothing out. Any thoughts?

Thanks,
Gordon

Comments

  • deSilvadeSilva Posts: 2,967
    edited 2007-10-07 08:24
    What about some DIRA?
    Why do you use the same pins (30,31) for comms AND bs2?
    Also have a look at the SD carddrivers this is basically SPI.
Sign In or Register to comment.