tanzhuolin 发表于 2021-2-1 11:11

【AT-START-F407测评】LWIP+DP83848

本帖最后由 tanzhuolin 于 2021-2-3 09:06 编辑

#1 点亮LED2
void LED_Init(void)
{
      GPIO_InitType GPIO_InitStructure;      

      RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOD, ENABLE);

      GPIO_StructInit(&GPIO_InitStructure);
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_13;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT_PP;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;

      GPIO_ResetBits(GPIOD, GPIO_Pins_13);

      GPIO_Init(GPIOD, &GPIO_InitStructure);      
}

#2网口测试:如果是直接使用官方的开发板,下载就能用了。我是使用自己做的主板焊接了AT32F407芯片来调试的,目前已经能够ping通了,参考的是官方的DP83848的demo,官方demo下载链接如下:
百度云链接:https://pan.baidu.com/s/1BQQz91QhJcyPF-mLMIsPJw   提取码: t3io
因为我的主板上的晶振不是8M的,因此参考了官方的文档对时钟进行了修改,文档链接:
http://www.arterytek.com/download/FAQ0093_How_to_modify_BSP_after_replacing_external_crystal_CH_V1.0.0.pdf
ping的测试效果如下:


#3串口打印测试:串口打印测试,我用的是串口2,而且需要IO重映射。ATK的库和ST的寄存器结构体的定义和很多标志的宏定义都是不一样的,因此有点不习惯,例如ST的状态寄存器是SR,ATK的是STA。ST的数据寄存器是DR,ATK的是DT。
void UART2_Init(uint32_t bound)
{
      GPIO_InitType GPIO_InitStructure;
      USART_InitType USART_InitStructure;

      /*Enable the GPIO Clock*/
      RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOD | RCC_APB2PERIPH_AFIO, ENABLE);      

      /*Enable the UART Clock*/
      RCC_APB1PeriphClockCmd(RCC_APB1PERIPH_USART2, ENABLE);

      /* UART2 PinsRemap */
      GPIO_PinsRemapConfig(GPIO_Remap_USART2, ENABLE);

      /* Configure the UART2 TX pin */
      GPIO_StructInit(&GPIO_InitStructure);
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_5;
      GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
      GPIO_Init(GPIOD, &GPIO_InitStructure);

      /* Configure the UART2 RX pin */
      GPIO_InitStructure.GPIO_Pins = GPIO_Pins_6;
      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
      GPIO_Init(GPIOD, &GPIO_InitStructure);

      /*Configure UART param*/
      USART_StructInit(&USART_InitStructure);
      USART_InitStructure.USART_BaudRate = bound;
      USART_InitStructure.USART_WordLength = USART_WordLength_8b;
      USART_InitStructure.USART_StopBits = USART_StopBits_1;
      USART_InitStructure.USART_Parity = USART_Parity_No;
      USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
      USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;      

      USART_Init(USART2, &USART_InitStructure);
      //USART_INTConfig(AT32_PRINT_UART, USART_INT_RDNE, ENABLE);
      USART_Cmd(USART2, ENABLE);   
}


int fputc(int ch, FILE *f)
{
      while((USART2->STS & USART_FLAG_TRAC) == 0){}      
      USART2->DT = ch;
      return ch;
}

jiaxinhui 发表于 2021-3-10 17:00

你好能分享一下你的程序吗? 我的板子也是AT32F407VCT6+DP83848,我用AT32F407VCT6直接焊接到107VCT6板子上,以太网程序不能直接运行,看硬件管脚好像是兼容的,估计应该是软件问题导致的。我之前的107板子的以太网接口芯片是DP83848采用RMII方式,利用CPU输出50MHZ给 DP83848提供的


chenqianqian 发表于 2021-3-11 08:19

谢谢楼主分享

看别人照片 发表于 2021-3-11 18:21

期待楼主有更好的作品,一直关注着。

li880wert 发表于 2021-3-19 15:45

感觉跑200M 和107跑72M 网口 速率 差不了多少,
页: [1]
查看完整版本: 【AT-START-F407测评】LWIP+DP83848