TIMBO 2023
Newbie
(1) Could you check some code-passages in ASSEMBLER ARMv7 for me? I marked relevant semantic lines with an arrow, -> .
(2) Is there a common understanding of programming regarding definitions and declarations, sub-programmes etc.? Do you know a fundamental programmers book beside the official documentation for ARMv7?
(3) I need to pulse a signal on PA2 - there I need support from you - for a clear signal to a configured PA2 ...
(2) Is there a common understanding of programming regarding definitions and declarations, sub-programmes etc.? Do you know a fundamental programmers book beside the official documentation for ARMv7?
(3) I need to pulse a signal on PA2 - there I need support from you - for a clear signal to a configured PA2 ...
Code:
.syntax unified
.text
.global __main
.global function
.thumb_func
.equ RCC_BASE, 0x40021000
.equ RCC_APB2_ENR, 0x40021018 // STM32f103C8T6 - Adresse von RCC_APB2ENR - 0x18
.equ GPIOC_BASE, 0x40011000 // GPIOC-Basisadresse nach "memory-map", Datenblatt
.equ GPIOC_CRH, 0x40011004 // GPIOC-BASE + 0x04 ist das Konfigurationsregister
.equ GPIOA_BASE, 0x40010800
.equ GPIOA_CRL, 0x40010800
.equ GPIO_ODR, 0x4001080C
.equ GPIOCEN, 1 << 4 // Seite 141, Referenz-Dokumentation
.equ GPIOAEN, 1 << 2 //
.equ CRH_OUT_SET_1, 0 << 23
.equ CRH_OUT_SET_2, 0 << 22
.equ CRH_OUT_SET_3, 1 << 21
.equ CRH_OUT_SET_4, 0 << 20 // Von unten nach oben: MODE1, MODE0, CNF1, CNF0 festlegen - (Referenz-Handbuch, Seite 161)
.equ CRL_OUT_SET_1_PA4, 0 << 19
.equ CRL_OUT_SET_2_PA4, 0 << 18
.equ CRL_OUT_SET_3_PA4, 1 << 17
.equ CRL_OUT_SET_4_PA4, 0 << 16
.equ CRL_OUT_SET_1_PA3, 0 << 15
.equ CRL_OUT_SET_2_PA3, 0 << 14
.equ CRL_OUT_SET_3_PA3, 1 << 13
.equ CRL_OUT_SET_4_PA3, 0 << 12
.equ CRL_OUT_SET_1_PA2, 0 << 11
.equ CRL_OUT_SET_2_PA2, 0 << 10
.equ CRL_OUT_SET_3_PA2, 1 << 9
.equ CRL_OUT_SET_4_PA2, 0 << 8 // Von unten nach oben: MODE1, MODE0, CNF1, CNF0 festlegen - Konfiguration für PA2, PA3, PA4 einstellen
.equ LED_BLUE, 1 << 13 // PC13 - Programm-Kontroll-LED
.equ PA2_PUL, 1 << 2
.equ PA3_DIR, 1 << 3
.equ PA4_ENA, 1 << 4
.equ DELAY_TIME, 1000000
//------------------------------------------------------------------------------------------------
__main:
// Setzen der Uhr im Programm
LDR R0,=RCC_APB2_ENR
LDR R1,[R0]
ORR R1,GPIOAEN
-> ORR R1,GPIOCEN
STR R1,[R0] // Absatz beschreibt das Freischalten der Uhr mit dem Bus für Port A und C
LDR R0,=GPIOC_CRH
LDR R1,[R0]
LDR R2,=(CRH_OUT_SET_1|CRH_OUT_SET_2|CRH_OUT_SET_3|CRH_OUT_SET_4)
ORR R1,R2
STR R1,[R0] // Konfiguration-Register setzen
LDR R2,=GPIO_ODR // ODR-Register wird in R2 geladen, PROGRAMM-KONTROLL-LED
LDR R4,=GPIOA_CRL
LDR R5,[R4]
-> LDR R6,=(CRL_OUT_SET_1_PA2|CRL_OUT_SET_2_PA2|CRL_OUT_SET_3_PA2|CRL_OUT_SET_4_PA2|CRL_OUT_SET_1_PA3|CRL_OUT_SET_2_PA3|CRL_OUT_SET_3_PA3|CRL_OUT_SET_4_PA3|CRL_OUT_SET_1_PA4|CRL_OUT_SET_2_PA4|CRL_OUT_SET_3_PA4|CRL_OUT_SET_4_PA4)
ORR R5,R6
STR R5,[R4] // Konfigurations-Register setzen
LDR R6,=GPIO_ODR // ODR-Register wird in R6 geladen, SCHRITTMOTOR
-> MOV R5,#PA3_DIR
STR R5,[R6]
-> MOV R5,#PA4_ENA
STR R5,[R6]
function:
Blink:
MOV R1,#LED_BLUE
STR R1,[R2]
-> MOV R5,#PA2_PUL
STR R5,[R6]
LDR R3,=#DELAY_TIME
BL delay1
MOV R1,#0
STR R1,[R2]
MOV R5,#0
STR R5,[R6]
LDR R3,=#DELAY_TIME
BL delay1
B Blink
delay1:
SUBS R3,R3,#1
BNE delay1 // BNE, BX
BX LR