您的位置 首页 硬件

9G-STM32 LwIP测验进程简介

一,准备STM32LwIP软件包1,在http:wwwstcommcudevicedocs-STM32F107RC-110html下载lwIPTCPIPstackdemonstrationfor

一,预备STM32 LwIP软件包

1,在http://www.st.com/mcu/devicedocs-STM32F107RC-110.html
下载lwIP TCP/IP stack demonstration for STM32F107xx connectivity line microcontrollers软件包
an3102.zip
http://www.st.com/stonline/products/support/micro/files/an3102.zip

2,在http://www.st.com/mcu/devicedocs-STM32F107RC-110.html
下载lwIP TCP/IP stack demonstration for STM32F107xx connectivity line microcontrollers文档
16620.pdf
http://www.st.com/stonline/products/literature/an/16620.pdf

3,有关STM32F107VC-PKT的PCB和SCH和测验代码见下面衔接:STM32F107VC_SCH.pdf
STM32F107VC_PCB.pdfSTM32107_LK_SelfTest.zip

二,树立STM32 LwIP开发工程

1,把an3102.zip解压到D:works构成工程文件夹:D:worksSTM32F107_ETH_LwIP_V1.0.0 ;

2,进入到目录D:worksSTM32F107_ETH_LwIP_V1.0.0ProjectEWARMv5,双击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:worksSTM32F107_ETH_LwIP_V1.0.0Projectsrcmain.c 的53行后增加如下代码:

/* Output a message on Hyperterminal using printf function */
printf(“”);
printf(“*** STM32F107VC-PKT V1.0 Build byyuanxihua@21cn.comon (“__DATE__ ” – ” __TIME__ “)”);
printf(“*** STM32F107VC-PKT V1.0 Rebooting …”);

2,在D:worksSTM32F107_ETH_LwIP_V1.0.0Projectsrcstm32f107.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:worksSTM32F107_ETH_LwIP_V1.0.0Projectsrcetconf.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:worksSTM32F107_ETH_LwIP_V1.0.0Utilitieslwip-1.3.1portlwipopts.h中把
#define LWIP_DHCP 1
修正成:
#define LWIP_DHCP 0

5,在D:worksSTM32F107_ETH_LwIP_V1.0.0UtilitiesSTM32_EVALSTM3210C_EVALstm3210c_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 byyuanxihua@21cn.comon (Jan 12 2010 – 12:43:08)
*** STM32F107VC-PKT V1.0 Rebooting …
3,在PC的IE浏览器中输入:http://192.168.1.8/回车改写能够拜访到板子,看到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

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/qianrushi/yingjian/319306.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部