0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

STM32入门学习笔记之STM32F103环境搭建(下)

jf_78858299 来源:滑小稽笔记 作者:电子技术园地 2023-02-16 09:39 次阅读

(3)在工程文件夹中创建四个子文件夹,HEADERWARE,OBJECT,USER和SYSTEM,各文件夹内容如下所示。

USER:存放工程文件,汇编启动文件与主函数的c文件

SYSTEM:存放系统文件,串口1文件和滴答时钟文件

HEADERWARE:存放其他的驱动文件

OBJECT:存放编译过程的链接文件以及最终的HEX文件

图片

(4)新建工程,输入工程保存路径后点击保存。

图片

图片

(5)选择目标芯片型号,我们使用的芯片型号是STM32F103ZET6

图片

图片

图片

(6)点击工程设置,添加系统文件夹

图片

点击红框选中的位置来新建文件夹,双击新建的文件夹修改名称,创建和步骤3目录一样的文件夹,如下图所示。

图片

(7)创建启动汇编文件

图片

点击保存,输入文件名stm32f103x.s后保存进User文件夹。

图片

输入以下代码,由于以下代码是固定的,所以可以直接复制

Stack_Size    EQU    0x00000400


        AREA  STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem    SPACE  Stack_Size
__initial_sp


Heap_Size    EQU    0x00000200


        AREA  HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem    SPACE   Heap_Size
__heap_limit


                PRESERVE8
                THUMB


; Vector Table Mapped to Address 0 at Reset
                AREA    RESET, DATA, READONLY
                EXPORT    __Vectors
                EXPORT    __Vectors_End
                EXPORT    __Vectors_Size


__Vectors    DCD    __initial_sp        ; Top of Stack
        DCD    Reset_Handler        ; Reset Handler
        DCD    NMI_Handler          ; NMI Handler
        DCD    HardFault_Handler      ; Hard Fault Handler
        DCD    MemManage_Handler      ; MPU Fault Handler
        DCD    BusFault_Handler      ; Bus Fault Handler
        DCD    UsageFault_Handler      ; Usage Fault Handler
        DCD    0              ; Reserved
        DCD    0              ; Reserved
        DCD    0              ; Reserved
        DCD    0              ; Reserved
        DCD    SVC_Handler          ; SVCall Handler
        DCD    DebugMon_Handler      ; Debug Monitor Handler
        DCD    0              ; Reserved
        DCD    PendSV_Handler        ; PendSV Handler
        DCD    SysTick_Handler        ; SysTick Handler


        ; External Interrupts
        DCD     WWDG_IRQHandler        ; Window Watchdog
        DCD     PVD_IRQHandler        ; PVD through EXTI Line detect
        DCD     TAMPER_IRQHandler      ; Tamper
        DCD     RTC_IRQHandler        ; RTC
        DCD     FLASH_IRQHandler      ; Flash
        DCD     RCC_IRQHandler        ; RCC
        DCD     EXTI0_IRQHandler      ; EXTI Line 0
        DCD     EXTI1_IRQHandler      ; EXTI Line 1
        DCD     EXTI2_IRQHandler      ; EXTI Line 2
        DCD     EXTI3_IRQHandler      ; EXTI Line 3
        DCD     EXTI4_IRQHandler      ; EXTI Line 4
        DCD     DMA1_Channel1_IRQHandler  ; DMA1 Channel 1
        DCD     DMA1_Channel2_IRQHandler  ; DMA1 Channel 2
        DCD     DMA1_Channel3_IRQHandler  ; DMA1 Channel 3
        DCD     DMA1_Channel4_IRQHandler  ; DMA1 Channel 4
        DCD     DMA1_Channel5_IRQHandler  ; DMA1 Channel 5
        DCD     DMA1_Channel6_IRQHandler  ; DMA1 Channel 6
        DCD     DMA1_Channel7_IRQHandler  ; DMA1 Channel 7
        DCD     ADC1_2_IRQHandler      ; ADC1 & ADC2
        DCD     USB_HP_CAN1_TX_IRQHandler  ; USB High Priority or CAN1 TX
        DCD     USB_LP_CAN1_RX0_IRQHandler  ; USB Low  Priority or CAN1 RX0
        DCD     CAN1_RX1_IRQHandler      ; CAN1 RX1
        DCD     CAN1_SCE_IRQHandler      ; CAN1 SCE
        DCD     EXTI9_5_IRQHandler      ; EXTI Line 9..5
        DCD     TIM1_BRK_IRQHandler      ; TIM1 Break
        DCD     TIM1_UP_IRQHandler      ; TIM1 Update
        DCD     TIM1_TRG_COM_IRQHandler    ; TIM1 Trigger and Commutation
        DCD     TIM1_CC_IRQHandler      ; TIM1 Capture Compare
        DCD     TIM2_IRQHandler        ; TIM2
        DCD     TIM3_IRQHandler        ; TIM3
        DCD     TIM4_IRQHandler        ; TIM4
        DCD     I2C1_EV_IRQHandler      ; I2C1 Event
        DCD     I2C1_ER_IRQHandler      ; I2C1 Error
        DCD     I2C2_EV_IRQHandler      ; I2C2 Event
        DCD     I2C2_ER_IRQHandler      ; I2C2 Error
        DCD     SPI1_IRQHandler        ; SPI1
        DCD     SPI2_IRQHandler        ; SPI2
        DCD     USART1_IRQHandler      ; USART1
        DCD     USART2_IRQHandler      ; USART2
        DCD     USART3_IRQHandler      ; USART3
        DCD     EXTI15_10_IRQHandler    ; EXTI Line 15..10
        DCD     RTCAlarm_IRQHandler      ; RTC Alarm through EXTI Line
        DCD     USBWakeUp_IRQHandler    ; USB Wakeup from suspend
        DCD     TIM8_BRK_IRQHandler      ; TIM8 Break
        DCD     TIM8_UP_IRQHandler      ; TIM8 Update
        DCD     TIM8_TRG_COM_IRQHandler    ; TIM8 Trigger and Commutation
        DCD     TIM8_CC_IRQHandler      ; TIM8 Capture Compare
        DCD     ADC3_IRQHandler        ; ADC3
        DCD     FSMC_IRQHandler        ; FSMC
        DCD     SDIO_IRQHandler        ; SDIO
        DCD     TIM5_IRQHandler        ; TIM5
        DCD     SPI3_IRQHandler        ; SPI3
        DCD     UART4_IRQHandler      ; UART4
        DCD     UART5_IRQHandler      ; UART5
        DCD     TIM6_IRQHandler        ; TIM6
        DCD     TIM7_IRQHandler        ; TIM7
        DCD     DMA2_Channel1_IRQHandler  ; DMA2 Channel1
        DCD     DMA2_Channel2_IRQHandler  ; DMA2 Channel2
        DCD     DMA2_Channel3_IRQHandler  ; DMA2 Channel3
        DCD     DMA2_Channel4_5_IRQHandler  ; DMA2 Channel4 & Channel5
