Home  |  Contents 

Microcontroller and PC projects
  Forum Index : Microcontroller and PC projects         Section
Subject Topic: Question about settick Post ReplyPost New Topic
Page of 2 Next >>
Author
Message << Prev Topic | Next Topic >>
Quazee137
Senior Member
Senior Member
Avatar

Joined: 07 August 2016
Location: United States
Online Status: Offline
Posts: 162
Posted: 15 April 2018 at 12:55am | IP Logged Quote Quazee137


settick never fires while waiting for console input.

Is that how it should be working?


  Option EXPLICIT
  SetTick 1000,tock,4
  Dim k, count=0

Do
 Input "Waiting for tick to fire  ";k
 Print "main loop "; count
Loop

Sub tock
 count=count+1
 Print "Ding Dong ";count
End Sub



Back to Top View Quazee137's Profile Search for other posts by Quazee137
 
MicroBlocks
Guru
Guru
Avatar

Joined: 12 May 2012
Location: Thailand
Online Status: Offline
Posts: 2192
Posted: 15 April 2018 at 2:46am | IP Logged Quote MicroBlocks

Yes.
Use inkey$ instead.


__________________
Microblocks. Build with logic.
Back to Top View MicroBlocks's Profile Search for other posts by MicroBlocks
 
twofingers
Guru
Guru


Joined: 02 June 2014
Location: Germany
Online Status: Offline
Posts: 625
Posted: 15 April 2018 at 5:43am | IP Logged Quote twofingers

MB is correct.

From the MMbasic manual for Maximites (v4.5)
Quote:
Up to four periodic interrupts (or regular “ticks”) with periods specified in milliseconds can be setup using the SETTICK statement. This interrupt has the lowest priority. Using the ON KEY command an interrupt can be generated whenever a key is pressed.
Interrupts can occur at any time but they are disabled during INPUT statements. If you need to get input from the keyboard while still accepting interrupts you should use the INKEY$ function or the ON KEY command.
When using interrupts the main program is completely unaffected by the interrupt activity unless a variable used by the main program is changed during the interrupt


EDIT:
I did not find the text above (about interrupts) in the manual for the Micromites (v5.4). Geoff should maybe complete that.

I think this could be a replacement for Input (and LINE INPUT) that works with SETTICK (not tested).

Michael

Edited by twofingers on 15 April 2018 at 6:31am
Back to Top View twofingers's Profile Search for other posts by twofingers
 
CaptainBoing
Guru
Guru
Avatar

Joined: 07 September 2016
Location: United Kingdom
Online Status: Offline
Posts: 687
Posted: 15 April 2018 at 7:47am | IP Logged Quote CaptainBoing

Quazee137 wrote:

settick never fires while waiting for console input.

Is that how it should be working?



yes.

Input is a very blunt instrument and as you have discovered, once you disappear inside it your own program loses control of things until INPUT returns.

There was a thread a little while back where a number of options were posted that give you much better functions that play nice with your code and still give you the input you require as shown in rave's link in the previous post and Peter63 function here

Edited by CaptainBoing on 15 April 2018 at 7:51am
Back to Top View CaptainBoing's Profile Search for other posts by CaptainBoing
 
Quazee137
Senior Member
Senior Member
Avatar

Joined: 07 August 2016
Location: United States
Online Status: Offline
Posts: 162
Posted: 15 April 2018 at 2:55pm | IP Logged Quote Quazee137


Thanks everyone for the replies.

I looked in the 5.4 manual for the Micromites and did not see any thing
showing it would not work.

This will also apply to LINE INPUT ?

So inkey$ will do.

Quazee
Back to Top View Quazee137's Profile Search for other posts by Quazee137
 
Geoffg
Guru
Guru
Avatar

Joined: 06 June 2011
Location: Australia
Online Status: Offline
Posts: 2446
Posted: 15 April 2018 at 4:03pm | IP Logged Quote Geoffg

twofingers wrote:
I did not find the text above (about interrupts) in the manual for the Micromites (v5.4). Geoff should maybe complete that.

Page 40.
Back to Top View Geoffg's Profile Search for other posts by Geoffg Visit Geoffg's Homepage
 
Quazee137
Senior Member
Senior Member
Avatar

Joined: 07 August 2016
Location: United States
Online Status: Offline
Posts: 162
Posted: 15 April 2018 at 4:32pm | IP Logged Quote Quazee137

