Spi CS not working properly

ggeli

New member
Hello,

We have two prototypes, and one is able to communicate via SPI and the other is not. The picture below shows the CS (blue) and SCLK during a working interaction.
TEK00000.png


The other time when it does not work, it looks like below, when the CS (now Yellow) changes state during an SPI interaction and does not allow it to complete.
TEK00007.png


The only obvious difference I see is the oscillations in the SCLK, but I'm not sure what could be causing it. What could be causing this?




CODE:
#include <SPI.h>

void DoTest(void)
{
uint32_t  ver;

SPI.begin();
  ver = readRegister(SMDA_COMMON,ADDRESS_TYPE_VERSION_429);
  Serial.println(ver);
}

uint32_t readRegister(uint8_t smda,uint8_t address)
{
MosiDatagram mosi_datagram;

mosi_datagram.rrs = RRS_REGISTER;
  mosi_datagram.address = address;
  mosi_datagram.smda = smda;
  mosi_datagram.rw = RW_READ;
  mosi_datagram.data = 0;
  MisoDatagram miso_datagram = writeRead(mosi_datagram);
  return miso_datagram.data;
}
 
Would you mind posting your complete code?
Your code does not compile. For starters, it's missing void setup() and void loop().

Paul
 
Back
Top