__Vectors_End


__Vectors_Size  EQU  __Vectors_End - __Vectors


        AREA    |.text|, CODE, READONLY
; Reset handler
Reset_Handler  PROC
        EXPORT    Reset_Handler        [WEAK]
        IMPORT    __main  
        LDR      R0, =__main
        BX      R0
        ENDP


; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler    PROC
        EXPORT    NMI_Handler          [WEAK]
        B    .
        ENDP
HardFault_Handler\\
        PROC
        EXPORT    HardFault_Handler      [WEAK]
        B    .
        ENDP
MemManage_Handler\\
        PROC
        EXPORT    MemManage_Handler      [WEAK]
        B    .
        ENDP
BusFault_Handler\\
        PROC
        EXPORT    BusFault_Handler      [WEAK]
        B    .
        ENDP
UsageFault_Handler\\
        PROC
        EXPORT    UsageFault_Handler      [WEAK]
        B    .
        ENDP
SVC_Handler    PROC
        EXPORT    SVC_Handler          [WEAK]
        B    .
        ENDP
DebugMon_Handler\\
        PROC
        EXPORT    DebugMon_Handler      [WEAK]
        B    .
        ENDP
PendSV_Handler  PROC
        EXPORT    PendSV_Handler        [WEAK]
        B    .
        ENDP
SysTick_Handler  PROC
        EXPORT    SysTick_Handler        [WEAK]
        B    .
        ENDP


