Ethernet Receiving frame Problem in MK66.,

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Ethernet Receiving frame Problem in MK66.,

1,546 Views
karthikas
Contributor IV

I am using  MK66FN2M0VLQ18 MCU in our customized board.

 

In SDK_2.0_MK66FN2M0xxx18 stack I am using LWIP_ping example. As our Ethernet Phy is hardware confiured, I removed all PHY initialization part existing in the stack.

Now I can able to get Ethernet interface and also I am sending UDP packet from board to PC. I am using send function as fallows .

>>         form_UDP_Packet(send_buf,send_buf,8+Length);
>>         error = ENET_SendFrame(ENET,handle,send_buf,168);

To form UDP frame I am using my own routines. The send function is working fine and I am getting UDP packet in PC(observed using Wireshark Ethernet tool). 

similarly How do I implement Receive function.?? 

I tried to receive the packet using available routines in stack as fallows 

>>     error = ENET_GetRxFrameSize(handle, &length);
>>      error = ENET_ReadFrame(ENET, handle,Rx_buf,length);

But its not working.

 

Can anyone help me to implement receive function, also how do I use those Receive functions available.??

 

Thank you .,

 

Best Regards 

Karthik..

Labels (1)
4 Replies

1,079 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I do not know if you have seen the ethernet example in SDK2.0, located in:

C:\Freescale\SDK2.0_FRDM_K64F\boards\frdmk64f\driver_examples\enet\txrx_transfer

If you use the example to develop your code, can you check if the ethernet module have received frame or not by checking the received frame.

The received frame is pointed by Rx data buffer pointer.

you can access the the Rx data buffer pointer with the structure:

  [ENET_RDSR]->RxBD->Rx data buffer pointer

Hope it can help you

BR

Xiangjun Rong

1,079 Views
karthikas
Contributor IV

Hai xiangjun.rong.,

Since one week I stuck on this issue, i would expecting a response from your side.

The UDP_echo example is working perfectly. I removed the echo init function so that I can stop UDP echo functionalities. 

Now I am trying to send some data from board 

/*******************************************************************************************************/

u8_t temp[] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};

pcb = udp_new();
if (pcb == NULL) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_new failed!\n"));
}
if (udp_bind(pcb, IP_ADDR_ANY, 0x0007) != ERR_OK) {
LWIP_DEBUGF(UDP_DEBUG, ("udp_bind failed!\n"));
}
p = pbuf_alloc (PBUF_TRANSPORT, 8, PBUF_RAM);
p->flags = 0; p->len = 20; p->next = NULL ; p->payload = temp;  p->ref = 0x01;  p->tot_len = 20;  p->type = 0x03;
IP4_ADDR(&ipaddr, 192,168,16,100);

err = udp_sendto(pcb, p, &ipaddr, 0xd710);
pbuf_free(p);

/**********************************************************************************************************/

The UDP packet is sending . But after returning from "udp_sendto" function its going to Hard fault handler. 

Can you please point out me where I did mistake.

Thank you .,

Best Regards.,

karthik.

0 Kudos
Reply

1,079 Views
manfredschnell
Contributor IV

Hi karthik,

I think, you are allocating 8 bytes to send.

p = pbuf_alloc (PBUF_TRANSPORT, 8, PBUF_RAM);

you should allocate the full memory for your payload.

--> p = pbuf_alloc (PBUF_TRANSPORT, sizeof(temp /* your payload*/), PBUF_RAM);

      if (p == NULL) { error_trap(); }

 

after that, you should put your payload into packet.

--> memcpy(p->payload, temp, sizeof(temp));

I wouldn't touch any of the internal flags and references.

Then .. send it.

IP4_ADDR(&ipaddr, 192,168,16,100); 
err = udp_sendto(pcb, p, &ipaddr, 0xd710 /*Destination port*/);
pbuf_free(p);

Best regards

Manfred

0 Kudos
Reply

1,079 Views
karthikas
Contributor IV

Hai.,

Thank you for the help.

I am using UDP_echo example, located in:

C:\Users\Sigma\Desktop\SDK_2.0_MK66FN2M0xxx18\boards\frdmk66f\demo_apps\lwip\lwip_udpecho

The Echo example is working , and I am getting back UDP packet whatever I sent from PC. 

Now I wanted to modify  like the board should not echo UDP packet back, instead I need to receive UDP packet from PC and process the data and then I need to send our own data(UDP packet) to PC(To same IP and PORT address from which I got data).

I removed fallowing function in udp_echo_recv function,So that echo has stopped.

/* send received packet back to sender */
udp_sendto(pcb, p, addr, port);   

Now how send to udp packet to the PC.? 

Thank you.,

Regards 

Karthik

0 Kudos
Reply