Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:07 27 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
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 12:33am 24 Jun 2013
Copy link to clipboard 
Print this post

Can anyone show me a few lines of code that demonstrate how to use SETTICK and IRETURN.
thanks
cliff
Cliff
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:16am 24 Jun 2013
Copy link to clipboard 
Print this post

[code]
'Every second
SETTICK 1000, ShowTime

'Endless loop until a key is pressed
'If you do not have this your program will END
DO WHILE INKEY$ = "": LOOP

ShowTime:
PRINT TIME$
IRETURN

Edited by TZAdvantage 2013-06-25
Microblocks. Build with logic.
 
Nixie
Regular Member

Joined: 19/02/2013
Location: Australia
Posts: 66
Posted: 11:53am 24 Jun 2013
Copy link to clipboard 
Print this post

Hmmmm I also still haven't got a grip on the SETTICK command.
I've looked at the notes, but it still hasn't stuck with me.
When it was mentioned to me in a post, a long time ago, I did have a play. But I too couldn't find much info in the manuals - especially in examples and also on this site.
Perhaps I missed something?

I solved what I was doing with TIMER and PAUSE. So if someone cold explain the value in this command, I'd e most grateful for enlightenment! Thanks, Nic.
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6100
Posted: 02:38pm 24 Jun 2013
Copy link to clipboard 
Print this post

For my data acquisition application, I wanted to read some of the data every second and the remainder every 10 seconds.
using :
SETTICK 1000,_readAll

and then in the _readAll sub:
...do the one second stuff
ticks=ticks+1

if ticks mod 10=0 then... do the 10 second stuff


etc

It doesn't matter how long the routine take provided its less than the settick interval.
the SETTICK 1000 does all the time keeping.

If you have a routine that might take longer than the interval such as waiting for user input. use SETTICK 0,0 to disable it and then restart when the slow routine has finished.

Jim


VK7JH
MMedit   MMBasic Help
 
panky

Guru

Joined: 02/10/2012
Location: Australia
Posts: 1101
Posted: 04:20pm 24 Jun 2013
Copy link to clipboard 
Print this post

..... or simply,

SETTICK is an interrupt driven timer that has two arguments; the interrupt interval in milliseconds and a label that points to an interrupt service routine which must end with IRETURN.

Cheers, Doug.

... almost all of the Maximites, the MicromMites, the MM Extremes, the ArmMites, the PicoMite and loving it!
 
robert.rozee
Guru

Joined: 31/12/2012
Location: New Zealand
Posts: 2350
Posted: 04:51pm 24 Jun 2013
Copy link to clipboard 
Print this post

  TZAdvantage said   [code]
'Every second
SETTICK 1000, ShowTime

'Endless loop until a key is pressed
'If you do not have this your program will END
DO WHILE INKEY$ = "": LOOP

ShowTime:
PRINT TIME$
IRETURN



shouldn't there be some sort off exit or stop statement after the "DO WHILE" loop to stop the program executing the interrupt routine once after a key has been pressed and throwing an error (?) when it hits an IRETURN that has no place to return to?
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 05:13pm 24 Jun 2013
Copy link to clipboard 
Print this post

Good point.
I am used to SUB or FUNCTION and those are not run when you press a key.
The subroutines with a label are something that have to be used with interrupt routines. I read Geoff is planning to add SUB and FUNCTION called from interrupts. That should prevent small errors like this.
I try to avoid subroutine labels and use them only when absolutely necessary.


Microblocks. Build with logic.
 
centrex

Guru

Joined: 13/11/2011
Location: Australia
Posts: 320
Posted: 10:53pm 24 Jun 2013
Copy link to clipboard 
Print this post

Thanks TZ
It worked perfectly, now I know what I am looking for.
Thanks to all the others as always you are helpful.
Regards
Cliff
Cliff
 
Nixie
Regular Member

Joined: 19/02/2013
Location: Australia
Posts: 66
Posted: 11:47am 25 Jun 2013
Copy link to clipboard 
Print this post

Thanks to all. That has given me a much better grip on SETTICK - much appreciated!
Cheers, Nic
 
Print this page


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

© JAQ Software 2024