Default_Handler  PROC
        EXPORT    WWDG_IRQHandler        [WEAK]
        EXPORT    PVD_IRQHandler        [WEAK]
        EXPORT    TAMPER_IRQHandler      [WEAK]
                EXPORT    RTC_IRQHandler        [WEAK]
        EXPORT    FLASH_IRQHandler      [WEAK]
        EXPORT    RCC_IRQHandler        [WEAK]
        EXPORT    EXTI0_IRQHandler      [WEAK]
        EXPORT    EXTI1_IRQHandler      [WEAK]
        EXPORT    EXTI2_IRQHandler      [WEAK]
        EXPORT    EXTI3_IRQHandler      [WEAK]
        EXPORT    EXTI4_IRQHandler      [WEAK]
        EXPORT    DMA1_Channel1_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel2_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel3_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel4_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel5_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel6_IRQHandler  [WEAK]
        EXPORT    DMA1_Channel7_IRQHandler  [WEAK]
        EXPORT    ADC1_2_IRQHandler      [WEAK]
        EXPORT    USB_HP_CAN1_TX_IRQHandler  [WEAK]
        EXPORT    USB_LP_CAN1_RX0_IRQHandler  [WEAK]
        EXPORT    CAN1_RX1_IRQHandler      [WEAK]
        EXPORT    CAN1_SCE_IRQHandler      [WEAK]
        EXPORT    EXTI9_5_IRQHandler      [WEAK]
        EXPORT    TIM1_BRK_IRQHandler      [WEAK]
        EXPORT    TIM1_UP_IRQHandler      [WEAK]
        EXPORT    TIM1_TRG_COM_IRQHandler    [WEAK]
        EXPORT    TIM1_CC_IRQHandler      [WEAK]
        EXPORT    TIM2_IRQHandler        [WEAK]
        EXPORT    TIM3_IRQHandler        [WEAK]
        EXPORT    TIM4_IRQHandler        [WEAK]
        EXPORT    I2C1_EV_IRQHandler      [WEAK]
        EXPORT    I2C1_ER_IRQHandler      [WEAK]
        EXPORT    I2C2_EV_IRQHandler      [WEAK]
        EXPORT    I2C2_ER_IRQHandler      [WEAK]
        EXPORT    SPI1_IRQHandler        [WEAK]
        EXPORT    SPI2_IRQHandler        [WEAK]
        EXPORT    USART1_IRQHandler      [WEAK]
        EXPORT    USART2_IRQHandler      [WEAK]
        EXPORT    USART3_IRQHandler      [WEAK]
        EXPORT    EXTI15_10_IRQHandler    [WEAK]
        EXPORT    RTCAlarm_IRQHandler      [WEAK]
        EXPORT    USBWakeUp_IRQHandler    [WEAK]
        EXPORT    TIM8_BRK_IRQHandler      [WEAK]
        EXPORT    TIM8_UP_IRQHandler      [WEAK]
        EXPORT    TIM8_TRG_COM_IRQHandler    [WEAK]
        EXPORT    TIM8_CC_IRQHandler      [WEAK]
        EXPORT    ADC3_IRQHandler        [WEAK]
        EXPORT    FSMC_IRQHandler        [WEAK]
        EXPORT    SDIO_IRQHandler        [WEAK]
        EXPORT    TIM5_IRQHandler        [WEAK]
        EXPORT    SPI3_IRQHandler        [WEAK]
        EXPORT    UART4_IRQHandler      [WEAK]
        EXPORT    UART5_IRQHandler      [WEAK]
        EXPORT    TIM6_IRQHandler        [WEAK]
        EXPORT    TIM7_IRQHandler        [WEAK]
        EXPORT    DMA2_Channel1_IRQHandler  [WEAK]
        EXPORT    DMA2_Channel2_IRQHandler  [WEAK]
        EXPORT    DMA2_Channel3_IRQHandler  [WEAK]
        EXPORT    DMA2_Channel4_5_IRQHandler  [WEAK]


WWDG_IRQHandler
PVD_IRQHandler
TAMPER_IRQHandler
RTC_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_2_IRQHandler
USB_HP_CAN1_TX_IRQHandler
USB_LP_CAN1_RX0_IRQHandler
CAN1_RX1_IRQHandler
CAN1_SCE_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_IRQHandler
TIM1_UP_IRQHandler
TIM1_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM3_IRQHandler
TIM4_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
USART3_IRQHandler
EXTI15_10_IRQHandler
RTCAlarm_IRQHandler
USBWakeUp_IRQHandler
TIM8_BRK_IRQHandler
TIM8_UP_IRQHandler
TIM8_TRG_COM_IRQHandler
TIM8_CC_IRQHandler
ADC3_IRQHandler
FSMC_IRQHandler
SDIO_IRQHandler
TIM5_IRQHandler
SPI3_IRQHandler
UART4_IRQHandler
UART5_IRQHandler
TIM6_IRQHandler
TIM7_IRQHandler
DMA2_Channel1_IRQHandler
DMA2_Channel2_IRQHandler
DMA2_Channel3_IRQHandler
DMA2_Channel4_5_IRQHandler
        B    .
        ENDP
        ALIGN


; User Stack and Heap initialization
        IF      :DEF:__MICROLIB
        EXPORT    __initial_sp
        EXPORT    __heap_base
        EXPORT    __heap_limit
        ELSE  
        IMPORT    __use_two_region_memory
        EXPORT    __user_initial_stackheap
__user_initial_stackheap
        LDR    R0, =  Heap_Mem
        LDR    R1, =(Stack_Mem + Stack_Size)
        LDR    R2, = (Heap_Mem +  Heap_Size)
        LDR    R3, = Stack_Mem
        BX    LR
        ALIGN
        ENDIF
        END

