No interrupts from InterruptIn while inside a Ticker-service-routine?

22 Nov 2010

Hi all!

I'm testing around with a rotary-encoder(uses InterruptIn) and a DS1820 temperature-sensor (the readTemperature() is called every 15 seconds via ticker() to display the temperature)

Before reading the temperature one has to wait about 750ms with wait_ms().

Now it seems that the interrupts from the rotary-encoder (InterrruptIn) are blocked while inside the ticker-service-routine, which does the wait_ms() !

When I do a wait() in main no interrrupts are lost and everything is fine.

I'll try to create a simple testcase, but is it possible that the interrupts are blocked?

And how can I get those interrrupts, while in the ticker-handler?

Any ideas?

Charly

22 Nov 2010

Hi,

wait(), wait_ms() don't use interrupts, or block them.

However, a Ticker handler is an interrupt, so another interrupt will not fire until you return from the Ticker interrupt. So I think that just comes down to the code design pattern you use to avoid that situation occurring. For example, your interrupt could set a flag which is checked in your main loop.

That might be enough to solve your problem!

Simon

22 Nov 2010

Hi Simon!

Thanks a lot for the information!

That explains everything! I'll change my code and use a flag.

Charly