cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F0 WITH Assembly

pic_micro
Associate II
Posted on November 30, 2014 at 13:00

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 KEIL

PRESERVE8
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

39 REPLIES 39
pic_micro
Associate II
Posted on December 07, 2014 at 06:28

pic_micro
Associate II
Posted on December 07, 2014 at 10:01

Dear Sir,

This is my SysTick Handler code, Now SysTick timer operation is working but it does not return from SysTick Handler ( I think)

SysTick_Handler PROC 
LDR R1, =GPIOC_ODR 
LDR R0, =0x100 
STR R0, [R1] 
BX LR 
ENDP

Posted on December 07, 2014 at 15:58

With the code you posted earlier you had commented out vectors, you can't do that, they have specific order and position. Use ''DCD 0'' instead of commenting out.

Suggest you toggle the GPIO
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on December 08, 2014 at 15:53

Dear Sir, I got the point, now it is working and thanks

Suggest you toggle the GPIO

Could you please advice me about assembly instruction for toggle the bit?

Could you please advice me about debugger that we can use to check SysTick interrupt?( Exceptions )

Posted on December 08, 2014 at 18:01

SysTick_Handler PROC 
LDR R1, =GPIOC_ODR 
LDR R2, =0x100 
LDR R0, [R1]
EORS R0, R2 
STR R0, [R1] 
BX LR 
ENDP

Wouldn't expect the Keil debugger to have any problem break-pointing the code, debug how exactly?
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on December 09, 2014 at 02:35

Dear Sir,

I would like to ask this question hear The following program toggle the bit of PORTC using RMW method Can we apply hear the bit banding method to change the bit What should be the code pattern please advice

SysTick_Handler PROC 
LDR R1, =GPIOC_ODR 
LDR R2, =0x100 
LDR R0, [R1]
EORS R0, R2 
STR R0, [R1] 
BX LR
ENDP

Posted on December 09, 2014 at 06:22

I'm not sure bit-banding is implemented on the Cortex-M0 (STM32F0), you'd have to check.

It's not particularly efficient, as it still does an RMW under the hood. Perhaps you want to just do the SET/RESET as a singular write.

GPIOC_BSRR EQU 0x48000818
SysTick_Handler PROC 
LDR R1, =GPIOC_BSRR 
LDR R0, =0x00000100 ; PC8
STR R0, [R1] ; Set 
LDR R0, =0x01000000
STR R0, [R1] ; Reset 
BX LR
ENDP

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on December 10, 2014 at 17:28

Dear Sir, I debugged KIEL with hardware which I am using STM Discovery board, it does not debugging interrupt part (SysTick Exceptions )

Posted on December 10, 2014 at 17:50

Dear Sir, I debugged KIEL with hardware which I am using STM Discovery board, it does not debugging interrupt part (SysTick Exceptions )

One might conclude that the interrupt is not actually occurring.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
pic_micro
Associate II
Posted on December 11, 2014 at 02:26

Dear Sir,

One might conclude that the interrupt is not actually occurring.

 

I did not get it...

At the normal run the SysTick exception is occurred that confirming LED ''ON'' in which the program written to LED ''ON'' in the SysTick handler