TassyJim
 Guru
 Joined: 07/08/2011 Location: AustraliaPosts: 6181 |
Posted: 08:11pm 02 Feb 2025 |
|
|
|
I forgot to mask off the higher bits in the 16bit code
data0 = data0 AND &h3FF etc
doing that will get rid of the obviously wrong readings.
In the 8 bit version I should have masked of bits for each SPI read before adding them together.
For some reason the second call to SPI2() is returning zero This is why the v/2 readings are too constant at 512 and also why the 0.4V reading is 0 instead of ~128
@Pluto the MCP3004 is very similar but has a couple more configuration bits so needs 17 cycles or 3 bytes. Edited 2025-02-03 13:18 by TassyJim |