Chinaunix首页 | 论坛 | 博客
  • 博客访问: 30103280
  • 博文数量: 230
  • 博客积分: 2868
  • 博客等级: 少校
  • 技术积分: 2223
  • 用 户 组: 普通用户
  • 注册时间: 2009-10-08 21:48
个人简介

Live & Learn

文章分类

全部博文(230)

文章存档

2022年(2)

2019年(5)

2018年(15)

2017年(42)

2016年(24)

2015年(13)

2014年(1)

2012年(5)

2011年(58)

2010年(56)

2009年(9)

我的朋友

分类: 嵌入式

2010-10-29 09:20:21

9G-STM32 LwIP测试过程简介
一,准备STM32 LwIP软件
1,在http://www.st.com/mcu/devicedocs-STM32F107RC-110.html
    下载lwIP TCP/IP stack demonstration for STM32F107xx connectivity line microcontrollers软件包
    an3102.zip
   
   
2,在http://www.st.com/mcu/devicedocs-STM32F107RC-110.html
    下载lwIP TCP/IP stack demonstration for STM32F107xx connectivity line microcontrollers文档
16620.pdf


3,有关STM32F107VC-PKT的PCB和SCH和测试代码见下面连接:
http://www.freescaleic.org/yuanxihua/blog/10-01/183297_155bc.html

二,建立STM32 LwIP开发工程
1,把an3102.zip解压到D:\works形成工程文件夹:D:\works\STM32F107_ETH_LwIP_V1.0.0 ;
2,进入到目录D:\works\STM32F107_ETH_LwIP_V1.0.0\Project\EWARMv5,双击Project.eww打开工程;
3,在EWARM中的Project->make 编译通过整个项目
三,修改STM32 LwIP开发工程
1,打开Project->Options ,在Category中选择Debugger的setup驱动用J-Link/J-Trace,在J-Link/J-Trace
中选择connection的SWD接口;
2,对STM32F107VC-PKT开发板加上5V的直流电源,把J-LINK用USB线连接到PC的USB口上,执行Project->Download and Debug
下载代码到板子后,执行Debug->Go 。

四,修改STM32 LwIP开发源码
1,在D:\works\STM32F107_ETH_LwIP_V1.0.0\Project\src\main.c 的53行后添加如下代码:
   /* Output a message on Hyperterminal using printf function */
   printf("\n\r\n\r\n\r\n\r");
   printf("*** STM32F107VC-PKT V1.0 Build by on ("__DATE__ " - " __TIME__ ")\n\r");
   printf("*** STM32F107VC-PKT V1.0 Rebooting ...\n\r");
2,在D:\works\STM32F107_ETH_LwIP_V1.0.0\Project\src\stm32f107.c 的包含头文件中添加:
   #include "stdio.h"
   
在第30行选择用MII模式
#define MII_MODE          /* MII mode for STM3210C-EVAL Board (MB784) (check jumpers setting) */
//#define RMII_MODE       /* RMII mode for STM3210C-EVAL Board (MB784) (check jumpers setting) */

在54行后添加:
USART_InitTypeDef USART_InitStructure;

在125行后添加:
   
   /* Configure the com port */
   /* USARTx configuration ------------------------------------------------------*/
   /* USARTx configured as follow:
         - BaudRate = 115200 baud  
         - Word Length = 8 Bits
         - One Stop Bit
         - No parity
         - Hardware flow control disabled (RTS and CTS signals)
         - Receive and transmit enabled
   */
   USART_InitStructure.USART_BaudRate = 115200;
   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;

   STM_EVAL_COMInit(COM1, &USART_InitStructure);
}

/**
   * @brief  Retargets the C library printf function to the USART.
   * @param  None
   * @retval : None
   */
int fputc(int ch, FILE *f)
{
   /* Write a character to the USART */
   USART_SendData(USART2, (uint8_t) ch);

   /* Loop until the end of transmission */
   while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET)
   {
   }

   return ch;
}
/**
   * @brief  Get a key from the HyperTerminal
   * @param  None
   * @retval : The Key Pressed
   */
int fgetc(FILE *f)
{
  /* Waiting for user input */
  while ( USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET);
  return (uint8_t)USART2->DR;

在341-344行修改为:
   /* ADC Channel10 config --------------------------------------------------------*/
   /* Relative to STM32F107VC-PKT Board   */
   /* Configure PC.00 (ADC Channel10) as analog input -------------------------*/
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
  
在375-376行修改为:
/* ADC1 regular channel10 configuration */
ADC_RegularChannelConfig(ADC1, ADC_Channel_10, 1, ADC_SampleTime_13Cycles5);
  
3,在D:\works\STM32F107_ETH_LwIP_V1.0.0\Project\src\netconf.c 中的119-121行和316-318行把
IP地址都修改如下:
   IP4_ADDR(&ipaddr, 192, 168, 1, 8);
   IP4_ADDR(&netmask, 255, 255, 255, 0);
   IP4_ADDR(&gw, 192, 168, 1, 1);
4,在D:\works\STM32F107_ETH_LwIP_V1.0.0\Utilities\lwip-1.3.1\port\lwipopts.h中把
#define LWIP_DHCP               1
修改成:
#define LWIP_DHCP               0

5,在D:\works\STM32F107_ETH_LwIP_V1.0.0\Utilities\STM32_EVAL\STM3210C_EVAL\stm3210c_eval.h中把
#define LED1_GPIO_PIN               GPIO_Pin_7
修改成:
#define LED1_GPIO_PIN               GPIO_Pin_13

#define LED2_GPIO_PIN               GPIO_Pin_13
修改成:
#define LED2_GPIO_PIN               GPIO_Pin_14

#define LED3_GPIO_PIN               GPIO_Pin_3
修改成:
#define LED3_GPIO_PIN               GPIO_Pin_15


#define COMn                        1
修改成
#define COMn                        2

6,同样执行Project->Download and Debug 下载代码到板子后,执行Debug->Go 可以全速仿真运行。
五,演示STM32 LwIP开发工程
1,用交叉网线连接STM32F107VC-PKT到PC的网口,用交叉串口线连接RS232到PC的串口中,再对板子用5V上电
复位启动工作;
2,可以在串口终端上用115200 8N1的格式看到:
*** STM32F107VC-PKT V1.0 Build by on (Jan 12 2010 - 12:43:08)
*** STM32F107VC-PKT V1.0 Rebooting ...
3,在PC的IE浏览器中输入: 回车刷新可以访问到板子,看到Home page主页:
STM32F107 Webserver Demo
Based on the lwIP TCP/IP stack
4,点击Led control从Home page切换LED控制,任意勾上或者去掉LED1-3,再按SEND,可以看到板子的LED相应的
被控制亮或者灭;
5,点击ADC status bar从Led control页面切换到ADC采集,旋转板子上的RV1,可以看到STM32F107 ADC status bar
上绿色的滚动条被ADC的输入电压控制增减;
6,在SecureCRT 5.1终端中可以以telnet协议访问192.168.1.8,端口就是23,连接上了会显示:
Hello. What is your name? ,输入字符串YUANXIHUA,马上会回复Hello YUANXIHUA
阅读(13609) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~