UART changes Ethernet behaviour

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

UART changes Ethernet behaviour

跳至解决方案
618 次查看
giusloq
Contributor III

I have a project that runs on a custom LPC1768 board. The project uses Ethernet (with lwip in NO_SYS=1 mode) and UART for debug.

It works well many times. However I noticed a strange relation between UART and Ethernet.

Normally I can communicate with a server (MQTT over TLS). I can see frames/packets out and in and the communication is ok.

When I add some debug output in LPC Ethernet driver (for example in low_level_output() in lpc17xx_40xx_emac.c), Ethernet works differently. It seems some incoming frames that are normally received, aren't received now.

I know it's a very big question, however what could be the relation between UART and Ethernet?

标记 (2)
0 项奖励
1 解答
562 次查看
giusloq
Contributor III

I found the problem. It's in LWIP_DEBUGF macro in lpc_low_level_output(). In my application, when a pbuf chain is passed to the function, the while loop prepare the descriptor of each fragment and increment the TxProduceIndex. When LWIP_DEBUGF is enabled and takes some time to finish (as in my case), it is possible that the first fragment is transmitted before the second descriptor is configured

Because the first fragment is configured without ENET_TCTRL_LAST flag, I think the DMA starts transmitting a second corrupted fragment.

I solved increasing TxProduceIndex after the while loop, so the descriptor are all correctly configured.

在原帖中查看解决方案

0 项奖励
1 回复
563 次查看
giusloq
Contributor III

I found the problem. It's in LWIP_DEBUGF macro in lpc_low_level_output(). In my application, when a pbuf chain is passed to the function, the while loop prepare the descriptor of each fragment and increment the TxProduceIndex. When LWIP_DEBUGF is enabled and takes some time to finish (as in my case), it is possible that the first fragment is transmitted before the second descriptor is configured

Because the first fragment is configured without ENET_TCTRL_LAST flag, I think the DMA starts transmitting a second corrupted fragment.

I solved increasing TxProduceIndex after the while loop, so the descriptor are all correctly configured.

0 项奖励