SPI + Digital potentiometer question
Hello all,
I have searched for any help on this topic but haven't had any success. I am trying to control a digital potentiometer via the propeller using a 3 wire SPI protocol. There is an object in OBEX designed to control a similar device (MCP41xxx.spin) and I was trying to adapt it to work with the MCP4161, my issue is more of a basic SPI issue. I'm reading off of the CS and SDI pins of the device with an oscilloscope and cannot get my program to send any serial data. Below is the code snippet for the potentiometer setting, and the transmit segment of the MCP41xxx object. I am just calling the "setpot" from my main program with no response.
Any assistance is greatly appreciated.
Thanks in advance
I have searched for any help on this topic but haven't had any success. I am trying to control a digital potentiometer via the propeller using a 3 wire SPI protocol. There is an object in OBEX designed to control a similar device (MCP41xxx.spin) and I was trying to adapt it to work with the MCP4161, my issue is more of a basic SPI issue. I'm reading off of the CS and SDI pins of the device with an oscilloscope and cannot get my program to send any serial data. Below is the code snippet for the potentiometer setting, and the transmit segment of the MCP41xxx object. I am just calling the "setpot" from my main program with no response.
Any assistance is greatly appreciated.
PUB setpot(pot, value) | packet
if pot < POT_0 or pot > POT_BOTH or value < 0 or value > 255
return 1
else
packet.byte[0] := CMD_WRITE | pot
packet.byte[1] := value
write(16, packet)
PRI write(Bits,Data) | temp ' Send DATA MSB first
outa[CS] := 0 ' clear CS
temp := 1 << ( Bits - 1 )
repeat Bits
outa[SI] := (Data & temp)/temp ' Set bit value
outa[SCK] := 1 ' Clock bit
outa[SCK] := 0 ' Clock bit
temp := temp / 2
outa[SI] := 0
outa[CS] := 1 ' set CS to 1
Thanks in advance

Comments
pub write(bits, data) outa[CS] := 0 ' select device data <<= (32 - bits) ' move MSB to bit31 repeat bits outa[SI] := (data <-= 1) ' rotate MSB to bit0 for output outa[SCK] := 1 ' clock the bit outa[SCK] := 0 outa[CS] := 1 ' deselect@Mark_T - DIRA?
EDIT: I have a USB scope decoding the SPI interface and so far I am not getting anything. The CS pin gets pulled low right before it loops and should be sending data, however I don't get any data output on the SDO line and the CS pin stays low. To me this would indicate that it is not finishing the loop and getting stuck, should I be formatting my data differently? I'll keep playing with it in the meantime.
P.s.- I am running a board of education