[活动专区] 【AT-START-F407测评】LWIP+DP83848

[复制链接]
1502|4
 楼主| tanzhuolin 发表于 2021-2-1 11:11 | 显示全部楼层 |阅读模式
本帖最后由 tanzhuolin 于 2021-2-3 09:06 编辑

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

  4.         RCC_APB2PeriphClockCmd(RCC_APB2PERIPH_GPIOD, ENABLE);

  5.         GPIO_StructInit(&GPIO_InitStructure);
  6.         GPIO_InitStructure.GPIO_Pins = GPIO_Pins_13;
  7.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT_PP;
  8.         GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;

  9.         GPIO_ResetBits(GPIOD, GPIO_Pins_13);

  10.         GPIO_Init(GPIOD, &GPIO_InitStructure);        
  11. }


#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的测试效果如下:
2262960191ec5c474a.png

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

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

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

  9.         /* UART2 PinsRemap */
  10.         GPIO_PinsRemapConfig(GPIO_Remap_USART2, ENABLE);

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

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

  21.         /*Configure UART param*/
  22.         USART_StructInit(&USART_InitStructure);
  23.         USART_InitStructure.USART_BaudRate = bound;
  24.         USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  25.         USART_InitStructure.USART_StopBits = USART_StopBits_1;
  26.         USART_InitStructure.USART_Parity = USART_Parity_No;
  27.         USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  28.         USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;        

  29.         USART_Init(USART2, &USART_InitStructure);
  30.         //USART_INTConfig(AT32_PRINT_UART, USART_INT_RDNE, ENABLE);
  31.         USART_Cmd(USART2, ENABLE);   
  32. }


  33. int fputc(int ch, FILE *f)
  34. {
  35.         while((USART2->STS & USART_FLAG_TRAC) == 0){}        
  36.         USART2->DT = ch;
  37.         return ch;
  38. }

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 网口 速率 差不了多少,
您需要登录后才可以回帖 登录 | 注册

本版积分规则

7

主题

22

帖子

3

粉丝
快速回复 在线客服 返回列表 返回顶部