Jump to content
  • 0

WaveForms SPI Protocol Analyzer Issue


edwardjs

Question

I am using the SPI protocol analyzer on WaveForms (using the Analog Discovery 2) and I'm getting weird results. I keep getting results that look like this:

*********************

Leftover bits: 2 0,

Leftover bits: 3 32,

Leftover bits: 2 0,

Leftover bits: 4 96,

Leftover bits: 5 248,

*********************

I am using an Arduino Uno to send the SPI data. The sketch is as follows:

********************************

#include <SPI.h>

unsigned long lastInterrupt = 0;
unsigned long thisInterrupt;

uint8_t Command = 173;
uint16_t Data = 52128;

void setup() {

  SPI.begin();

  pinMode(8, OUTPUT);
  pinMode(2, INPUT_PULLUP);

  attachInterrupt(digitalPinToInterrupt(2), Interr, FALLING);

  SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE1));
}

void Interr() {

  thisInterrupt = millis();
  
  if ((thisInterrupt - lastInterrupt) > 500) {
    
    digitalWrite(8, LOW);
    SPI.transfer(Command);
    SPI.transfer16(Data);
    digitalWrite(8, HIGH);

  }

  lastInterrupt = thisInterrupt;
  
}

void loop() {}

********************************

I saw in another forum post that this "leftover bits" issue is caused when the active low cycle doesn't match up with the data transfer. However, I am confused why I am only getting leftover bits and no command or data bits. As well, the number of leftover bits does not add up to command bits + data bits, so where are the other bits going? I have attached a picture of my WaveForms settings. Could anyone help me with this issue? Or give me more insight on this issue? Is my CS pin going back to HIGH too early or too late? Please let me know if you need more information about the issue.

Screen Shot 2021-07-14 at 9.52.41 AM.png

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Using the logic analyzer, I saw that my chip select pin randomly goes high sometimes when it should be low. It spikes a couple times during the data transfer. If no spike occurs, then the data is transferred successfully. If it spikes, data is corrupted. I'm now trying to figure out how to eliminate the spikes. Thank you for the quick reply

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...