Go Down

Topic: SPI transfer, enable pin not staying low (Read 378 times) previous topic - next topic

Tauts54

I am doing an SPI transfer with an arduino due to an AD9833 chip.  For some reason i can not figure out the chip select (CS) pin is not staying low for the duration of the transfer.  Code and waveform shown below.

I put in only the relevant code here
Code: [Select]
#include <SPI.h>
#define slaveSelectPinAD9833 52

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  SPI.begin(slaveSelectPinAD9833);
  SPI.setDataMode(slaveSelectPinAD9833, SPI_MODE2);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Testing SPI");
  delay(4);
  SPI.transfer(slaveSelectPinAD9833, 0x21, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x00, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x50, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0xC7, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x40, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x00, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0xC0, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x00, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x20, SPI_CONTINUE);
  SPI.transfer(slaveSelectPinAD9833, 0x00);
  delay(200);
}




As can be seen the enable pin on 52 does not always stay low for the duration of the transfer.  Some times the transfer does work but most of the time it does not.  I even tried to set a seperate pin (22) as just an output pin and set it low before transfer, but even hooking up that pin showed a similar result.  It would periodically go high in the middle of the transfer even though it was set as output low.  The enable pin does this when it is both connected and  not connected to the AD9833.

Anyone else have this issue or know why the enable pin will periodically go high, or why SPI transfer can affect other output pins?

MarkT

You're picking up noise from an adjacent channel I think - check your circuit
and measuring probes - the Due output edges are way fast, easily induce a pulse
on a nearby signal if not short and running over a good groundplane.

Since you had the same problem with pin 22, its nothing specific to SPI I'd suggest.

It may just be a measurement artifact, do you have reason to suspect malfunction
without the LA attached?   Note that the error pulses coincide with SCLK and MOSI
signals positive-edges - I'd guess the enable wire is sandwiched between these two
signals at some point.
[ I won't respond to messages, use the forum please ]

Go Up