STM32F4 LAN8720 and LWIP porting and debugging records (2)

Publisher:云自南国来Latest update time:2018-04-22 Source: eefocusKeywords:STM32F4  LAN8720  LWIP Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

background

After the hardware engineer completed the PCB and schematic design, the routine was modified according to the tutorial of Zhengdian Atom to verify the correctness of the hardware. 
STM32F407 and LAN8720 debugging records . 
Zhengdian Atom network communication experiment

The next step is to implement the function on the product board. 
The original product uses the W5500 hard TCP/IP protocol solution. 
The debugging route attempts to start with UDP loopback.

In the introduction of ICMP protocol 
, you can see that the protocol points out that the error type belongs to port unreachable. 
I tested it with other programs. Sure enough, when the IP of the target device is correct and there is no corresponding port on the target device, it will reply to the ICMP message. 
It can be seen that the problem lies in the port initialization.

3. Factory routine test

I had no choice but to compare it with the original routine of Atom. It can send messages and receive messages normally. 
During the test, I accidentally intercepted such a message: 
Message screenshot 
It can be observed that only when the source address and the destination address are both 8089, ICMP will not return an error message. 
When either of the two is not 8089, an error will be reported. 
Going back to check the code carefully, there are indeed two places where UDP_DEMO_PORT is used. 
They are

err = udp_connect(udppcb, &rmtipaddr, UDP_DEMO_PORT);

and

err = udp_bind(udppcb, IP_ADDR_ANY, UDP_DEMO_PORT);

One is bound to the local port and IP, and the other is bound to the remote device's IP and port. 

The udp_connect function has not been used before. The LWIP manual describes this function as follows: 

LwIP Application Developers Manual


Connected pcbs only receive data from the connected remote address, while unconected pcbs receive datagrams from any remote address.

Therefore, the UDP port connected will only receive packets with the bound source address and source port. 
Try to comment out the udp_connect function, and all packets can be received successfully.

Keywords:STM32F4  LAN8720  LWIP Reference address:STM32F4 LAN8720 and LWIP porting and debugging records (2)

Previous article:Analysis of STM32 network packet loss problem
Next article:Hardware connection of STM32 transplantation lwip

Recommended ReadingLatest update time:2024-11-22 20:40

STM32f4 timer interrupt experimental code
Let's take a look at our time.c file. The code of the timer.c file is as follows: //General timer 3 interrupt initialization //arr: automatic reload value. psc: clock pre-division number //Timer overflow time calculation method: Tout=((arr+1)*(psc+1))/Ft us. //Ft=timer operating frequency, unit: Mhz //Timer 3 is used
[Microcontroller]
Clock configuration problem of stm32f407 development board
To use an 8M crystal oscillator, you need to modify two macro definitions based on the official example: 1) Change PLL_M to 8 in systm_stm32f40x.c 2) Change HSE_VALUE to 8000000 in stm32f40x.h, as follows: #define USED_HSE_8M #if !defined (HSE_VALUE)  #ifdef USED_HSE_8M    #define HSE_VALUE ((uint32_t)8000000) /*! Val
[Microcontroller]
STM32F4 - Independent watchdog and window watchdog
1. Introduction:     It is used to detect and resolve faults caused by software errors. When the counter reaches the set timeout value, a system reset will occur. Its features are: 1. The clock it uses is generated by an independent RC oscillator, so it can run in standby and stop modes. 2. After the watchdog is activ
[Microcontroller]
STM32F4 - Independent watchdog and window watchdog
STM32F4_RCC system clock configuration and description
I. Overview We all know the function of the system clock, which is the heart that drives the entire chip. Without it, it is like a person without a heartbeat. For those who use the development board for learning, the knowledge of RCC system clock is probably not configured much, because the crystal oscillator provided
[Microcontroller]
STM32F4_RCC system clock configuration and description
LCD display design based on STM32F4x9, hardware design guide
With the growing demand for human-machine interface (GUI) in various application fields of medical, industrial and consumer electronics, highly integrated and high-performance TFT liquid crystal display solutions have become an important part of electronic product design and development. In the absence of a built-in l
[Microcontroller]
LCD display design based on STM32F4x9, hardware design guide
DAC of stm32f407 (operation register)
DAC The DAC embedded in Stm32f4 is a 12-bit digital input, voltage output digital-to-analog converter. The DAC can be configured in 8-bit or 12-bit mode, and can also be used in conjunction with a DMA controller. When the DAC works in 12-bit mode, the data can be set to left-aligned or right-aligned. The DAC module
[Microcontroller]
stm32f4 uses Systick to achieve delay
Using Systick timer to achieve delay 1. SysTick timer characteristics The SysTick timer is a 24-bit down counter, that is, when vlue is decremented to 0, an interrupt is triggered and the load value is reloaded, and the cycle continues. In the stm32f4 library file, the priority is set to the lowest priority by def
[Microcontroller]
Problems with floating point calculations with stm32F4
Dear experts, I am now porting a program to stm32F4. It was previously running on a PC. I chose this chip because it has an FPU. When debugging, I found many problems. In addition to setting the FPU, I found that some very simple calculations would also go wrong. I wonder if anyone has encountered the same problem? It
[Microcontroller]
Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号