Author Topic: Can interrupt firing corrupt a SPI Transfer?  (Read 608 times)

0 Members and 1 Guest are viewing this topic.

Offline Pack34

  • Frequent Contributor
  • **
  • Posts: 659
Can interrupt firing corrupt a SPI Transfer?
« on: October 09, 2018, 06:17:51 am »
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?
 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 1748
  • Country: gb
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #1 on: October 09, 2018, 06:22:47 am »
Does the ADC error always correlate to the same bit in the SPI frame?
 

Offline Pack34

  • Frequent Contributor
  • **
  • Posts: 659
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #2 on: October 09, 2018, 08:30:56 am »
It's always the same channel. The LSB tends to look mostly intact but the MSB is complete garbage.
 

Offline JustMeHere

  • Regular Contributor
  • *
  • Posts: 99
  • Country: us
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #3 on: October 12, 2018, 12:37:35 pm »
 Do you have a schematic and perhaps a board layout?
Is your SPI being shared? 
 

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 2118
  • Country: ca
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #4 on: October 12, 2018, 12:47:50 pm »
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.
 

Offline mikeselectricstuff

  • Super Contributor
  • ***
  • Posts: 11798
  • Country: gb
    • Mike's Electric Stuff
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #5 on: October 12, 2018, 07:13:55 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?

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
Youtube channel:Taking wierd stuff apart. Very apart.
Mike's Electric Stuff: High voltage, vintage electronics etc.
Day Job: Mostly LEDs
 

Online SiliconWizard

  • Super Contributor
  • ***
  • Posts: 1559
  • Country: fr
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #6 on: October 13, 2018, 02:32:47 am »
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?

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf