cancel
Showing results for 
Search instead for 
Did you mean: 

Fast Interrupt in STM8S003

Paolo Rizzo
Associate
Posted on February 15, 2017 at 09:56

Hi,

for my project I use external port interrupt. When it come, I have to do an ADC conversion. The interrupt come every 5 us....is it possible to have an ADC conversion after interrupt every 5us?

I'm using discovery kit with STM8S003K3 MCU for test

m

y s

oftware

. Can I use the stm8s library? Because from my last test I see that  interrupt can not pass 15us....do you have some advice?

Thank you.

Paolo

#stm8-discovery #stm8 #adc #interrupt
2 REPLIES 2
Max
ST Employee
Posted on February 22, 2017 at 03:48

Hello,

For  this function, you should be using the external trigger feature of the ADC:

Look at chapter 24.5.7 Conversion on external trigger of

https://www.google.com.sg/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwiY46qo16LSAhVFKywKHRtUA9wQFggaMAA&url=http%3A%2F%2Fwww.st.com%2Fresource%2Fen%2Freference_manual%2FCD00190271.pdf&usg=AFQjCNEBwGhByhJX4hBCNhooiMA2CLCdkw

.

The SPL allows to use this mode.

BR

Max

raimond
Associate III
Posted on January 10, 2018 at 12:45

If the interrupt comes EVERY 5us I'm afraid you cannot keep the pace. Suppose you work on internal 16MHz clock. With this clock you need to divide by 3 to get the ADC clock 5.33MHz (it must be max. 6MHz at 5V, 4MHz at 3V). A conversion takes 14 adc clks that means 14*3 = 42 cpu clock. Interrupt overhead is 11+11 = 22 cpu clocks. You have already a 64 clks total. 5us is 80 cpu clocks. There are only 16 cpu clks left for your work, both inside and outside the ISR! And you must read the conversion result, store it somewhere or do some usefull work with it, etc.