![]() |
Forum Index : Microcontroller and PC projects : Interrupts colliding?
Author | Message | ||||
Phil23 Guru ![]() Joined: 27/03/2016 Location: AustraliaPosts: 1667 |
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: AustraliaPosts: 6269 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |