;This is sort of what you need, I wrote this for the 0832 but I tested it on a 0831(with some mods) as I didn't have an 0832, might need some adjustments here and there ??? and the pauses can reduced or removed, Iput them in when I was testing it.
;Picaxe 18x
;Read ADC0832
;
symbol cs = 0 ;Chip enable pin
symbol clk = 1 ;Clock pin
symbol dat = 2 ;Data pin
symbol loop = b0 ;for/next loop variable
symbol byte = b1 ;Final value
symbol bit = b2 ;bit value
symbol DataIn = pin1 ;data bit from adc
main:
low clk ;Clock low
low dat ;Data pin low
high cs ;Chip enable pin high
pause 50 ;Short delay
high dat ;Start bit
low cs ;Enable chip
pause 50 ;Delay before first clock
for loop = 1 to 3 ;First 3 clock pulses to set chip up
pulsout clk,5
next loop
byte = 0
Bit = 128 ;Set value for MSB
for loop = 1 to 8 ;Read 8 bits, MSB first
pulsout clk,5
if DataIn = 1 then DoBit ;If the data bit is high add bit value to byte
Bit = Bit / 2 ;If data bit is low divide for next bit
NextBit: next loop
high cs ;Finished so disable chip
sertxd (#byte ,13,10) ;Send byte to pc
goto main ;Read adc again
DoBit:
byte = byte + Bit ;Add bit value to byte variable
Bit = Bit / 2 ;Divide for next bit
goto NextBit
Edited by - Phil75 on 16/04/2006 11:57:42