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: AustraliaPosts: 320 |
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: ThailandPosts: 2209 |
[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 Microblocks. Build with logic. |
||||
Nixie Regular Member Joined: 19/02/2013 Location: AustraliaPosts: 66 |
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: AustraliaPosts: 6100 |
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: AustraliaPosts: 1101 |
..... 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 ZealandPosts: 2350 |
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: ThailandPosts: 2209 |
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: AustraliaPosts: 320 |
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: AustraliaPosts: 66 |
Thanks to all. That has given me a much better grip on SETTICK - much appreciated! Cheers, Nic |
||||
Print this page |