2014-11-30 04:00 AM
Dear All ,
I written a program in assembly to tern on bit 8 on GPOIC It is compiled well but LED does not on processor STM32F051R8T6 IDE KEILPRESERVE8
THUMB
RCC_APB2ENR EQU 0X40021018
GPIOC_CRH EQU 0x40011004
GPIOC_ODR EQU 0x4001100C
DEL1 EQU 0X10
DEL2 EQU 0X10
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors DCD 0X20002000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler PROC
clock_init
ldr R6, =RCC_APB2ENR
movs R0, #0x1C
str R0, [R6]
ldr R6, =GPIOC_CRH
ldr R0, =0x3333333
str R0, [R6]
LDR r1, =GPIOC_ODR
LDR r0, =0x0A00
STR r0, [r1]
ENDP
B DELAY
DELAY
SUBS R2,#1
BNE DELAY
DEL SUBS R3,#1
BNE DEL
B Reset_Handler
ALIGN
END
2014-11-30 05:56 AM
The MODER register for pins 0..7 is at +0x00 not +0x04
2014-11-30 06:38 AM
2014-11-30 07:01 AM
Sorry read PC0
You'll still need to enable the GPIOC clock on the AHB. Bit 19 of RCC_AHBENR (not APB) You might also want to get into the habit of masking/oring on to the registers so as not to disturb existing clocks/settings.2014-12-01 08:36 AM
;PRESERVE8
THUMB
RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x40020800
GPIOC_CRH EQU 0x40011004
GPIOC_ODR EQU 0x40020814
DEL1 EQU 0X10
DEL2 EQU 0X10
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors DCD 0X20002000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler PROC
clock_init
LDR R6, =RCC_AHBENR
LDR R0, =0x8000 ; Bit 19 of RCC_AHBENR
STR R0, [R6]
LDR R6, = GPIOC_MODER
LDR R0, = 0x100
STR R0, [R6]
LDR R1, =GPIOC_ODR
LDR R0, =0x300
STR R0, [R1]
ENDP
B DELAY
DELAY
SUBS R2,#1
BNE DELAY
DEL SUBS R3,#1
BNE DEL
B Reset_Handler
ALIGN
END
2014-12-01 09:35 AM
0x8000 would be bit 15, 0x80000 would be bit 19
2014-12-01 09:48 AM
Yes, Grate thanks now it is working
I will come on next steps;PRESERVE8
THUMB
RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
DEL1 EQU 0X10
DEL2 EQU 0X10
AREA RESET,DATA,READONLY
EXPORT __Vectors
__Vectors DCD 0X20002000
DCD Reset_Handler
ALIGN
AREA MYCODE,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler PROC
clock_init
LDR R6, =RCC_AHBENR
LDR R0, =0x80000 ; Bit 19 of RCC_AHBENR
STR R0, [R6]
LDR R6, = GPIOC_MODER
LDR R0, = 0x55555555
STR R0, [R6]
LDR R1, =GPIOC_ODR
LDR R0, =0x200
STR R0, [R1]
LDR R1, =GPIOC_ODR
LDR R0, =0x100
STR R0, [R1]
ENDP
B DELAY
DELAY
SUBS R2,#1
BNE DELAY
DEL SUBS R3,#1
BNE DEL
B Reset_Handler
ALIGN
END
2014-12-01 10:03 AM
Dear clive1
Can we ignore the following definitions, inserting header file of the target MCU, top of the code?RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
Please advice
2014-12-02 08:33 AM
Dear All
Can we use the header file instead of following definitionsRCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
2014-12-02 09:34 AM
I guess if you have one with equivalent equates in it...
There's probably a tool to convert .H to .INC formats, I've used one in the past.