![]() |
Forum Index : Microcontroller and PC projects : Settick
Author | Message | ||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
I have an interupt set for every 10 minutes to check and analyse pins. SetTick 600000, CheckAnalogs,1 Is there a way of calling this interupt routine at program startup without having to duplicate the code as a subroutine? |
||||
OA47 Guru ![]() Joined: 11/04/2012 Location: AustraliaPosts: 982 |
OK. Should have thought longer, I set a flag on startup and gave the routine a RETURN if the Startup flag was set, before the IRETURN. Startup=1: GOSUB CheckAnalogs / / CheckAnalogs: / / / / / If Startup=1 then Startup=0: RETURN IRETURN |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6265 |
firstrun = 1
settick 100, CheckAnalogs, 1 do loop end CheckAnalogs: if firstrun = 1 then settick 600000, CheckAnalogs, 1 firstrun = 0 endif print "Checking at "+time$ ireturn Jim VK7JH MMedit |
||||
MicroBlocks![]() Guru ![]() Joined: 12/05/2012 Location: ThailandPosts: 2209 |
You might want to consider using defined Subroutines. It will also stop code going into a subroutine unwanted. You could then call that subroutine the first time and also use it for an interrupt routine. You do not need to use an IRETURN when using defined subroutines. It makes code easier to write and reuse. [code] CheckAnalogs settick 600000, CheckAnalogs, 1 do loop SUB CheckAnalogs print "Checking at "+time$ END SUB [/code] Microblocks. Build with logic. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |