Strange looking SPI communication

Hi,

I'm using Arduino Ethernet board for communication with another MC using SPI bus.

Here is the code:

#include <SPI.h>
#include "ethernetFunctions.h"

void setup(){ 
  // for printing debug messages to serial window
  Serial.begin(9600);
  while (!Serial){
    Serial.println("opening port");
  }
  
  Serial.println("Program started");
  
  // setup for communicating with Jennic
  pinMode(CSforJennic,OUTPUT); 
  SPI.begin();
  SPI.setBitOrder(MSBFIRST); 
  digitalWrite(CSforJennic,HIGH);  
}


void loop(){
  sendDataToJennic(125);
  delay(5000);
  Serial.println("Data sent to SPI");
}

and ethernetFunction.h

#include <stdint.h>

uint8_t CSforJennic = 4;

void  sendDataToJennic(int data){ 
  digitalWrite(CSforJennic, LOW);
  SPI.transfer(data); 
  digitalWrite(CSforJennic,HIGH);  
}

When I plot the MISO(red), MOSI(blue), CLK(yellow) and CS(green) I get the graphs from attachement.

Does anyone know why CS has these strange oscillations when it should have been zero the whole time during communication?

Which CS are you monitoring? Is that CSforJennic (D4) or the default SPI CS (D10)?

What is connected to D4? Normally that is used for the SD card if one is in the SD slot.

I'm using pin 9. I've also tried pin 7 and 5 and 6.. Same situation in each case.

What SPI device CS is connected to D9 (or D7, D5, D6) that you are communicating with? What is the purpose?

edit: Do you have anything connected to D10 to D13? Do you have a SD card in the shield's slot? If you have a pin conflict with another device, that could cause the Arduino to malfunction. I noticed in your digital display that there is a long pause before the CS pin goes HIGH again, indicating a possible malfunction.

It's Jennic microcontroller, but it's not relevant to the problem.

I'm using pins 11 to 13 for standard SPI comm. for MOSI, MISO and CLK. All the pins that I've tried using for CS should be free and I don't see a reason why they should not work.

It's Jennic microcontroller, but it's not relevant to the problem.

Are you certain of that? Have you tried removing that microcontroller and running your digital analysis again with just the basic Arduino?

edit: The SPI function should work with no device connected. The MISO line may be floating and show weird results, but that is ok for a test. You are looking for correct outputs from the SCK and CS pins.

Are you powering your Jennic with the Arduino power?