Hello,
I try to send UDP packet using ENET_UDP_Tx() in ENET_RADAR.c.
It is okay send one by one packet in Debug.
But I write a for loop to send 1024 byte UDP packets with serial number.
But packet loss.
So I add "while(ENET.TDAR.B.TDAR) ;" in ENET_UDP_Tx to make sure transmit done.
void ENET_UDP_Tx(uint8_t *buffer, uint32_t size)
{
while(ENET.TDAR.B.TDAR) ; //yilin test wait TDAR
// Modify the UDP header to populate the IPv4 length field
UDP_header[16] = ((IPv4_HEADER_LEN + UDP_HEADER_LEN + size) >> 8) & 0xFF;
UDP_header[17] = (IPv4_HEADER_LEN + UDP_HEADER_LEN + size) & 0xFF;
// Modify the UDP header to populate the UDP length field
UDP_header[38] = ((UDP_HEADER_LEN + size) >> 8) & 0xFF;
UDP_header[39] = (UDP_HEADER_LEN + size) & 0xFF;
// Clear the checksums
UDP_header[24] = 0x00;
UDP_header[25] = 0x00;
UDP_header[40] = 0x00;
UDP_header[41] = 0x00;
txbd[0].status0 |= TX_BD_S0_R;
txbd[1].data = buffer;
txbd[1].length = (uint16_t)size;
/* Mark all buffer descriptors as ready */
txbd[1].status0 |= TX_BD_S0_R;
ENET.TDAR.B.TDAR = 1; // Start transmission
}
I had tried to check "txbd[0].status0 & TX_BD_S0_R == 0", but not work.
Is there any way to make this more efficiency?
Updated: I'm testing on S32R EVB and ENET_RADAR.c is part of S32R274_MR3003_GHS sample
Kuan Hung Lin