EEVblog Electronics Community Forum
Electronics => Microcontrollers => Topic started by: Pack34 on October 08, 2018, 07:17:51 pm
-
I'm working with a PIC24 and a SPI transfer from an ADC seems to intermittently return incorrect data on a specific channel. The voltages applied to the input of the ADC have been proven to be steady using a series of external ADCs at a greater sampling rate but the ADC itself could respond with what would correspond to a drop of 8V on a 24V circuit.
The SPI module is a dedicated module inside the PIC and an interrupt that pulls the PIC elsewhere shouldn't affect the data being read-in over the bus, correct?
-
Does the ADC error always correlate to the same bit in the SPI frame?
-
It's always the same channel. The LSB tends to look mostly intact but the MSB is complete garbage.
-
Do you have a schematic and perhaps a board layout?
Is your SPI being shared?
-
Check with a scope for runts on the SPI clock. I've seen cascaded 8-bit transfer subroutines used for 16-bit transfers, where the last 8-bits (subroutine) leaves the clock low and then the clock is up right away for the next 8-bit transfer, so you get an extra clock pulse as a glitch.
-
I'm working with a PIC24 and a SPI transfer from an ADC seems to intermittently return incorrect data on a specific channel. The voltages applied to the input of the ADC have been proven to be steady using a series of external ADCs at a greater sampling rate but the ADC itself could respond with what would correspond to a drop of 8V on a 24V circuit.
The SPI module is a dedicated module inside the PIC and an interrupt that pulls the PIC elsewhere shouldn't affect the data being read-in over the bus, correct?
Scope the SPI, add some debug code to set a pin to trigger the scope on an obviously incorrect SPI value and see what the SPI is doing at the time.
Check that you are clocking data in on the correct edge of the SPI clock
-
Since we have no idea about your source code... nor any scope capture...
Have you considered that it may not be an SPI transfer problem per se but rather the way you store the samples?
Maybe it's a 16-bit ADC and you use an 8-bit mode SPI, and have some kind of issue with reading incomplete values due to the storage itself being interrupted while you read them?