想问一下这是什么问题?为什么会报错,该怎么解决,刚买的屏幕想尝试一下点亮
这不是烧录,是上电检测外设硬件出错吧。买的开发板,直接找卖家,加他的学习群,提问。
extern void ETH_link_callback(struct netif* netif);
void Ethernet_Sys_Init(void)
{
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
// printf("TCP/IP initializing... \r\n");
tcpip_init(NULL, NULL);
// printf("TCP/IP initialized. \r\n");
Create_MAC(CONFIG_Table.MAC);
#if LWIP_DHCP //启用DHCP服务器 */
ipaddr.addr = 0;
netmask.addr = 0;
gw.addr = 0;
#else //启用静态IP地址
IP4_ADDR(&ipaddr, LWIP_Netcfg.ipaddr[0], LWIP_Netcfg.ipaddr[1], LWIP_Netcfg.ipaddr[2], LWIP_Netcfg.ipaddr[3]);
IP4_ADDR(&netmask, LWIP_Netcfg.netmask[0], LWIP_Netcfg.netmask[1], LWIP_Netcfg.netmask[2], LWIP_Netcfg.netmask[3]);
IP4_ADDR(&gw, LWIP_Netcfg.gateway[0], LWIP_Netcfg.gateway[1], LWIP_Netcfg.gateway[2], LWIP_Netcfg.gateway[3]);
#endif
netif_add(&stm32_netif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
netif_set_default(&stm32_netif);
#if LWIP_DHCP
dhcp_start(&stm32_netif);
#endif
netif_set_up(&stm32_netif);
// 在LWIP初始化最后面, 注册网线热插拔回调
/* Registers the default network interface.*/
netif_set_link_callback(&stm32_netif, ETH_link_callback); // 注册网线热插拔回调
}
extern void ETH_Delay(__IO uint32_t nCount);
extern struct netif stm32_netif;
// ETH_link_callback 是网线热插拔回调, 从官方工程中移植过来的, 注意将网卡地址, 寄存器号码等核对下.
void ETH_link_callback(struct netif* netif)
{
__IO uint32_t timeout = 0;
uint32_t tmpreg, RegValue;
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
if (NULL != netif) {
if (netif_is_link_up(netif)) {
/* Restart the autonegotiation */
if (ETH_InitStructure.ETH_AutoNegotiation != ETH_AutoNegotiation_Disable) {
/* Reset Timeout counter */
timeout = 0;
/* Enable Auto-Negotiation */
ETH_WritePHYRegister(LAN8720_PHY_ADDRESS, PHY_BCR, PHY_AutoNegotiation);
/* Wait until the auto-negotiation will be completed */
do {
timeout++;
} while (!(ETH_ReadPHYRegister(LAN8720_PHY_ADDRESS, PHY_BSR) & PHY_AutoNego_Complete)
&& (timeout < (uint32_t)PHY_READ_TO));
/* Reset Timeout counter */
timeout = 0;
/* Read the result of the auto-negotiation */
RegValue = ETH_ReadPHYRegister(LAN8720_PHY_ADDRESS, PHY_SR);
/* Configure the MAC with the Duplex Mode fixed by the auto-negotiation process */
if ((RegValue & PHY_DUPLEX_STATUS) != (uint32_t)RESET) {
/* Set Ethernet duplex mode to Full-duplex following the auto-negotiation */
ETH_InitStructure.ETH_Mode = ETH_Mode_FullDuplex;
} else {
/* Set Ethernet duplex mode to Half-duplex following the auto-negotiation */
ETH_InitStructure.ETH_Mode = ETH_Mode_HalfDuplex;
}
/* Configure the MAC with the speed fixed by the auto-negotiation process */
if (RegValue & PHY_SPEED_STATUS) {
/* Set Ethernet speed to 10M following the auto-negotiation */
ETH_InitStructure.ETH_Speed = ETH_Speed_10M;
} else {
/* Set Ethernet speed to 100M following the auto-negotiation */
ETH_InitStructure.ETH_Speed = ETH_Speed_100M;
}
/*------------------------ ETHERNET MACCR Re-Configuration --------------------*/
/* Get the ETHERNET MACCR value */
tmpreg = ETH->MACCR;
/* Set the FES bit according to ETH_Speed value */
/* Set the DM bit according to ETH_Mode value */
tmpreg |= (uint32_t)(ETH_InitStructure.ETH_Speed | ETH_InitStructure.ETH_Mode);
/* Write to ETHERNET MACCR */
ETH->MACCR = (uint32_t)tmpreg;
_eth_delay_(ETH_REG_WRITE_DELAY);
tmpreg = ETH->MACCR;
ETH->MACCR = tmpreg;
}
/* Restart MAC interface */
ETH_Start();
IP4_ADDR(&ipaddr, LWIP_Netcfg.ipaddr[0], LWIP_Netcfg.ipaddr[1], LWIP_Netcfg.ipaddr[2], LWIP_Netcfg.ipaddr[3]);
IP4_ADDR(&netmask, LWIP_Netcfg.netmask[0], LWIP_Netcfg.netmask[1], LWIP_Netcfg.netmask[2], LWIP_Netcfg.netmask[3]);
IP4_ADDR(&gw, LWIP_Netcfg.gateway[0], LWIP_Netcfg.gateway[1], LWIP_Netcfg.gateway[2], LWIP_Netcfg.gateway[3]);
netif_set_addr(&stm32_netif, &ipaddr, &netmask, &gw);
/* When the netif is fully configured this function must be called.*/
netif_set_up(&stm32_netif);
} else {
ETH_Stop();
/* When the netif link is down this function must be called.*/
netif_set_down(&stm32_netif);
}
}
}
开发板官方写的硬件检测程序检测到st480mc这个器件有问题,大概率是器件坏了,也有可能该模块的电路上的电容电阻有问题。
最省事的方法直接找售后,让他帮你修,如果没发找,就需要自己动手换器件了