cancel
Showing results for 
Search instead for 
Did you mean: 

How to deal properly with weak interrupt function and override in assembler ?

bully
Senior

Hello,

I have problems with implementation of weak default function and override with real function in assembler.

I have this in startup.s (usually all functions are defined like this):

.weak      SysTick_Handler
.thumb_set SysTick_Handler,Default_Handler

and then have defined function in main.s:

.global SysTick_Handler
.type  SysTick_Handler, %function
 
SysTick_Handler:
    push {r3, r4, r5, r6, lr}
...

if I comment those two lines in startup,s, then proper SysTick_Handler gets triggered, otherwise it ends in Default_Handler. I'm obviously doing something wrong ?

Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
  .syntax unified
  .cpu cortex-m7
  .fpu softvfp
  .thumb
 
...
 
  .global SysTick_Handler
  .section  .text.SysTick_Handler,"ax",%progbits
  .type  SysTick_Handler, %function
 
SysTick_Handler:
    push {r3, r4, r5, r6, lr}
...
  .size  SysTick_Handler, .-SysTick_Handler

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3
  .syntax unified
  .cpu cortex-m7
  .fpu softvfp
  .thumb
 
...
 
  .global SysTick_Handler
  .section  .text.SysTick_Handler,"ax",%progbits
  .type  SysTick_Handler, %function
 
SysTick_Handler:
    push {r3, r4, r5, r6, lr}
...
  .size  SysTick_Handler, .-SysTick_Handler

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hello,

have tried to replicate your advice, but I still get into Default_Handler.

It doesn't seem to help, I have to comment second line in startup.s.

. Can I check in some output docs what could be wrong ?

   .weak      SysTick_Handler
//   .thumb_set SysTick_Handler,Default_Handler

And I have this in main.s

  .global SysTick_Handler
  .section  .text.SysTick_Handler,"ax",%progbits
  .type  SysTick_Handler, %function
 
SysTick_Handler:
    push {r3, r4, r5, r6, lr}
 
//    adr	r3,LEDSTAT
//    ldr r4,[r3]
//    cmp	r4,#0
    add r8,r8,#1
    cmp r8,#500
    blo RET
 
    mov	r8,#0    // reset ms counter
 
    cmp r7,#0    // check flag
	beq LOFF
 
	mov r5, #LEDs_OFF
//	mov r4,#0
//    str r4,[r3]
    mov r7,#0
 
	b CONT
 
 .size  SysTick_Handler, .-SysTick_Handler
 

Thanks and regards.