如何跑动STM32F411RE
首先因为本地只能上内网,所以把IAR相关的软件和Licence破解之类的工具通过greenetrans传到本地,本地安装了半天。。。调试要代码吧要库吧,于是把代码打包,准备通过绿传传到本地,突然发现,被检测到是代码就给我rejected了。把代码压缩分卷成了好几份,Espace传给同事小伙伴,然后下线,在本地登陆Espace,让小伙伴再传过来。。搞定!
操作方法
- 01
先看main函数如下: 1 /** 2 * @brief Main program 3 * @param None 4 * @retval None 5 */ 6 int main(void) 7 { 8 /* STM32F4xx HAL library initialization: 9 - Configure the Flash prefetch, instruction and Data caches 10 - Configure the Systick to generate an interrupt each 1 msec 11 - Set NVIC Group Priority to 4 12 - Global MSP (MCU Support Package) initialization 13 */ 14 HAL_Init(); 15 16 /* Configure the system clock to 100 MHz */ 17 SystemClock_Config(); 18 19 /*##-1- Enable GPIOA Clock (to be able to program the configuration registers) */ 20 __HAL_RCC_GPIOA_CLK_ENABLE(); 21 22 /*##-2- Configure PA05 IO in output push-pull mode to drive external LED ###*/ 23 GPIO_InitStruct.Pin = GPIO_PIN_5; 24 GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; //推挽输出 25 GPIO_InitStruct.Pull = GPIO_NOPULL ; //默认悬空 26 GPIO_InitStruct.Speed = GPIO_SPEED_FAST; //管脚响应速度配置 27 HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 28 29 /*##-3- Toggle PA05 IO in an infinite loop #################################*/ 30 unsigned int i=0; 31 while (1) 32 { 33 ((++i)%2==0)?(HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_SET)):(HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,GPIO_PIN_RESET)); 34 //HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); 35 //HAL_GPIO_WritePin(GPIOA,GPIO_PIN_5,1); 36 /* Insert a 100ms delay */ 37 HAL_Delay(100); 38 } 39 }
- 02
1 typedef struct 2 { 3 uint32_t Pin; /*!< Specifies the GPIO pins to be configured. 4 This parameter can be any value of @ref GPIO_pins_define */ 5 6 uint32_t Mode; /*!< Specifies the operating mode for the selected pins. 7 This parameter can be a value of @ref GPIO_mode_define */ 8 9 uint32_t Pull; /*!< Specifies the Pull-up or Pull-Down activation for the selected pins.10 This parameter can be a value of @ref GPIO_pull_define */11 12 uint32_t Speed; /*!< Specifies the speed for the selected pins.13 This parameter can be a value of @ref GPIO_speed_define */14 15 uint32_t Alternate; /*!< Peripheral to be connected to the selected pins. 16 This parameter can be a value of @ref GPIO_Alternate_function_selection */17 }GPIO_InitTypeDef;