I tried to write some code but i'm beginner at assembly i could not complete i want to blink 2 leds when button pressed. I can blink the leds without button but i could not do with button.
@ STM32F107 - Assembly template
.thumb
.syntax unified
@ Keep the STACKINIT variable. .equ STACKINIT, 0x20008000 .equ DELAY, 80000
.equ RCC_APB2ENR, 0x40021018 @
.equ GPIOD_CRL, 0x40011400 @ D portuna clock
.equ GPIOD_ODR, 0x4001140C @ D portunu output olarak belirledik 0x0C offset
.equ GPIOC_CRL, 0x40011000 @ C portuna clock
.equ GPIOC_IDR, 0x40011008 @ C portunu input olarak belirledik 0x08 offset
.section .text
.word STACKINIT
.word _start + 1
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ Main code starts from here @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
_start:
LDR R6, = RCC_APB2ENR @ Load peripheral clock enable regiser
LDR R5, [R6] @ Read its content
ORR R5, 0x00000020 @ Buranın nasıl bulunacağını biliyorum portlara göre - Bit( A 2 B 3 C 4 D 5 ...)
STR R5, [R6] @ Store back the result in Perihperal clock enable register
@ Make GIOOD Pin1 as output pin (Page 170 from RM0008)
LDR R6, = GPIOD_CRL @ Load GPIOD control register low (Pin1 is in CRL register)
LDR R5, = 0x22222222 @ hepsi output yap
STR R5, [R6] @ Store back the result in GPIOD control register low
@ Enable GPIOC Peripheral Clock (
LDR R6, = RCC_APB2ENR
LDR R5, [R6]
ORR R5, 0x00000010 @ c portu
STR R5, [R6]
@ Make GIOOC Pins as input pin
LDR R6, = GPIOC_CRL
LDR R5, = 0x11111111 @ hepsi input mu oldu butonların bilmiyorum ?
STR R5, [R6]
dongu:
LDR R6, = GPIOC_IDR
LDR R5, = 0x00000001
STR R5, [R6]
BTFSC GPIOC,1
GOTO dongu
@ Set GIOOD Pin1 to 1 (Page 172 from RM0008)
LDR R6, = GPIOD_ODR @ Load GPIOD output data register
LDR R5, = 0x00000001 @ 1. lede elaktirik ver :)
STR R5, [R6] @ Store back the result in GPIOD output data register
LDR R1, = 1460000
loop: SUBS R1 , 1 BNE loop
LDR R6, = GPIOD_ODR @ Load GPIOD output data register
LDR R5, = 0x00000002 @ 2. LED
STR R5, [R6]
LDR R1, = 1460000
loop1: SUBS R1 , 1 BNE loop1 B dongu
two problems, I think you are configuring port C as an output not an input. mode should be 00 not 01. and a typo the assembler should of caught, dont you want 0x40011008 not 0x4001108h as the address to port c IDR? the port should reset as an input so long as you dont mess with that or so long as port c pin 0 is not an exception to that rule (I dont see an exception in the register description it defaults to 0x44444444 which is all ports as digital inputs) you can just poll IDR after enabling port C in the RCC.
User contributions licensed under CC BY-SA 3.0