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 : Settick
Author | Message | ||||
OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 926 |
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: 926 |
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: 6101 |
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 MMBasic Help |
||||
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. |
||||
Print this page |