I'm using an ADS1248 and am sending the following commands:
Setup:
send SDATAC (turn continuous read off)
wait for ready
send WREG reg=1,2 len=2 values=0x00,0xa0
wait for ready
send WREG reg=0xa,0xb len=2 values=0x04,0x89
wait for ready
These settings appear to work as we are more or less getting the correct readings most of the time.
Once a second:
wait for ready signal
send WREG reg=0 len=1 value=0x05 (Ain0)
wait for ready signal
send RDATA
wait for ready signal
send WREG reg=0 len=1 value=0x0D (Ain1)
* keep the 3 bytes that come back as Ain0 reading
wait for ready signal
send RDATA
wait for ready signal
send 3xNOP
* keep the 3 bytes that come back as Ain1 reading
I'm seeing spikes on the first channel (should be reading 2.048 V (correct)) - but i occasionally get ~1.7408 (85% reading).
The second channel isn't seeing spikes and that is reading around ~0.819 V (correct).
Time timing for my SPI transmission is as follows:
wait for ready signal
select ADC (chip select on (low))
delay 2us
interrupts off
push command bytes into SPI queue
interrupts on
wait for response back from SPI (when bytes tx == bytes rx) - all done via interrupts
delay 4us
deselect ADC (chip select off (high))
delay 3us
keep the rx bytes if relevant (ie. take a reading)
The SPI driver is not running at highest priority - there is potentially another task that can interrupt it (except where
interrupts are off).