2012-09-30 02:51 AM
Hello, I am new in programming of STM32VL Discovery. I would like to write program in assembler for blinking LEDs using interrupts.
But it is so difficult to find examples in ASM and I can�t find some example in ASM with interrupts. Do you have some example where are used interrupts (handlers,..)? Can you help me? Thanks a lot #books2012-09-30 08:07 PM
Do you have any experience of ARM/Thumb assembler to draw from?
In Keil, I might use the SysTick to periodically toggle LED3 thuslySysTick_Handler PROC
EXPORT SysTick_Handler
ldr r0, =0x40011000 ; GPIOC
ldr r1, =0x200 ; Pin 9, LED3
ldr r2, [r0, #0xC] ; GPIOC->ODR
and r2, r2, r1 ; Mask bits to toggle
lsl r3, r2, #16 ; Get reset bits to high order
eor r2, r2, r1 ; Invert set in low order
orr r2, r2, r3 ; Combine
str r2, [r0, #0x10] ; GPIOC->BSRR
bx lr
ENDP
2012-10-01 12:10 AM
Any particular reason why it has to be assembly, rather than, say, 'C' ?
In Assembly, you are dealing directly with the Cortex-M3 instruction set - which is defined by ARM, and not specific to ST or the STM32.
So the place to start would be the ARM technical reference site: http://infocentre.arm.com Get yourself a copy of ''The Definitive Guide to the ARM Cortex-M3'' by Joseph Yiu eg, More ARM Books here: In the ARM 'Community' section, you will find training providers, consultants, etc:2012-10-01 02:05 AM
Thank you, LEDs are blinking now. I was trying to use TIM3 handler, but SYStick handler is definitely better (easier to write in ASM). I must write this in ASM because our teacher wants that. We can use ''delay'' function for blinking LEDs, but I want have better solution...
2012-10-01 03:49 AM
Only one thing is for me still unclear.
I used code from THE DEFINITIVE GUIDE TO THE ARM CORTEX-M3: LDR R0, =0xE000E010 ; SYSTICK control and status register MOV R1, #0 STR R1, [R0] ; stop counter to prevent interrupt triggered accidentally LDR R1, =11999999 ; trigger every 12000000 cycles STR R1, [R0,#4] ; write reload value to reload value register STR R1, [R0,#8] ; write any value tu current value MOV R1, #0x7 ; enable interrupt, enable SYSTICK counter STR R1, [R0] ; start counter Now, it´s blinking every 1 second (0,5s is shining and 0,5s isn´t shining). I thought that when I want blinking every 2 seconds, I only need set LDR R1, =23999999. But it´s blinking even faster! Do you know ,why?2012-10-01 04:25 AM
Confirm what SYSCLK is, 8 MHz, 24 MHz
Check if SysTick is at SYSCLK or SYSCLK/8 The count is 24-bit, so largest value is 16777216. Larger values give slower speeds.