Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 21:04 28 Nov 2024 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 : Settick

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 926
Posted: 07:42pm 24 Jan 2014
Copy link to clipboard 
Print this post

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: Australia
Posts: 926
Posted: 08:04pm 24 Jan 2014
Copy link to clipboard 
Print this post

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: Australia
Posts: 6101
Posted: 08:11pm 24 Jan 2014
Copy link to clipboard 
Print this post


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: Thailand
Posts: 2209
Posted: 09:12pm 24 Jan 2014
Copy link to clipboard 
Print this post

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]
Edited by TZAdvantage 2014-01-26
Microblocks. Build with logic.
 
Print this page


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

© JAQ Software 2024