Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:26 07 Jul 2025 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Interrupts colliding?

Author Message
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:05am 15 Jul 2016
Copy link to clipboard 
Print this post

Hi All,

I read on page 39,

[Quote]If two or more interrupts occur at the same time they will be processed in order of the interrupts as defined with SETPIN.
During the processing of an interrupt all other interrupts are disabled until the interrupt subroutine returns.[/quote]

What happens with timed interrupts?

As in:-

[Code]
SETTICK 5000,CheckMainSensors,1

SETTICK 30000,CheckOtherSensors,2
[/code]

Both would be expected to be called at the 30 second mark etc.
Regardless of the times set, they would always meet up at numbers divisible by both times.

Wondering which gets precedence & if there are any issues.

Thanks

Phil.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6269
Posted: 12:58pm 15 Jul 2016
Copy link to clipboard 
Print this post

The two interrupts would have been set at different times at the start of your program so they should continue in the original order.

I wouldn't trust the timing to stay that close so I prefer to take control of the sequences myself.

One master timer and call the subs as required.

SETTICK 5000, tick, 1





SUB tick
CheckMainSensors
ticktock = ticktock + 1
IF ticktock MOD 6 = 0 THEN
CheckOtherSensors
ENDIF

END SUB

This has the CheckMainSensors sub first.

You can have as many subs being called at any interval in whatever order you desire.
You will have to manage the ticktock variable to prevent overflow.

Jim
VK7JH
MMedit
 
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025