OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 3978|回复: 5

请问,lwip demo 程序 为什么lwip_comm_init()过不了?

[复制链接]

2

主题

5

帖子

0

精华

新手上路

积分
23
金钱
23
注册时间
2016-5-16
在线时间
4 小时
发表于 2016-11-10 17:23:19 | 显示全部楼层 |阅读模式
1金钱
lwip demo 程序 为什么lwip_comm_init()过不了?
谢谢解答,多谢!

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

88

主题

7377

帖子

5

精华

资深版主

Rank: 8Rank: 8

积分
14980
金钱
14980
注册时间
2013-11-13
在线时间
1823 小时
发表于 2016-11-10 17:24:20 | 显示全部楼层
一步一步的硬件调试,看看是卡到哪里了?
回复

使用道具 举报

2

主题

5

帖子

0

精华

新手上路

积分
23
金钱
23
注册时间
2016-5-16
在线时间
4 小时
 楼主| 发表于 2016-11-10 18:06:55 | 显示全部楼层
/**
  * @brief  Read a PHY register
  * @param PHYAddress: PHY device address, is the index of one of supported 32 PHY devices.
  *   This parameter can be one of the following values: 0,..,31                  
  * @param PHYReg: PHY register address, is the index of one of the 32 PHY register.
  *   This parameter can be one of the following values:
  *     @arg PHY_BCR: Transceiver Basic Control Register
  *     @arg PHY_BSR: Transceiver Basic Status Register
  *     @arg PHY_SR : Transceiver Status Register   
  *     @arg More PHY register could be read depending on the used PHY
  * @retval ETH_ERROR: in case of timeout
  *         MAC MIIDR register value: Data read from the selected PHY register (correct read )
  */
uint16_t ETH_ReadPHYRegister(uint16_t PHYAddress, uint16_t PHYReg)
{
  uint32_t tmpreg = 0;     
__IO uint32_t timeout = 0;
  /* Check the parameters */
  assert_param(IS_ETH_PHY_ADDRESS(PHYAddress));
  assert_param(IS_ETH_PHY_REG(PHYReg));
  
  /* Get the ETHERNET MACMIIAR value */
  tmpreg = ETH->MACMIIAR;
  /* Keep only the CSR Clock Range CR[2:0] bits value */
  tmpreg &= ~MACMIIAR_CR_MASK;
  /* Prepare the MII address register value */
  tmpreg |=(((uint32_t)PHYAddress<<11) & ETH_MACMIIAR_PA); /* Set the PHY device address */
  tmpreg |=(((uint32_t)PHYReg<<6) & ETH_MACMIIAR_MR);      /* Set the PHY register address */
  tmpreg &= ~ETH_MACMIIAR_MW;                              /* Set the read mode */
  tmpreg |= ETH_MACMIIAR_MB;                               /* Set the MII Busy bit */
  /* Write the result value into the MII Address register */
  ETH->MACMIIAR = tmpreg;
  /* Check for the Busy flag */
  do
  {
    timeout++;
    tmpreg = ETH->MACMIIAR;
  } while ((tmpreg & ETH_MACMIIAR_MB) && (timeout < (uint32_t)PHY_READ_TO));
  /* Return ERROR in case of timeout */
  if(timeout == PHY_READ_TO)
  {
    return (uint16_t)ETH_ERROR;
  }
  
  /* Return data register value */
  return (uint16_t)(ETH->MACMIIDR);
}
回复

使用道具 举报

2

主题

5

帖子

0

精华

新手上路

积分
23
金钱
23
注册时间
2016-5-16
在线时间
4 小时
 楼主| 发表于 2016-11-10 18:11:28 | 显示全部楼层
PHYAddress 传入参数从0x00 改为0x01 后,初始化成功。
有朋友能解答一下吗?
谢谢!
回复

使用道具 举报

11

主题

49

帖子

0

精华

新手上路

积分
25
金钱
25
注册时间
2016-8-24
在线时间
65 小时
发表于 2016-11-10 18:41:07 | 显示全部楼层
你下载到硬件里,然后一步步调试,按F10,看卡在哪个函数那了。就好找下一步的错误了。。
回复

使用道具 举报

7

主题

58

帖子

0

精华

初级会员

Rank: 2

积分
194
金钱
194
注册时间
2016-10-11
在线时间
43 小时
发表于 2016-11-11 11:02:45 | 显示全部楼层
你用的什么板子,,原因有2个。。第一个是静态id 还是动态的ID,,,宏定义#define LWIP_DHCP 必须置1    第二个就是板子的硬件,,,,你用的什么网络接口,enc28j60还是其他,,,在看看spi初始化引脚配制
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-4-9 01:45

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表