本帖最后由 YangTwo 于 2023-11-11 13:56 编辑
在Keil官网下载固件包:
双击安装:
安装完成后新建工程,可以选择芯片:STM32U5A5ZJT6Q
先运行一个最简单的GPIO翻转,初始化GPIO
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = LED1_PIN;
HAL_GPIO_Init(LED1_GPIO_PORT, &GPIO_InitStruct);
GPIO_InitStruct.Pin = LED2_PIN;
HAL_GPIO_Init(LED2_GPIO_PORT, &GPIO_InitStruct);
延迟一定时间后,翻转LED状态
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
HAL_GPIO_TogglePin(LED1_GPIO_PORT, LED1_PIN);
/* Insert delay 1000 ms */
HAL_Delay(1000);
HAL_GPIO_TogglePin(LED2_GPIO_PORT, LED2_PIN);
/* Insert delay 1000 ms */
HAL_Delay(1000);
}
编译:
Rebuild started: Project: GPIO_IOToggle
*** Using Compiler 'V6.16', folder: 'D:\ProgramFiles\Keil_v5\ARM\ARMCLANG\Bin'
Rebuild target 'GPIO_IOToggle'
assembling startup_stm32u5a5xx.s...
compiling main.c...
compiling stm32u5xx_hal_exti.c...
compiling stm32u5xx_hal_cortex.c...
compiling stm32u5xx_hal.c...
compiling stm32u5xx_hal_msp.c...
compiling stm32u5xx_hal_dma.c...
compiling stm32u5xx_hal_gtzc.c...
compiling stm32u5xx_hal_icache.c...
compiling stm32u5xx_hal_pwr_ex.c...
compiling stm32u5xx_hal_i2c.c...
compiling stm32u5xx_hal_tim.c...
compiling stm32u5xx_it.c...
compiling stm32u5xx_hal_pwr.c...
compiling stm32u5xx_hal_i2c_ex.c...
compiling stm32u5xx_hal_flash_ex.c...
compiling stm32u5xx_nucleo.c...
compiling stm32u5xx_hal_gpio.c...
compiling stm32u5xx_hal_tim_ex.c...
compiling stm32u5xx_hal_dma_ex.c...
compiling stm32u5xx_hal_flash.c...
compiling system_stm32u5xx.c...
compiling stm32u5xx_hal_rcc.c...
compiling stm32u5xx_hal_rcc_ex.c...
linking...
Program Size: Code=6448 RO-data=832 RW-data=12 ZI-data=1660
FromELF: creating hex file...
"GPIO_IOToggle\GPIO_IOToggle.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:03
Load "GPIO_IOToggle\\GPIO_IOToggle.axf"
Erase Done.
Programming Done.
Verify OK.
Flash Load finished at 13:40:15
还有一个选项需要注意:“RESET AND RUN”,这样下载后程序会自动运行。
|