0

I want a main routine that runs continually but can be interrupted. I am at a loss as to how to get the UART or ADC interrupt to work properly. They only behave as expected if my main loop has wait-for-interrupt (i.e. goes into low power mode). I understand that at reset the interrupt level in CCR is set to low and the level in the ITC_SPR registers is set to high, so main loop code should be interrupted. However if I run it without wfi I only get the first interrupt. If I call rim (enable interrupts) in the main code prior to the main loop, I get no interrupt, but this should force the main loop to low interrupt level. I'm very confused and obviously missing something because this seems like a normal operational mode that must work. Any ideas appreciated.

manny
  • 1
  • 1
  • do you clear interrupt flag in the ISR code? – Tirdad Sadri Nejad May 03 '21 at 15:56
  • Are your correcly work with your peripheral block (USART or ADC). It may become incative on errors (check CR register). Or may be you just don't clear interrupt flags from SR register. Or may be some issues in initialization and your peripheral block just not work as you expect. Share your code of init function, and irq handler. – imbearr May 19 '21 at 07:24
  • Does this answer your question? [stm8 uart tx interrupt issue](https://stackoverflow.com/questions/66396179/stm8-uart-tx-interrupt-issue) – imbearr May 19 '21 at 07:54

1 Answers1

0

In modern stm8 (2022-2023) peripherls library interrupts are set by XXX_ITConfig(interrupt_flag, ENABLE/DISABLE);

After checking them in main loop you MUST clear the pending bit or clear a flag by XXX_ClearItPendingFlag(interrupt_type) or XXX_ClearFlag;

These libraries are well known and available. For every peripheral they set different registers so if you want exact bit settings just look into them separately. I assure they work properly and interrupts do fire.

If someone has issues -> check peripherls library and set registers properly.

Elboyler
  • 87
  • 4