Ok, here is my code:
First my Open UDP function:
int8_t UDP_OpenPort(uint8_t sn, uint16_t port)
{
int8_t tmp = 0;
int8_t retVal = UDP_OPEN_ERROR;
/* Wird nur ausgeführt wenn der Socket nicht bereits geöffnet ist */
if (getSn_SR(sn) != SOCK_UDP)
{
/* Ă–ffne Socket (Port config)*/
tmp = socket(sn, Sn_MR_UDP, port, 0x00);
if (tmp != sn)
{
/* Signalisiere durch das 0 setzten, dass das öffnen des Ports nicht erfolgreich war. Kann zur Laufzeit als Bedingung genutzt werden */
W5500_RuntimeInformation.wizUdp0 = 0;
W5500_RuntimeInformation.wizUdp0Port = 0;
}
else
{
/* Ăśbernehme Config in Runtimeinformation, da 'socket' function erfolgreich */
W5500_RuntimeInformation.wizUdp0 = sn;
W5500_RuntimeInformation.wizUdp0Port = port;
retVal = UDP_OPEN_COMPLETE;
}
}
return retVal;
}
Next my function where sending UDP frames out:
int8_t UDP_Send(ipMessage_t *message)
{
int8_t tmp = 0;
int8_t retVal = UDP_TRANSMISSION_NOT_COMPLETE;
if(message != NULL)
{
switch (getSn_SR(W5500_RuntimeInformation.wizUdp0))
{
case SOCK_UDP:
tmp = sendto(W5500_RuntimeInformation.wizUdp0, message->payloadBuff, message->numberOfBytes, message->destinationIp, message->destinationPort);
if (tmp == message->numberOfBytes)
{
retVal = UDP_TRASNMISSION_COMPLETE;
}
else if (tmp < 0)
{
retVal = UDP_TRANSMISSION_ERROR;
}
break;
case SOCK_CLOSED:
/* Wenn SEND-Request ausgeführt wird, der Port jedoch nicht geöffnet ist, wird automatisch ein OpenUDS ausgeführt (Anhand der Runtimeinformation [ethComInterface.c/h])*/
UDP_OpenPort(W5500_RuntimeInformation.wizUdp0, W5500_RuntimeInformation.wizUdp0Port);
break;
default:
/* Error Handler */
retVal = UDP_TRANSMISSION_ERROR;
break;
}
}
return retVal;
}
Here is my init function of the chip:
uint8_t ECI_InitComInterface(uint8_t *mac, uint8_t *ip, uint8_t *subnetMask, uint8_t *gateway, uint8_t *dns, bool bootFromFlash)
{
int8_t retValSetInfo = -1;
int8_t retValGetInfo = -1;
int8_t tmp;
uint8_t memsize[2][8] = { { 2, 2, 2, 2, 2, 2, 2, 2 }, { 2, 2, 2, 2, 2, 2, 2, 2 } };
uint8_t retVal = INIT_FAILED;
/* Boot the Main Config / else case get information from EEPROM */
if (bootFromFlash == true)
{
/* Init the abstraction layer of SPI Write/ Read functions to the driver layer*/
/* Chip selection call back */
reg_wizchip_cs_cbfunc(ECI_SetSpiChipSelect, ECI_SetSpiChipDeselect);
/* SPI Read & Write callback function */
reg_wizchip_spi_cbfunc(ECI_SetSpiReadByte, ECI_SetSpiWriteByte);
/* Reset the Wiznet W5500 Chip */
ECI_ResetChip();
/* Function set the arguments into the runtime information */
SetRuntimeInformation(mac, ip, subnetMask, gateway, dns);
//Bring the runtimeinformation to Initial values.
W5500_RuntimeInformation.state = W5500_STATE_NOT_DEFINED;
W5500_RuntimeInformation.failState = W5500_ERROR_NO_ERROR_OCCURED;
W5500_RuntimeInformation.operationMode = W5500_MODE_NOT_DEFINED;
/* WIZCHIP SOCKET Buffer initialize */
if (ctlwizchip(CW_INIT_WIZCHIP, (void*)memsize) == -1)
{
W5500_RuntimeInformation.failState = W5500_ERROR_IN_MEM_CONFIG;
return INIT_FAILED;
}
/* PHY link status check*/
uint32_t start = HAL_GetTick();
uint32_t time = 0;
do
{
if (ctlwizchip(CW_GET_PHYLINK, (void*)&tmp) == -1)
{
W5500_RuntimeInformation.failState = W5500_ERROR_UNKOWN_PHY;
return INIT_FAILED;
}
/* Timeout to avoid infinit loop */
time = HAL_GetTick() - start;
}
while ((tmp == PHY_LINK_OFF) && (time < timeOutInit));
if (tmp == PHY_LINK_OFF)
{
W5500_RuntimeInformation.failState = W5500_ERROR_PHY_LINK_OFF;
W5500_RuntimeInformation.state = W5500_STATE_INIT;
W5500_RuntimeInformation.operationMode = W5500_MODE_INIT;
return INIT_FAILED;
}
/* Init the Wiznet Chip. Function reaches this part only if all other parts were successfull */
uint8_t stateOfConfig = ConfigW5500Chip(W5500_RuntimeInformation);
if (stateOfConfig == ERROR_OCCURED)
{
W5500_RuntimeInformation.failState = W5500_ERROR_BASE_CONFIG_FAILED;
retVal = INIT_FAILED;
}
else
{
W5500_RuntimeInformation.failState = W5500_ERROR_NO_ERROR_OCCURED;
}
if (W5500_RuntimeInformation.failState == W5500_ERROR_NO_ERROR_OCCURED)
{
W5500_RuntimeInformation.state = W5500_STATE_IDLE;
W5500_RuntimeInformation.operationMode = W5500_MODE_NORMAL;
retVal = INIT_SUCCEED;
}
else
{
W5500_RuntimeInformation.state = W5500_STATE_INIT;
W5500_RuntimeInformation.operationMode = W5500_MODE_INIT;
}
EthRingbuffInitBuffer(&tcpRingBuff, tcpArray, ETH_RING_BUFF_SIZE, 0);
}
return retVal;
}
And here is my main:
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_SPI1_Init(); //For EEPROM
MX_SPI2_Init(); //For W5500
/* USER CODE BEGIN 2 /
/ EEPROM Init*/
EEPROM_25LC320_InitEeprom();
/*Bsp.: Init des Ethernet-Chips W5500 & Configurieren des Treibers*/
ECI_InitComInterface(mac, ip, snm, dgw, dns, true);
/* Open UDP Port "internal socket 7" with port 3000*/
UDP_OpenPort(7, 3000);
/* PC ip address & port*/
message.destinationIp[0] = 192;
message.destinationIp[1] = 168;
message.destinationIp[2] = 1;
message.destinationIp[3] = 132;
message.destinationPort = 3000;
/* All data bytes are zero */
message.numberOfBytes = 100;
/* Send UDP Frame */
UDP_Send(&message);
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
ECI_Runtask();
}
/* USER CODE END 3 */
}
The ECI_Run task is a TCP/ UDP Loopbackserver (works good).
But if you look at the section before the while(1), you se I init the interface open the UDP Port an want to send a Frame. In debugging step-by-step it works really good, but when I let run my microcontroller with full speed (release) no frame would send 
I hope you can help me! Bechause I would even go so far as to say that this is a Bug of the W5500.
Steve