嵌入式技术论坛
直播中

ss

8年用户 8762经验值
擅长:电源/新能源 制造/封装 RF/无线
私信 关注
[问答]

LAN8720A无法接收数据是为什么?怎么解决?

  1.环境使用RT-Studio创建的标准F2工程,已经修改了HSE时钟。
  RT版本:4.0.3
  STM32CubeMX版本6.4
  编译不通过,提示重复定义的PHY_FULL_DUPLEX
  修改PHY_FULL_DUPLEX的名称为EPHY_FULL_DUPLEX
  编译通过,但是不知道为啥
  2.phy_reset.c如下
#include "board.h"
#include "drv_common.h"
#include
#define RESET_IO GET_PIN(A,3)
void phy_reset(void){
    rt_pin_write(RESET_IO, PIN_LOW);
    rt_thread_mdelay(50);
    rt_pin_write(RESET_IO, PIN_HIGH);
}
int phy_init(void){
    rt_pin_mode(RESET_IO, PIN_MODE_OUTPUT);
    rt_pin_write(RESET_IO, PIN_HIGH);
    return RT_EOK;
}
INIT_APP_EXPORT(phy_init);
开打 #define DRV_DEBUG 日志如下
[I/sal.skt] Socket Abstraction Layer initialize success.
msh >[D/drv.emac] Found a phy, address:0x00
[D/drv.emac] RESET PHY!
[D/drv.emac] phy basic status reg is 0x7829
[D/drv.emac] phy control status reg is 0x1058
[D/drv.emac] link up
[D/drv.emac] 100Mbps
[D/drv.emac] full-duplex
[D/drv.emac] transmit frame length :42
[D/drv.emac] receive frame faild
[D/drv.emac] phy basic status reg is 0x782D
[D/drv.emac] phy control status reg is 0x1058
[D/drv.emac] phy basic status reg is 0x782D
定位到
  /* Get received frame */
    state = HAL_ETH_GetReceivedFrame_IT(&EthHandle);
    if (state != HAL_OK)
    {
        LOG_D("receive frame faild");
        return NULL;
    }
HAL_ETH_GetReceivedFrame_IT(&EthHandle); 返回了 HAL_ERROR
  /* Scan descriptors owned by CPU */
  while (((heth->RxDesc->Status & ETH_DMARXDESC_OWN) == (uint32_t)RESET) && (descriptorscancounter < ETH_RXBUFNB))
这个条件没有过,
请问有解决的方法么?
芯片是STM32F207ZET6,原理图如下

STM32 F4的寄存器状态

STM32 F2的寄存器状态


STM32F2的 OWM bit 是SET 的状态。其他位好像都是无效的
OWN: Own bit
When set, this bit indicates that the descriptor is owned by the DMA. When this bit is reset, it
indicates that the descriptor is owned by the CPU. The DMA clears this bit either when it
completes the frame transmission or when the buffers allocated in the descriptor are read
completely. The ownership bit of the frame’s first descriptor must be set after all subsequent
descriptors belonging to the same frame have been set.
这个是用STM32 ( 192.168.1.10) ping 电脑主机的IP( 192.168.1.23)

电脑回复了,但是32 一直无法收到

回帖(2)

ss

2022-3-16 09:35:18
rt-thread.map 文件中的ETH dma 地址映射

.bss.DMARxDscrTab

                0x2000245c        0x4 ./drivers/drv_eth.o

.bss.DMATxDscrTab

                0x20002460        0x4 ./drivers/drv_eth.o

.bss.Rx_Buff   0x20002464        0x4 ./drivers/drv_eth.o

.bss.Tx_Buff   0x20002468        0x4 ./drivers/drv_eth.o

.bss.EthHandle

                0x2000246c       0x48 ./drivers/drv_eth.o

.bss.stm32_eth_device

                0x200024b4       0x84 ./drivers/drv_eth.o

@cuphead 这边eth dma 的配置是在哪里看参考资料捏,我怎么看 F4 的eth dma地址映射也差不多的样子?

.bss.DMARxDscrTab

                0x200028d0        0x4 ./drivers/drv_eth.o

.bss.DMATxDscrTab

                0x200028d4        0x4 ./drivers/drv_eth.o

.bss.Rx_Buff   0x200028d8        0x4 ./drivers/drv_eth.o

.bss.Tx_Buff   0x200028dc        0x4 ./drivers/drv_eth.o

.bss.EthHandle

                0x200028e0       0x48 ./drivers/drv_eth.o

.bss.stm32_eth_device

                0x20002928       0x84 ./drivers/drv_eth.o
举报

ss

2022-3-16 09:35:44
简单一点,OWN为1就说明此时EMAC还没收到包。
可能原因:
包没到PHY,网络接收有问题(协商速率时要用到,可以排除)
包没到EMAC,MII/RMII的接收有问题,如IO配置,映射不对,或虚焊短路。
包到了EMAC但过滤掉了,检查EMAC配置和MAC地址。或是包校验不过。
你板子的IP是静态还是DHCP?如果是DHCP,那第1,2条都可以排除。第3条可以把过滤器那里接收所有包这个位打开,这样所有包都能进来。
举报

更多回帖

发帖
×
20
完善资料,
赚取积分