UDP Communication and an addtional SPI connection, STM32duino

Hello guys,

I am working on a project, where I want to make two MCUs communicate with each other. I am using STM32F29ZI. I am using the example sketch UDPSendReceiveString and it works fine. The two MCUs have different MAC-Addresses and IPs. And one of them begins to send a message. After that the infinite loop begins..

#include <SPI.h>
#include <LwIP.h>
#include <STM32Ethernet.h>
#include <EthernetUdp.h>

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xFF
};
IPAddress ip(192, 168, 1, 176);
IPAddress server(192, 168, 1, 177);
const int slaveSelectPin = 7;
unsigned int localPort = 8888;      // local port to listen on

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE];  // buffer to hold incoming packet,
char ReplyBuffer[] = "acknowledged";        // a string to send back

// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;

void setup() {
  pinMode (slaveSelectPin, OUTPUT);
// start the Ethernet
  SPI.begin();
  Ethernet.begin(mac, ip);

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start UDP // only one of them
  Udp.begin(localPort);
  Udp.beginPacket(server,localPort);
  Udp.write(ReplyBuffer);
  Udp.endPacket();
}

void loop() {

  // if there's data available, read a packet
  int packetSize = Udp.parsePacket();
  if (packetSize) {
    Serial.print("Received packet of size ");
    Serial.println(packetSize);
    Serial.print("From ");
    IPAddress remote = Udp.remoteIP();
    for (int i=0; i < 4; i++) {
      Serial.print(remote[i], DEC);
      if (i < 3) {
        Serial.print(".");
      }
    }
    Serial.print(", port ");
    Serial.println(Udp.remotePort());

    // read the packet into packetBufffer
    Udp.read(packetBuffer, UDP_TX_PACKET_MAX_SIZE);
    Serial.println("Contents:");
    Serial.println(packetBuffer);

    // send a reply to the IP address and port that sent us the packet we received
    Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
    Udp.write(ReplyBuffer);
    Udp.endPacket();
  }
  delay(10);
}

Soo the code above works, but if I paste this code right under void loop{:

void loop() {

  SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE2));
  SPI.endTransaction();

it wont work anymore, and I have really not one idea, why it doesnt.

I need your help please..

LG
Furkan

the experts are there https://www.stm32duino.com/

All right, Ive posted it also there, but if there is anyone who can help, I would be glad!