Skip to main content
bully
Senior
September 18, 2022
Solved

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

  • September 18, 2022
  • 2 replies
  • 1810 views

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.

This topic has been closed for replies.
Best answer by Tesla DeLorean
 .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

2 replies

Tesla DeLorean
Guru
September 18, 2022
 .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 VenmoUp vote any posts that you find helpful, it shows what's working..
bully
bullyAuthor
Senior
October 28, 2022

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.

Piranha
Principal III
September 20, 2022