Other Parts Discussed in Thread: TMS570LC4357
Tool/software:
I’m working on a project that involves setting up Ethernet communication between two TMS570LC4357 microcontrollers using their EMAC (Ethernet Media Access Controller) modules. My goal is to transmit packets from one TMS570LC4357 (Board A) to another (Board B) and receive packets on Board B, with the possibility of bidirectional communication.
Each board has a unique MAC address:
- Board A: 00:08:EE:03:A6:6C
- Board B: 00:08:EE:03:A6:6D
I’m sending a 64-byte packet from Board A with:
- Destination MAC: Board B’s MAC (00:08:EE:03:A6:6D) or broadcast (FF:FF:FF:FF:FF:FF).
- Source MAC: Board A’s MAC.
- EtherType: 0x88B5 (custom).
- Payload: "hello" followed by zeros.
I’ve tested loopback mode on a single board by importing an example project from forum :
#include "HL_sys_common.h"
#include "HL_system.h"
#include "HL_emac.h"
#include "HL_hw_reg_access.h"
// Global flag to track transmission status
volatile uint8 txSuccessFlag = 0;
uint8 src_emacAddress[6U] = {0x00U, 0x08U, 0xEEU, 0x03U, 0xA6U, 0x6CU}; // TX MAC
uint8 dest_emacAddress[6U] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU}; // RX MAC
extern hdkif_t hdkif_data[1];
pbuf_t pack[1];
uint8 data[1][100];
uint8 a = 0;
uint8 b = 0;
void create_packet()
{
int j;
pack[0].tot_len = 64; // Make sure it's >= minimum Ethernet frame size
pack[0].len = 64;
// Destination MAC
for (j = 0; j < 6; j++)
data[0][j] = dest_emacAddress[j];
// Source MAC
for (j = 0; j < 6; j++)
data[0][j + 6] = src_emacAddress[j];
// EtherType
data[0][12] = 0x88;
data[0][13] = 0xB5;
// Payload "hello"
data[0][14] = 'h';
data[0][15] = 'e';
data[0][16] = 'l';
data[0][17] = 'l';
data[0][18] = 'o';
for (j = 19; j < 64; j++)
data[0][j] = 0x00;
pack[0].payload = &data[0][0];
pack[0].next = NULL;
}
// Notification function called when TX is complete
void emacTxNotification(hdkif_t *hdkif)
{
// Set flag to indicate transmission success
txSuccessFlag = 1; // Transmission completed successfully
}
void main(void)
{
_enable_IRQ();
EMACHWInit(src_emacAddress);
create_packet();
while(1){
txSuccessFlag=0;
if (EMACTransmit(&hdkif_data[0], &pack[0]) != 0)
{
// Transmission started, now wait for notification
while (txSuccessFlag == 0); // Wait for notification (TX success)
if (txSuccessFlag == 1) {
// Transmission was successful
a++; // Some logic to indicate success
} else {
// Transmission failed
b = 9; // Some logic to indicate failure
}
}
else
{
b = 9;
}
}
}
By Checking TXGOODFRAMES and RXGOODFRAMES for Broadcast we can see the value incrementing
Now, I’m moving to board-to-board communication.
Pleases provide me suggestions and steps to Transmit and receive packets between 2 boards
Any guidance, code snippets, or references to similar projects would be greatly appreciated! I’m particularly interested in practical steps to get TX/RX working and debug any issues. Thanks in advance for your help!
Best regards,
Tanuj Soni