cancel
Showing results for 
Search instead for 
Did you mean: 

Enabling interrupts

MSeme.1
Associate II

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.

2 REPLIES 2
Artur IWANICKI
ST Employee

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

Hi, thanks for the answer.Actually the RIM instruction solved my problem.Thanks also for sharing the examples.Marco. Il martedì 14 dicembre 2021, 11:00:20 CET, ST Community ha scritto: @media only screen and ( _filtered_a ) {#yiv9561805269 html {}#yiv9561805269 table.yiv9561805269container {width:100% !important;}#yiv9561805269 .yiv9561805269hidden-for-mobile {display:none !important;}#yiv9561805269 .yiv9561805269callToAction, #yiv9561805269 .yiv9561805269callToAction td, #yiv9561805269 .yiv9561805269footer {font-size:12px !important;}#yiv9561805269 .yiv9561805269button .yiv9561805269text {font-size:12px !important;}#yiv9561805269 .yiv9561805269defaultIndentation {width:10 !important;}#yiv9561805269 .yiv9561805269text {font-size:12px !important;}#yiv9561805269 a.yiv9561805269button {width:96 !important;}#yiv9561805269 a.yiv9561805269buttonWide {width:118 !important;}#yiv9561805269 a.yiv9561805269buttonAuto {padding-left:1em !important;padding-right:1em !important;}#yiv9561805269 a.yiv9561805269button, #yiv9561805269 a.yiv9561805269buttonWide, #yiv9561805269 a.yiv9561805269buttonAuto {min-height:23 !important;line-height:23px !important;border-radius:4px !important;}#yiv9561805269 td.yiv9561805269buttonWrapper {width:98 !important;min-height:23 !important;}#yiv9561805269 img {display:inline !important;}#yiv9561805269 .yiv9561805269circle {border-radius:50%;}#yiv9561805269 .yiv9561805269square {border-radius:10%;}}@media only screen and ( _filtered_a ) {#yiv9561805269 table.yiv9561805269container {width:600px !important;}}@media screen { _filtered {}}#yiv9561805269 a, #yiv9561805269 a:visited {color:#015BA7;text-decoration:none;}#yiv9561805269 img {display:block;}#yiv9561805269 .yiv9561805269preheader {display:none !important;}#yiv9561805269 table {border-collapse:collapse;}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  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    Download (pdf) | Enabling interrupts 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. 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    Download (pdf) | To change or turn off ST Community email, log in as marco95_thebest@yahoo.it.st. Are notifications about this post getting annoying? Reply to this email with the word " mute". STMicroelectronics N.V.