请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。
部件号:LAUNCHXL2-570LC43 Thread 中讨论的其他器件:TMS570LC4357、 HALCOGEN
工具/软件:
我有两个 TMS570LC4357 Launchpad、我想执行这两个 TMS570LC4357 Launchpad 之间的 EMAC 通信。 我使用了与 EMAC_Loopback 示例相同的 HalCOGen 配置、但我已禁用环回并更改了两个 LaunchPad 的 MAC 地址。 问题是、当我从一个 LaunchPad 发送并监测 TXGOODFRAMES 寄存器时、我得到0000000、我认为这不是预期结果。 问题出在哪里? 下面是变速箱的代码。
#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] = {0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU, 0xFFU}; // 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;
uint8 c = 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
{
c = 9;
}
}
}