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
Posted on December 11, 2014 at 03:22

Ok, so if you place a break-point in the interrupt code is it hit, or not?

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 16:52

Ok, so if you place a break-point in the interrupt code is it hit, or not?

Yes sir, It is working debug run mode but it does not hit the interrupt step by step debugging mode Thank you very much for advice Dear Sir, my next question about GET or INCLUDEdirectives I am expecting to create equates as a separate file ( file name is test.s )and add to main file using GET directive Following are the only things that i included to ''test.s'' file and this test.s file is in the same folder

RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
STK_CSR EQU 0xE000E010
STK_RVR EQU 0xE000E014 
STK_CVR EQU 0xE000E018
STK_CALIB EQU 0xE000E01C 
PWR_CR EQU 0X40007000
PWR_CSR EQU 0X40007004

Following is showing the way how I included the test.s to my main program file

Stack_Size EQU 0x00000400
RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
STK_CSR EQU 0xE000E010
STK_RVR EQU 0xE000E014 
STK_CVR EQU 0xE000E018
STK_CALIB EQU 0xE000E01C 
PWR_CR EQU 0X40007000
PWR_CSR EQU 0X40007004
DEL1 EQU 0XFFFFF
DEL2 EQU 0Xffffffff
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp

GET test.s

PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
ENTRY
; Reset handler routine
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
start BL Sys_init
LOOP BL blink_LED 
BNE LOOP
ENDP
stop

Finally following error occurred startup_stm32f0xx.s(22): error: A1163E: Unknown opcode test.s , expecting opcode or Macro Please advice
Posted on December 11, 2014 at 17:30

Single stepping will not take you into interrupt code.

I'd use test.inc, you don't need to replicate the equates you already have. You should have a space or tab in front of GET so that it's not in the first column.
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 17:54

Dear Sir,

Thanks for the prompt reply

I already used tab in my program for GET directive 

I used .s and .INC both but result is same

The equates already have in my main program removed but problem remaining same

I am 100% sure that the program is reading the test.inc file, that should be the reason only one error occurred 

Error

startup_stm32f0xx.s(24): error: A1163E: Unknown opcode TEST.INC , expecting opcode or Macro

Please advice

Posted on December 11, 2014 at 18:33

test.inc

RCC_AHBENR EQU 0x40021014
GPIOC_MODER EQU 0x48000800
GPIOC_ODR EQU 0x48000814
STK_CSR EQU 0xE000E010
STK_RVR EQU 0xE000E014
STK_CVR EQU 0xE000E018
STK_CALIB EQU 0xE000E01C
PWR_CR EQU 0X40007000
PWR_CSR EQU 0X40007004
END

startup.s

...
INCLUDE test.inc ; GET works too
SysTick_Handler_Test PROC 
LDR R1, =GPIOC_ODR 
LDR R2, =0x100 
LDR R0, [R1]
EORS R0, R2 
STR R0, [R1] 
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..
Posted on December 11, 2014 at 20:14

Yeah, I don't know what you're doing, it works on uv4.74, the only way I get the same error you get is when I have the command in the first column

You need

<Space>INCLUDE<Space>test.inc
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 12, 2014 at 01:49

Dear Sir,

Yes, it is my fault

<Space>INCLUDE<Space>test.inc

I missed the ''space''

Thanks

pic_micro
Associate II
Posted on December 12, 2014 at 19:10

Dear Sir,

I am now initializing TIM14 following code does not copy to the actual registers at the debugging RCC_APB1ENR EQU 0X4002101C Other registers are showing very correctly but timer 14 related registers should not show the values at the debugging

LDR R6, =RCC_APB1ENR ;TIM14 clock enable bit 8
LDR R0, =0X80
STR R0, [R6]

Please see image for better understand 0690X00000602wAQAQ.jpg
Posted on December 12, 2014 at 21:09

I'm not sure what peripherals are present in your particular chip

 LDR R6, =RCC_APB1ENR
LDR R0, =0xFFFFFFFF
STR R0, [R6] ; Set all
LDR R0, [R6] ; See which stick

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 13, 2014 at 02:00 Dear Sir, I am using STM32F051R8 It is stranger to me, following code works

LDR R6, =RCC_APB1ENR ;TIM14 clock enable bit 8
LDR R0, =0X11
STR R0, [R6]

But this code is not working

LDR R6, =RCC_APB1ENR ;TIM14 clock enable bit 8
LDR R0, =0X80
STR R0, [R6]

Only code different is 1.

LDR R0, =0X11

2.

LDR R0, =0X80

So, I would need second one which is used to enable clock for TIM14 by setting bit 8 of APB1ENR