Answer the question
In order to leave comments, you need to log in
How to handle interrupts in STM8 without using SPL?
I use the compiler from Cosmic, as an IDE I use STVD. I would like to know how to write interrupt handlers without using SPL. Let's say a timer interrupt. I set up the registers of the desired timer, I did everything right, but what's next?
Answer the question
In order to leave comments, you need to log in
Found it myself. An interrupt vector is created in STVD. We write the function in main.c:
\@far \@interrupt IRQ_Handler_TIM4(void)
{
/*code is located here*/
return;
}
after which we write it to main.h, and also do not forget to enter the main.h file into the interrupt vector file and enter the handler into the vector itself (for TIM4 on STM8S003 this is interrupt 23). Also, do not forget to enable interrupts with the RIM assembler command (_asm("RIM\n");) That's it, it works, subject to the conditions that you specified when setting up the timer.
Possible rake:
1. Correctly configured the timer, enabled interrupts, everything compiled, but the interrupt does not occur. Solution: they forgot to apply clocking to the timer (ST has such a fetish).
2. Event interrupt not enabled. Solution: set the timer according to the Reference manual for the desired chip.
In fact, there are many rakes, the main thing is to carefully study the Reference manual, especially the description of the registers.
What is the advantage of abandoning SPL: you always know how it works, program execution is accelerated (fewer function calls) and the size of the firmware is reduced (less extra code) (in particular, the size of the firmware has decreased from 3 kilobytes to 800 bytes with the same functionality).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question