(8)修改链接文件与HEX文件的保存路径

图片

修改HEX的保存路径

图片

修改链接文件的保存路径

图片

(9)创建主函数的c文件,创建步骤与步骤7一样,只不过保存的时候,文件后缀变为c,例如1.c。将主函数的c文件保存到User目录下

图片

(10)在c文件下输入如下代码

#include 
int main()
{
  while( 1 )
  {

  }
}

(11)将刚才创建的2个文件添加进工程

图片

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • ARM
    ARM
    +关注

    关注

    134

    文章

    9091

    浏览量

    367481
  • STM32
    +关注

    关注

    2270

    文章

    10897

    浏览量

    355882
  • Cortex-M
    +关注

    关注

    2

    文章

    229

    浏览量

    29757
  • 嵌入式控制系统

    关注

    0

    文章

    6

    浏览量

    2358
收藏 人收藏

    评论

    相关推荐

    STM32F103如何搭建开发环境

    STM32F103如何搭建开发环境
    发表于 11-26 06:59

    基于STM32F103的振动监测系统设计

    基于STM32F103的振动监测系统设计。
    发表于 11-09 17:49 43次下载

    STM32F103封装方式与功能配置

    本文介绍STM32F103封装方式和STM32F103管脚功能的配置。
    发表于 08-03 17:44 2.2w次阅读
    <b class='flag-5'>STM32F103</b>封装方式与功能配置

    STM32F103使用总结

    STM32F103使用总结
    发表于 10-24 10:22 152次下载

    stm32f103移植

    stm32f103移植
    发表于 10-27 09:03 43次下载
    <b class='flag-5'>stm32f103</b>移植

    STM32F103教程之STM32F103单片机的使用心得资料免费下载

    本文档的主要内容详细介绍的是STM32F103教程之STM32F103单片机的使用心得资料免费下载目前很火的设计STM32教程。
    发表于 09-26 08:00 254次下载

    STM32F103芯片资料介绍

    只是STM32F103芯片资料的简单介绍,文章由(逆向开发技术网)编辑整理。下次我们将具体介绍一STM32F103芯片解密方法”
    发表于 01-08 08:00 188次下载
    <b class='flag-5'>STM32F103</b>芯片资料介绍

    STM32F103 CAN模板程序

    STM32F103 CAN模板程序
    发表于 11-09 11:08 80次下载
    <b class='flag-5'>STM32F103</b> CAN模板程序

    stm32f030和stm32f103功能差异

    stm32f030和stm32f103功能差异主要表现在哪?
    的头像 发表于 07-22 09:35 2.2w次阅读

    STM32F103学习笔记三 串口通信

    STM32F103学习笔记三 串口通信
    发表于 11-25 09:06 71次下载
    <b class='flag-5'>STM32F103</b><b class='flag-5'>学习</b><b class='flag-5'>笔记</b>三   串口通信

    STM32F103 模拟IIC时序

    STM32F103 模拟IIC时序
    发表于 11-25 09:51 34次下载
    <b class='flag-5'>STM32F103</b>  模拟IIC时序

    [笔记]|[stm32]|[寄存器存储器区别]|[PWM]|[串口]|[Timer]stm32f103笔记

    [笔记]|[stm32]|[寄存器存储器区别]|[PWM]|[串口]|[Timer]stm32f103笔记笔记为18.12.21笔者期末复
    发表于 12-06 18:51 10次下载
    [<b class='flag-5'>笔记</b>]|[<b class='flag-5'>stm32</b>]|[寄存器存储器区别]|[PWM]|[串口]|[Timer]<b class='flag-5'>stm32f103</b><b class='flag-5'>笔记</b>

    GD32F103STM32F103的区别 2021.6.2

    GD32F103STM32F103区别介绍关键词Key words:GD32F103STM32F103摘要Abstract:本文主要是GD32F
    发表于 12-08 11:06 83次下载
    GD32<b class='flag-5'>F103</b>与<b class='flag-5'>STM32F103</b>的区别 2021.6.2

    学习STM32F103的DAC功能

    三勺最近在学习STM32F103的DAC功能,本文主要解释在配置DAC寄存器实现相应功能时遇到的一些问题。
    的头像 发表于 10-24 16:00 2750次阅读
    <b class='flag-5'>学习</b><b class='flag-5'>STM32F103</b>的DAC功能

    学习STM32F103的ADC功能

    三勺最近在学习STM32F103的ADC功能,居然连最简单的独立模式的单通道的电压采集都不能实现,这就不能忍了,这是对智商的侮辱。
    的头像 发表于 10-24 16:06 2251次阅读
    <b class='flag-5'>学习</b><b class='flag-5'>STM32F103</b>的ADC功能