Question
Systick Interrupt using GNU Assembler
Posted on September 13, 2015 at 16:48
Hi guys,
I have a problem to test systick using GNU assembler on my STM32VLDiscoveryMy assembly code is:.thumb.syntax unified.cpu cortex-m3 @ STM32VLDiscovery Board .equ STACKINIT , 0x20005000 .equ GPIOC_BASE , 0x40011000 .equ GPIOC_CRL , GPIOC_BASE + 0x00 .equ GPIOC_CRH , GPIOC_BASE + 0x04 .equ GPIOC_IDR , GPIOC_BASE + 0x08 .equ GPIOC_ODR , GPIOC_BASE + 0x0C .equ GPIOC_BSRR , GPIOC_BASE + 0x10 .equ GPIOC_BRR , GPIOC_BASE + 0x14 .equ GPIOC_LCKR , GPIOC_BASE + 0x18 .equ RCC_APB2ENR, 0x40021018 .equ SYSTICK , 0xE000E010 .equ _CTRL , 0x00 .equ _LOAD , 0x04 .equ _CALIB , 0x0C .equ _CURRENT , 0x08 .equ LEDDELAY , 100000 .equ LEDDELAY2 , 800000 .align.global _start.global SysTick_handler.section .text.org 0vectors: @ Vectors .word STACKINIT .word _start + 1 .word _nmi_handler + 1 .word _hard_fault + 1 .word _memory_fault + 1 .word _bus_fault + 1 .word _usage_fault + 1 .org 0x0000003C .word SysTick_handler + 1 _start: ldr r6, = RCC_APB2ENR mov r0, #0x10 @ Port C Eneable str r0, [r6] ldr r6, =GPIOC_CRH ldr r0, = 0x444433 @ Port C8 dan C9 output 50Hz str r0, [r6] Systick_Init: cpsid i LDR R0, =SYSTICK @ SYSTICK control and status register MOV R1, #0 STR R1, [R0] @ Stop counter to prevent interrupt triggered accidentally LDR R1, =8000000 STR R1, [R0,_LOAD] @ Write reload value to reload register address STR R1, [R0,_CURRENT] @ Write any value to current value @ register to clear current value to 0 and clear COUNTFLAG MOV R1, #0x7 @ Clock source = core clock, Enable Interrupt, Enable Counter STR R1, [R0] @ Start counter cpsie i loop: ldr r6, =GPIOC_BSRR ldr r5, =LEDDELAY delay1: subs r5, 1 bne delay1 mov r2, #0x200 @ turn on port C8 str r2, [r6] ldr r5, = LEDDELAY delay2: subs r5, 1 bne delay2 mov r2, #0x2000000 @ turn off port C8 str r2, [r6] b loop_dummy: @ if any int gets triggered, just loop_nmi_handler:_hard_fault:_memory_fault:_bus_fault:_usage_fault: ldr r6, =GPIOC_BSRR ldr r5, =LEDDELAY2 delay3: subs r5, 1 bne delay3 mov r2, #0x300 @ turn on port C8 and C9 str r2, [r6] ldr r5, = LEDDELAY2 delay4: subs r5, 1 bne delay4 mov r2, #0x3000000 @ turn off portC8 and C9 str r2, [r6] b _dummySysTick_handler: @ isr routine ldr r6, =GPIOC_BSRR mov r2, #0x300 @ turn on port C9 str r2, [r6] bx lrMy goal just blink the led in pin C8 in the loop sectionand when the systick interrupt is triggered, the pin C9 in setif there is error, the pin C8 and C9 are blink together.In the first 1 second everything is running well, means C8 blink successfullywhen the systick interrupt is triggered, it should be turning on C9 onlyBut i always got error (hard fault) , means C8 and C9 blink together ( _dummy loop)I tried to add this code:LDR R1, =0xE000ED22 @ Set the PendSV exception priority (lowest)LDR R2, =0xFFSTRB R2, [R1] LDR R1, =0xE000ED23 @ Set the SysTick exception priority (lowest)LDR R2, =0xFFSTRB R2, [R1]but nothing change.Does anyone can help me !Thanks.