<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 9G-STM32 LwIP測試過程簡介

          9G-STM32 LwIP測試過程簡介

          作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          一,準(zhǔn)備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,有關(guān)STM32F107VC-PKT的PCB和SCH和測試代碼見下面連接:STM32F107VC_SCH.pdf
          STM32F107VC_PCB.pdfSTM32107_LK_SelfTest.zip

          本文引用地址:http://www.ex-cimer.com/article/201611/323206.htm

          二,建立STM32 LwIP開發(fā)工程

          1,把an3102.zip解壓到D:works形成工程文件夾:D:worksSTM32F107_ETH_LwIP_V1.0.0 ;

          2,進(jìn)入到目錄D:worksSTM32F107_ETH_LwIP_V1.0.0ProjectEWARMv5,雙擊Project.eww打開工程;

          3,在EWARM中的Project->make 編譯通過整個項目。

          三,修改STM32 LwIP開發(fā)工程

          1,打開Project->Options ,在Category中選擇Debugger的setup驅(qū)動用J-Link/J-Trace,在J-Link/J-Trace
          中選擇connection的SWD接口;

          2,對STM32F107VC-PKT開發(fā)板加上5V的直流電源,把J-LINK用USB線連接到PC的USB口上,執(zhí)行Project->Download and Debug
          下載代碼到板子后,執(zhí)行Debug->Go 。

          四,修改STM32 LwIP開發(fā)源碼

          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,同樣執(zhí)行Project->Download and Debug 下載代碼到板子后,執(zhí)行Debug->Go 可以全速仿真運行。

          五,演示STM32 LwIP開發(fā)工程

          1,用交叉網(wǎng)線連接STM32F107VC-PKT到PC的網(wǎng)口,用交叉串口線連接RS232到PC的串口中,再對板子用5V上電
          復(fù)位啟動工作;
          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相應(yīng)的
          被控制亮或者滅;
          5,點擊ADC status bar從Led control頁面切換到ADC采集,旋轉(zhuǎn)板子上的RV1,可以看到STM32F107 ADC status bar
          上綠色的滾動條被ADC的輸入電壓控制增減;
          6,在SecureCRT 5.1終端中可以以telnet協(xié)議訪問192.168.1.8,端口就是23,連接上了會顯示:
          Hello. What is your name? ,你輸入字符串YUANXIHUA,馬上會回復(fù)Hello YUANXIHUA



          關(guān)鍵詞: STM32LwIP測試過

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();