STM32 CubeIDE快速創建工程(圖文詳解)


使用STM32CubeIDE快速創建STM32的HAL庫工程。

1 STM32CubeIDE Home

進入到官網的下載界面,選擇符合對應的操作系統和對應的版本,下載安裝,下載界面如下圖所示;
在這里插入圖片描述

安裝完成之后,打開STM32CubeIDE會直接進入主頁,這里開始創建STM32工程或者導入工程,如下圖所示;
在這里插入圖片描述

Read STM32CubeIDE Documentation有大量的官方文檔;可以快速入門,包括;

  • 安裝教程;
  • 用戶手冊;

2 生成工程

在這里插入圖片描述

設置工程名稱和路徑之后就基本完成工程的創建了,具體如下圖所示;
在這里插入圖片描述
在此期間可能會聯機下載庫文件和相應MCU的外設文件,這里要保持網絡暢通,並耐心等待;

成功創建工程之后,如下圖所示;
在這里插入圖片描述
可以看到左邊是HAL庫,右邊是CubeMAX的配置界面,至此已經完成了工程的生成了,那么下一步進行進行編譯和下載。

另外在文件列表中可以看到TEST.ioc文件,這是CubeMAX的配置文件,相當於一些軟件的ini文件,CubeMAX主要通過讀寫該文件將設備的配置保存和加載的軟件中,直接用文本編輯器打開可以看到具體的信息如下所示;

#MicroXplorer Configuration settings - do not modify
FREERTOS.IPParameters=Tasks01
FREERTOS.Tasks01=defaultTask,0,128,StartDefaultTask,Default,NULL
File.Version=6
KeepUserPlacement=false
Mcu.Family=STM32F1
Mcu.IP0=FREERTOS
Mcu.IP1=NVIC
Mcu.IP2=RCC
Mcu.IP3=SYS
Mcu.IPNb=4
Mcu.Name=STM32F103Z(C-D-E)Tx
Mcu.Package=LQFP144
Mcu.Pin0=VP_FREERTOS_VS_CMSIS_V1
Mcu.Pin1=VP_SYS_VS_ND
Mcu.Pin2=VP_SYS_VS_Systick
Mcu.PinsNb=3
Mcu.ThirdPartyNb=0
Mcu.UserConstants=
Mcu.UserName=STM32F103ZETx
MxCube.Version=5.3.0
MxDb.Version=DB.5.0.30
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
NVIC.PendSV_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:false
NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:false\:false\:false\:false
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:true\:false\:true
NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
PCC.Checker=false
PCC.Line=STM32F103
PCC.MCU=STM32F103Z(C-D-E)Tx
PCC.PartNumber=STM32F103ZETx
PCC.Seq0=0
PCC.Series=STM32F1
PCC.Temperature=25
PCC.Vdd=3.3
PinOutPanel.RotationAngle=0
ProjectManager.AskForMigrate=true
ProjectManager.BackupPrevious=false
ProjectManager.CompilerOptimize=6
ProjectManager.ComputerToolchain=false
ProjectManager.CoupleFile=false
ProjectManager.CustomerFirmwarePackage=
ProjectManager.DefaultFWLocation=true
ProjectManager.DeletePrevious=true
ProjectManager.DeviceId=STM32F103ZETx
ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.8.0
ProjectManager.FreePins=false
ProjectManager.HalAssertFull=false
ProjectManager.HeapSize=0x200
ProjectManager.KeepUserCode=true
ProjectManager.LastFirmware=true
ProjectManager.LibraryCopy=1
ProjectManager.MainLocation=Src
ProjectManager.NoMain=false
ProjectManager.PreviousToolchain=
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=TEST.ioc
ProjectManager.ProjectName=TEST
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false
RCC.APB1Freq_Value=8000000
RCC.APB2Freq_Value=8000000
RCC.FamilyName=M
RCC.IPParameters=APB1Freq_Value,APB2Freq_Value,FamilyName,PLLCLKFreq_Value,PLLMCOFreq_Value,TimSysFreq_Value
RCC.PLLCLKFreq_Value=8000000
RCC.PLLMCOFreq_Value=4000000
RCC.TimSysFreq_Value=8000000
VP_FREERTOS_VS_CMSIS_V1.Mode=CMSIS_V1
VP_FREERTOS_VS_CMSIS_V1.Signal=FREERTOS_VS_CMSIS_V1
VP_SYS_VS_ND.Mode=No_Debug
VP_SYS_VS_ND.Signal=SYS_VS_ND
VP_SYS_VS_Systick.Mode=SysTick
VP_SYS_VS_Systick.Signal=SYS_VS_Systick
board=custom
isbadioc=false

這個不用太關心,因為可以通過圖形化界面去配置,軟件會自動修改這個配置文件的。

3 程序下載

可以在工具欄直接點擊錘子
在這里插入圖片描述快速進行構建,最終會自動生成elf的文件,也就是仿真器可以燒錄的文件;然后可以在窗口直接查看Build的信息,包括報錯等等,具體如下;

12:52:59 **** Incremental Build of configuration Debug for project TEST ****
make -j4 all 
arm-none-eabi-gcc "../Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c" -mcpu=cortex-m3 -std=gnu11 -g3 -DSTM32F103xE -DUSE_HAL_DRIVER -DDEBUG -c -I../Inc -I../Drivers/CMSIS/Device/ST/STM32F1xx/Include -I../Drivers/CMSIS/Include -I../Drivers/STM32F1xx_HAL_Driver/Inc/Legacy -I../Drivers/STM32F1xx_HAL_Driver/Inc -O0 -ffunction-sections -fdata-sections -Wall -fstack-usage -MMD -MP -MF"Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.d" -MT"Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.o" --specs=nano.specs -mfloat-abi=soft -mthumb -o "Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.o"
...
Finished building target: TEST.elf
 
arm-none-eabi-objdump -h -S  TEST.elf  > "TEST.list"
arm-none-eabi-size   TEST.elf 
   text	   data	    bss	    dec	    hex	filename
   3860	     20	   8228	  12108	   2f4c	TEST.elf
Finished building: default.size.stdout

點擊工具欄的蟲子圖標
在這里插入圖片描述
進行調試;

在這里插入圖片描述

在菜單欄Run選項中找到Debug Configuratons,如下圖所示,配置調試用的仿真器和接口方式,最后點擊Debug即可將TEST.elf下載到target中。
在這里插入圖片描述

成功開始調試之后,如下圖所示;
在這里插入圖片描述


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM