Ok so I am basing what I know about SPI off how to make a max 7219 led driver work. I am now trying to use a dac to produce a voltage based on an input from an adc. I looked over wests tutorial and find it complex from what I think I should be able to do so here is what I tried. It didn't work because I am not sure how to read the cut sheet and determine the register to address to send data.
I think all you need to make spi work (using 28x2) is to hook up the clk line, the DIN line and the CS line. My dac doesn't have LDAC. I am using a for next loop to make data for the dac and pulsout to load the data via cs. I could not find a register to put with the data to send so I just put the same variable as the data and that produces a ramp as expected but one that repeats many times as the dac counts up. So what is wrong with this approach provided I find the appropriate register value to pair with the data. IF its not a register than the appropriate top byte that provides the correct command. This is on a max5241. I tried making the cs line high and low via the let pin command and also via the pulseout command thinking that maybe cs had to stsay open longer than just a pulse. Both give the same result.
I think all you need to make spi work (using 28x2) is to hook up the clk line, the DIN line and the CS line. My dac doesn't have LDAC. I am using a for next loop to make data for the dac and pulsout to load the data via cs. I could not find a register to put with the data to send so I just put the same variable as the data and that produces a ramp as expected but one that repeats many times as the dac counts up. So what is wrong with this approach provided I find the appropriate register value to pair with the data. IF its not a register than the appropriate top byte that provides the correct command. This is on a max5241. I tried making the cs line high and low via the let pin command and also via the pulseout command thinking that maybe cs had to stsay open longer than just a pulse. Both give the same result.
Code:
#picaxe 28x2
setfreq m16
let adcsetup = 0
Let dirsA=%00010000
Let dirsB=%11111111
Let dirsC=%11111111
hspisetup spimode00,spifast
main:
for w0=0 to 10000 step 1
let pinb.0=0
hspiout (W0,W0)
let pinb.0=1
next w0