Board logo

标题: 9G-STM32 MDK-ARM开发过程简介(2) [打印本页]

作者: yuyang911220    时间: 2014-11-25 12:32     标题: 9G-STM32 MDK-ARM开发过程简介(2)

三,配置STM32工程
在Keil uVision3的左面“Workspace”窗口下面的“EK-STM3210E”右击鼠标,选择“Options for Target "EK-STM3210E"”窗口;
1,在页面“Device”中选择上“STMicroelectronics”下面的STM32F103ZD”,
在页面“TarGet”中选择上“USE microLIB”;
2,在页面“Output”中选择上“Select Folder for Objects...”,在文件夹选择框中指定到路径:
D:\works\EK-STM3210E-MDK\Project\Stm32f103\obj 后点击“OK”;并勾选上Create HEX File,
产生“Debug information”浏览“Browse information”;
3,在页面“Listing”中选择上“Select Folder for Listing...”,在文件夹选择框中指定到路径:
D:\works\EK-STM3210E-MDK\Project\Stm32f103\lst 后点击“OK”;并勾选上C Compiler Listing
和 C Preprocessor Listing (看看自己是否需要);

4,在页面“C/C++”中的“Include Paths ”,中添加:
..\..\Libraries\STM32F10x_StdPeriph_Driver\inc
..\..\Libraries\CMSIS\Core\CM3
..\..\Include
在页面“C/C++”中的“Preprocessor Symbols”,中添加:
USE_STDPERIPH_DRIVER, USE_FULL_ASSERT, STM32F10X_HD,USE_STM3210C_EVAL
5,在页面“ASM”中的“Include Paths ”,中添加:
..\..\Libraries\STM32F10x_StdPeriph_Driver\inc
..\..\Libraries\CMSIS\Core\CM3
..\..\Include
在页面“ASM”中的“Preprocessor Symbols”,中添加:
USE_STDPERIPH_DRIVER, USE_FULL_ASSERT, STM32F10X_HD,USE_STM3210C_EVAL6,在页面“Debug”中选择右边的硬件仿真功能的“Cortex-M3 J-LINK”,并点开右面的“Settings”配置页面,选择SW接口并把速度改成2M;
在“Flash Download”的编程算法选择上“STM32F10x High-density Flash”;
7,在页面“Utlites”中硬件FLASH编程工具“Cortex-M3 J-LINK”,并点开右面的“Settings”配置页面,选择SW接口并把速度改成2M;
在“Flash Download”的编程算法选择上“STM32F10x High-density Flash”;

四,修改STM32工程
(待续)

附件:
1,serial.c 文件
/* Includes ------------------------------------------------------------------*/
#include "stm32f10x.h"
#include "stm32f10x_conf.h"
#include
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
USART_InitTypeDef USART_InitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
void UART_Configuration(void)
{
/* Enable USART1 clocks */
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_USART1, ENABLE);
  /* Configure USART1_Tx as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* Configure USART1_Rx as input floating */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
  GPIO_Init(GPIOA, &GPIO_InitStructure);
  /* 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);
  /* Configure the USARTx */
  USART_Init(USART1, &USART_InitStructure);
  /* Enable the USARTx */
  USART_Cmd(USART1, ENABLE);
}




欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) Powered by Discuz! 7.0.0