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

0 Members and 1 Guest are viewing this topic.

Offline Pack34Topic starter

  • Frequent Contributor
  • **
  • Posts: 753
Can interrupt firing corrupt a SPI Transfer?
« 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?
 

Offline mikerj

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

Offline Pack34Topic starter

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

Offline JustMeHere

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

Offline floobydust

  • Super Contributor
  • ***
  • Posts: 6923
  • Country: ca
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #4 on: October 12, 2018, 01:47:50 am »
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: 13694
  • Country: gb
    • Mike's Electric Stuff
Re: Can interrupt firing corrupt a SPI Transfer?
« Reply #5 on: October 12, 2018, 08:13:55 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?

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
 

Offline SiliconWizard

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