SPIN driver for MCP3208
VonSzarvas
Posts: 3,451
in Propeller 2
Hello!
Wondering if anyone created (and willing to share) a SPIN driver for the MCP320x family of A/Ds (SPI bus) ?
https://www.microchip.com/datasheet/MCP3208
Wondering if anyone created (and willing to share) a SPIN driver for the MCP320x family of A/Ds (SPI bus) ?
https://www.microchip.com/datasheet/MCP3208
Comments
Read app notes 6.3 Buffering & filtering carefully
also 6.4 Layout Considerations.
Must use a MCP1541 voltage reference chip (or equal ) along with the required 1uF cap
There is way too much voltage variance and noise in a system voltage supply, and you will never get consistent readings either long or short term.
Using the P2 Smart pin ADC gives much better short and long term readings. My tests is to short a P2 DAC and ADC together. Set the DAC at some nice voltage (1.000 VDC) and read the voltage using a Smart pin ADC. Consistent short and long term (2000 hours plus) readings 1.00x plus/minus 1or 2 counts, as compared with my 4 half digit voltmeter.
Warning: Not tested (yet) by JM -- though I feel like this is an accurate translation of P1 code that I've used in other projects.
Of course, after I posted I looked back and found some little gotchas. While I don't have a loose chip to test with, I do have a logic analyzer. The attached image shows a test of this version of the object attempting to read channel 0 in single-ended mode. The constant for that is %11000, and you can see that corresponds to the first five bits out of the MOSI pin.
This will be a great head-start (or complete finish if they run as-is!!).
Whatever happens, I'll post back a tested working code sample later next week. As soon as I finish a test fixture for a certain large P2 development board