Quantcast
Channel: Arduino Forum - Latest topics
Viewing all articles
Browse latest Browse all 15454

SPI Master - trouble with signal burst

$
0
0

SPI Master on Arduino Nano
I'm having problems to get the SPI commnication to work on an Arduino Nano. The final project shall connect an RaspPi (master at 3.3V) with an Arduino Nano (slave at 5V) via SPI to send test data from the Nano to the RaspPi. I wasn't successful, so I thought to first test the Arduino in master mode with no slave connected (MISO floating). The nano is powered by USB and I'm using the serial monitor.

The Error
a logic analyzer monitors the voltage levels on the 4 pins. When I drive the SS low (pin 10 as Output) i expected the voltage level to go down and up only once when requested by the code, but instead the voltage level jumps between high/low randomly causing the SPI transmission to fail. I cannot figure out what the problem is. I can overcome the unstability at the beginning when SS goes low by adding a delay of 50 microsec, but during the SPI transmission the SS pin is jumping up and down.

Screenshot logic analyzer

The logic analyzer is connected straight to the Arduino pins using the same single ground pin on the POWER connector of the Arduino for all 4 channels.

Master Code

#include <SPI.h>

void setup (void)
{
  Serial.begin (115200);
  
  // pinMode(SS, OUTPUT);
  // digitalWrite(SS, HIGH);   
  
  SPI.begin ();   // setting SS as OUTPUT and set to HIGH
  
  Serial.println ("start...");
}  // end of setup

void loop (void)
{
  byte a;

  delay(5000);  // give time to start analyzer
  
  digitalWrite(SS, LOW);
  delayMicroseconds(5);  // give some time to settle

  byte a = SPI.transfer ('a');  // send ASCII a
  delayMicroseconds(20);  
  
  digitalWrite(SS, HIGH);

while(1){};  // don't loop, wait for reset

}  // end of loop

I have tried all different variations of the delay and also setting the register (PORTB) istead of the function digitalWrite Voltage levels look always similar.

Any ideas what I'm missing out?
Thanks.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 15454

Trending Articles