STM32F107+LAN8720调试问题

2019-08-18 21:19发布

    我使用的是STM32F107RC+LAN8720,具体电路参考的原子STM32F407+LAN8720A,电路如下:其中的ETH_RESET我直接接的地。
主要代码如下,  PHY_address也设置了为1.现在插上网线灯也不亮,读取网卡寄存器都是FFFF。现在也不知道是硬件还是软件问题。[mw_shl_code=c,true]#include "stm32f10x_conf.h"
#include "EthInit.h"
#include "stm32_eth.h"
#define PHY_ADDRESS     1
void ETHDriverInit(void)
{
        RCC_AHBPeriphClockCmd(RCC_AHBPeriph_ETH_MAC | RCC_AHBPeriph_ETH_MAC_Tx |
                        RCC_AHBPeriph_ETH_MAC_Rx, ENABLE);
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC |
                        RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO |
                            RCC_APB2Periph_ADC1, ENABLE);
        NVIC_Configuration();
        GPIO_Configuration();
        GPIO_SetBits(GPIOE,GPIO_Pin_6);

        GPIO_ResetBits(GPIOE,GPIO_Pin_6);
               
        GPIO_SetBits(GPIOE,GPIO_Pin_6);        
        Ethernet_Configuration();

}
void NVIC_Configuration(void)
{
  NVIC_InitTypeDef   NVIC_InitStructure;

  /* Set the Vector Table base location at 0x08000000 */
  NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);

  /* 2 bit for pre-emption priority, 2 bits for subpriority */
  NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
  
  /* Enable the Ethernet global Interrupt */
  NVIC_InitStructure.NVIC_IRQChannel = ETH_IRQn;
  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 2;
  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
  NVIC_Init(&NVIC_InitStructure);   
  
}
void GPIO_Configuration(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;


  /* Configure PA2 as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

  /* Configure PC1, PC2 and PC3 as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;  //PC2óÃ2»μ½£¬Îaê2Ã′é¾3y¾í2»ÄüÔËDDáË£¿
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOC, &GPIO_InitStructure);

  /* Configure PB5, PB8, PB11, PB12 and PB13 as alternate function push-pull */  //PB8óÃ2»μ½£¬Îaê2Ã′é¾3y¾í2»ÄüÔËDDáË£¿
  GPIO_InitStructure.GPIO_Pin =  GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOB, &GPIO_InitStructure);

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_7;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4|GPIO_Pin_5;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOC, &GPIO_InitStructure);





  
}
void Ethernet_Configuration(void)
{
  ETH_InitTypeDef ETH_InitStructure;

  /* MII/RMII Media interface selection ------------------------------------------*/




  GPIO_ETH_MediaInterfaceConfig(GPIO_ETH_MediaInterface_RMII);

  ETH_DeInit();

  /* Software reset */
  ETH_SoftwareReset();

  /* Wait for software reset */
  while (ETH_GetSoftwareResetStatus() == SET);

  /* ETHERNET Configuration ------------------------------------------------------*/
  /* Call ETH_StructInit if you don't like to configure all ETH_InitStructure parameter */
  ETH_StructInit(D_InitStructure);

  /* Fill ETH_InitStructure parametrs */
  /*------------------------   MAC   -----------------------------------*/
  ETH_InitStructure.ETH_AutoNegotiation = ETH_AutoNegotiation_Enable  ;        //êÇ·ñê1óÃíaÖ&#195HY
  ETH_InitStructure.ETH_LoopbackMode = ETH_LoopbackMode_Disable;
  ETH_InitStructure.ETH_RetryTransmission = ETH_RetryTransmission_Disable;
  ETH_InitStructure.ETH_AutomaticPadCRCStrip = ETH_AutomaticPadCRCStrip_Disable;
  ETH_InitStructure.ETH_ReceiveAll = ETH_ReceiveAll_Disable;
  ETH_InitStructure.ETH_BroadcastFramesReception = ETH_BroadcastFramesReception_Enable;
  ETH_InitStructure.ETH_PromiscuousMode = ETH_PromiscuousMode_Disable;
  ETH_InitStructure.ETH_MulticastFramesFilter = ETH_MulticastFramesFilter_Perfect;
  ETH_InitStructure.ETH_UnicastFramesFilter = ETH_UnicastFramesFilter_Perfect;



  /* Configure Ethernet */
  ETH_Init(D_InitStructure, PHY_ADDRESS);
  

  /* Enable the Ethernet Rx Interrupt */
  ETH_DMAITConfig(ETH_DMA_IT_NIS | ETH_DMA_IT_R, ENABLE);

}



[/mw_shl_code]


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
11条回答
dsf1412
1楼-- · 2019-08-19 00:52
哪位大神帮忙看下,我是按照STM32F4的改过来的
dsf1412
2楼-- · 2019-08-19 02:36
augustedward
3楼-- · 2019-08-19 05:04
芯片中间的地接了没?107与F4的驱动差别不大,好像只用修改DMA部分东西。
taizonglai
4楼-- · 2019-08-19 08:14
检查REF_CLK有没有50M时钟信号出来,还有LAN8720的25M晶振有没有起震
dsf1412
5楼-- · 2019-08-19 12:16
 精彩回答 2  元偷偷看……
dsf1412
6楼-- · 2019-08-19 18:03
augustedward 发表于 2017-3-3 09:34
芯片中间的地接了没?107与F4的驱动差别不大,好像只用修改DMA部分东西。

哥们  F4的网口用的是什么?   我这儿用的是HR901105C   网口会有影响吗

一周热门 更多>