使用汇编语言闪烁LED

芯片STM32F103ZET6 PG2接LED 内部RC 8M时钟

首先使能RCC_GPIOG时钟,选择GPIO模式,循环GPIOG->ODR^0XFF
代码如下:

Stack_Size      EQU     0x00000400

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

                AREA    RESET, DATA, READONLY

__Vectors       DCD     __init_sp                  ;__initial_sp               ; Top of Stack
                DCD     Reset_Handler              ; Reset Handler
                    
                    
                AREA    |.text|, CODE, READONLY
                    
                THUMB
                REQUIRE8
                PRESERVE8                 
                ENTRY
Reset_Handler  		
								LDR R0,=0x40021018
								MOV R1,#0XFFFF
								STR R1,[R0]                 ;GPIOG_EN
								
								LDR R0,=0x40012000
								MOV R1,#0X0300
								STR R1,[R0]						     ;GPIO_MODEL 							
								LDR R3,=0X00
start						
                EOR R3,R3,#0XFF
								MOV R2,R3
								LDR R0,=0x4001200C
								STR R2,[R0]                ;GPIOG->ODR^=0XFF		          
                MOV R0,#0
loop            ADD R0,R0,#1  
                LDR R1,=0X8FFFF
                CMP R0,R1
								BEQ start
								BNE loop
								END

你可能感兴趣的:(汇编)