2021-11-02 06:38 AM
Hi,
I'm new to STM8 (usually I develop from STM32) and I'd like to know how can I enable interrupts.
In STM32, I usually configure the peripheral interrupt enable bit and also in the NVIC I enable the interrupt to pass it from peripheral to CPU.
In STM8S I thought the approach was the same.
I'm finding the peripheral interrupt enable (e.g. the interrupt enable for the timer on TIM1_IER register) but I'm not finding how to enable it (and if needed) from the CPU side.
In addition, I read that at the end of the interrupt routine, a IRET instruction is required.
Should I manage it? And how?
By the way I'm using ST Visual Develop with COSMIC compiler and the CPU I'm referring to is the STM8S003K3.
Is there a working example or simple explanations?
EDIT: In the reference manual I also found
#asm
PUSH ISR_CC
POP CC
#endasm
but don't know what is ISR_CC
Thanks and best regards.
2021-12-14 02:00 AM
Hello,
In case of STM8 devices you need to unmask interrupts after the reset. To do this you can use asm instruction rim (remove interrupt mask). In case you are using COSMIC C compiler you can invoke it by command: _asm("rim");
Let me share with you some training materials we have used some time ago which demonstrates simple use cases with and without STM8 standard peripheral library usage.
You can find more examples for STM8S either within its library pack:
https://www.st.com/en/embedded-software/stsw-stm8069.html
or within dedicated set of optimized examples which are using direct operations on registers.
https://www.st.com/en/embedded-software/stsw-stm8026.html
I hope it helps.
Best Regards
2021-12-15 08:03 AM