Hi, Everyone
I'm trying to transmit frame on Ethernet, I made internal loop back, but i'm unable to transmit the frame. I tested both interrupt and polling. None of them worked. I'm attaching file please have a look at it and tell me whats the problem is?
Processor : MK60N512
Here is the BIT test code
uint8_t | PerformBIT_EthernetTest(void) |
{
LDD_ETH_TBufferDesc BufferDescListPtr[2]; | |
uint8* BufferListPtr[2]; | |
uint8 tx_buf[120],rx_buf[120]; | |
uint8_t dummy[100], Status = 0; | |
int i; | |
uint8_t temp[] = {"\n\r\v 3. Testing Ethernet.."}; | |
uint8_t ErrorMsg[] = {"\n\n\r\t Ethernet Test Failed"}; | |
uint32 *reg_ptr1,reg_value1; | |
BufferDescListPtr[0].DataPtr = tx_buf; | |
BufferDescListPtr[0].Size = 100; | |
BufferListPtr[0] = rx_buf; |
TxStr(temp);
tx_buf[0]=0xff; | // broad cast frame address = ff:ff:ff:ff:ff:ff | ||||||||||||
tx_buf[1]=0xff; | |||||||||||||
tx_buf[2]=0xff; | |||||||||||||
tx_buf[3]=0xff; | |||||||||||||
tx_buf[4]=0xff; | |||||||||||||
tx_buf[5]=0xff; |
tx_buf[6]=0x00; | |
tx_buf[7]=0x01; | |
tx_buf[8]=0x02; | |
tx_buf[9]=0x03; | |
tx_buf[10]=0x04; | |
tx_buf[11]=0x05; | |
for (i=12;i<100;i++) tx_buf[i]=0x55; // fill data area with 0x55 |
for (i=12;i<100;i++) rx_buf[i]=0xaa; // fill data area with 0xaa
Status=1; | |
ENET_PDD_EnableInternalLoopback(ENET_BASE_PTR, PDD_ENABLE);
ETH1_ReceiveFrame(eth_handler, BufferListPtr, 1);
eth_rx_set =0;
ETH1_SendFrame(eth_handler, BufferDescListPtr, 1);
eth_tx_set = 0;
for (i=0;i<100;i++) | |||
{ | |||
Delay(1000); | |||
if(eth_tx_set) | |||
break; | |||
} |
for (i=0;i<100;i++) | ||||
{ | ||||
Delay(1000); | ||||
if(eth_rx_set) | ||||
break; | ||||
} | ||||
if (eth_tx_set && eth_rx_set ) | ||||
{ | ||||
Status=0; | ||||
for(i=12;i<90;i++) // compare recived data |
{
if (tx_buf[i] != rx_buf[i]) | |
{ | |
Status=0; |
break;
} | |
}
} | ||
else | ||
{ | ||
Status = 1; | ||
TxStr(ErrorMsg); | ||
} | ||
return Status; |
Original Attachment has been moved to: ETH.c.zip
Original Attachment has been moved to: ENET_PDD.h.zip
I'm using Keil and PEx is there any provision to add Lwip to it? I tried 2nd Option as you said but I failed. Is there any document to getting started with 2nd option? I don't want do in KDS because I already wrote body of Project in keil. So
Thank you
Trilok
Hi Trilok
You can download examples in Keil, search Kinetis Expert in the web, after that log in and select the option "Build an SDK". See the picture below
Select the board that you are using and name the configuration
Write a Package name SDK version 1.3 and then choose Keil MDK in Supported toolchain, with the host that you are working. Be sure to mark the FreeRTOS option.
Click Build SDK Package and select "software vault" to see the download process. I recommended to you, take a look lwip examples.
Hope it helps
Mario
Hi Trilok
It seems to me you are sending Raw Ethernet frames, unfortunately we don’t have examples, but if you want to take a look to the KQRUG, it shows an initialization code example for ENET Module.
http://www.nxp.com/files/32bit/doc/quick_ref_guide/KQRUG.pdf
However, due to complexity of the Ethernet protocol, I recommend you to use a Multi Layered Software Architecture and a TCP/IP stack. The OSI model and the TCP/IP model are the most popular multilayer communication models.
The next image shows you the layers the TCP communication model.
According to the image above, when sending an Ethernet packet the data is generated in the application layer, then Transport Layer protocol header (TCP in this case) is concatenated to the payload, this header contains tracking transmitted data segments, ACK received, unacknowledged data and connection ports, then another header for the Network layer is added including Time to live, source IP and destination IP address. At the end the MCU creates the Ethernet Header containing preamble, source and destination MAC address, and with all that information calculates the Checksum and send the packet.
When receiving data the MCU checks the FCS, then IP header is decoupled and destination IP is compared to evaluate if it belongs to this device, if it doesn´t then the entire frame is ignored. After this the network layer header (TCP in this case) is decoupled and the connection port is checked, the last layer decouples the application header if it exists and gets the payload.
If you try to send Ethernet data without TCP/IP stack, you have to create all the headers each layer one by one manually and it might be complicated.
On the other hand a TCP/IP stack will create all the headers like TCP, IP and you only have to provide the data, and when you are receiving data, a TCP/IP stack will process the headers and give you the payload without all the headers. This is why it is strongly recommended to use a TCP/IP stack, as it makes all that process, and the user can only focus in the application.
NXP provides different tools with TCP/IP Stacks:
-MQX4.2 with RTCS
-KSDK2.0 with lwIP
RTCS TCP/IP Stack in MQX 4.2
RTCS provides a rich assortment of TCP/IP networking application protocols and uses the NXP MQX RTOS drivers for Ethernet and serial connectivity.
For stating with MQX go to www.nxp.com/mqx
Once you install MQX you will find different examples using RTCS, you can follow the next path: C:\Freescale\Freescale_MQX_4_2\rtcs\examples
Note: RTCS is no longer supported in SDK2.0
Lightweight TCP/IP (lwIP) Stack in Kinetis SDK
NXP provides a software development kit for Kinetis MCUs that includes system startup, peripheral drivers, USB and connectivity stacks, middleware, and real-time operating system (RTOS) kernels. The Kinetis SDK also includes getting started and API documentation along with usage examples and demo applications
For starting with KSDK follow this link https://community.freescale.com/docs/DOC-329662
The TCP/IP stack provided in KSDK is Lightweight IP (lwIP), it also provides several protocols and you could check next path for examples using lwIP:
C:\Freescale\SDK_2.0\boards\K60D100M\demo_apps\lwIP
If you are getting stated with this TCP/IP stack. The next document is a guide on how to reproduce this example as a standalone project.
https://community.freescale.com/docs/DOC-252874
As a side comment, please note that the K60DN512 is the first silicon version of K60 and it is no longer manufactured. For new designs it is strongly recommended to use a second version like K60D100M,
Let me know if you have any question.
Regards,
Mario
Hi Mario,
I have a similar problem. I need to create two communications (UDP and TCP/IP). I am sending commands with parameters in TCP/IP and UDP, and I need to receive commands in TCP/IP. The problem is that I need and interrupt of flag that tell me that there is a message to process. I'm working with tasks. So, I don't know how to do it in MQX and RTCS. I saw that there is the tcp.h, ip.h and udp.h, but I didn't find how to add Data to the datagram. :smileysad:
Hi
There are 3 important point to be clear
-PEx Processor Expert
-TCP/IP stack
-IDE
PEx is a development system to create, configure, software components that generate source code, for ENET, it can provide initialization examples, and creates a simple driver, but this option is the same problem, you have to create the headers manually, PE doesn´t provides a TCP/IP stack.
Unfortunately we don´t have a solution with this features, PEx + TCP/IP stack + KEIL.
Other options could be
Best Regards
Mario