Geoffg is there an updated version of the 5.4 MicroMite user manual?

Page 40 shows information on the Timing related to

PAUSE, PULSE, TIMER and SETTICK.


Quazee


Thanks. Found it on 38 and 39 under Interrupts


Edited by Quazee137 on 15 April 2018 at 4:34pm
Back to Top View Quazee137's Profile Search for other posts by Quazee137
 
CaptainBoing
Guru
Guru
Avatar

Joined: 07 September 2016
Location: United Kingdom
Online Status: Offline
Posts: 687
Posted: 15 April 2018 at 11:21pm | IP Logged Quote CaptainBoing

Quazee137 wrote:

So inkey$ will do.


Not on its own. INKEY$ grabs any *single* character waiting in the buffer, if there's nothing waiting you get the empty string ""

So what you'll have to do is grab characters in a loop and build up your input data in a string variable, generally until INKEY$ returns character (13) - this is the enter key on most keyboards. Then will you have your "INPUT" string in your variable.

it isn't hard to do but if you want something canned, use one of the functions mentioned earlir.

I rarely use INPUT at all, only when I can afford to wait indefinitely in a program of for debugging etc. At any time in main threads where other things are happening in the background I always build up a string using the method above.

Edited by CaptainBoing on 15 April 2018 at 11:24pm
Back to Top View CaptainBoing's Profile Search for other posts by CaptainBoing
 
twofingers
Guru
Guru


Joined: 02 June 2014
Location: Germany
Online Status: Offline
Posts: 625
Posted: 15 April 2018 at 11:40pm | IP Logged Quote twofingers

Geoffg wrote:
twofingers wrote:
I did not find the text above (about interrupts) in the manual for the Micromites (v5.4). Geoff should maybe complete that.

Page 40.

Thanks Geoff. All good!
I found this
Quote:
Interrupts can occur at any time but they are disabled during INPUT statements.
on page 39 in the manual for Micromites (MM V5.04.08).
(I scanned the manual only for the occurence of SETTICK)

Michael


Back to Top View twofingers's Profile Search for other posts by twofingers
 
Grogster
Guru
Guru
Avatar

Joined: 31 December 2012
Location: New Zealand
Online Status: Offline
Posts: 6307
Posted: 16 April 2018 at 10:21am | IP Logged Quote Grogster

CaptainBoing wrote:
Quazee137 wrote:

So inkey$ will do.


Not on its own. INKEY$ grabs any *single* character waiting in the buffer, if there's nothing waiting you get the empty string ""


Yes indeed. I made that mistake a few times, when I thought that the keyboard input was buffered - it isn't. (well, not past one byte it isn't)

__________________
Smoke makes things work. When the smoke gets out, it stops!
Back to Top View Grogster's Profile Search for other posts by Grogster Visit Grogster's Homepage
 
CaptainBoing
Guru
Guru
Avatar

Joined: 07 September 2016
Location: United Kingdom
Online Status: Offline
Posts: 687
Posted: 16 April 2018 at 5:33pm | IP Logged Quote CaptainBoing

Grogster wrote:
... the keyboard input was buffered - it isn't. (well, not past one byte it isn't)


good point. You have to scan the keys (I always do it in in the main loop) fairly frequently and build up a global variable, I then set a flag when char(13) received so anything that needs to know about input gets signaled there is a complete line waiting.
Back to Top View CaptainBoing's Profile Search for other posts by CaptainBoing
 
MicroBlocks
Guru
Guru
Avatar

Joined: 12 May 2012
Location: Thailand
Online Status: Offline
Posts: 2192
Posted: 16 April 2018 at 6:35pm | IP Logged Quote MicroBlocks

?? Keyboard input is buffered otherwise you would miss keystrokes.
INKEY$ does not wait when there is nothing in the buffer.

I always make sure i use INKEY$ about every 200ms or faster. This will keep the user happy as longer times will be felt as being non responsive.



__________________
Microblocks. Build with logic.
Back to Top View MicroBlocks's Profile Search for other posts by MicroBlocks
 


Page of 2 Next >>
In the news...
 
Post ReplyPost New Topic
Printable version Printable version
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

Powered by Web Wiz Forums version 7.8
Copyright ©2001-2004 Web Wiz Guide

This page was generated in 0.1250 seconds.
Privacy Policy     Process times : 0, 0.02, 0, 0.11