Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:47 10 Nov 2025 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 : Interupts During Input

Author Message
OA47

Guru

Joined: 11/04/2012
Location: Australia
Posts: 1013
Posted: 11:15am 07 Oct 2017
Copy link to clipboard 
Print this post

Am I right in assessing that all interrupts initiated by SETTICK are paused whilst MMBasic is waiting for an INPUT variable?
 
atmega8

Guru

Joined: 19/11/2013
Location: Germany
Posts: 727
Posted: 04:57pm 07 Oct 2017
Copy link to clipboard 
Print this post

I could not find it in the Manual.

But four lines of testcode and you know the answer.
Let us know...
 
goc30

Guru

Joined: 12/04/2017
Location: France
Posts: 435
Posted: 05:04pm 07 Oct 2017
Copy link to clipboard 
Print this post

hI
Normally the "Timer" interrupt is the highest priority, before the hardware interrupts (and just after the system interruption). I do not know how MMBasic handles this, but with the "Settick" function, I think that it increments soft counters, and in this case generates a pseudo interrupt. other case is in uses of proc's internal counters. In the latter case, the language must recover the interrupt and dispatch it, which is not simple for an interpreted language like Basic, because it need to use a small OS or core.
but this is only my opinion, not on what is true

you can see how Microchip use core timer interrupt in this exemple
2017-10-08_031420_example.zip Edited by goc30 2017-10-09
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 117
Posted: 05:09pm 07 Oct 2017
Copy link to clipboard 
Print this post

Hi,
I believe Geoff wrote it so it only checks after a complete instruction has completed. I think the reasoning behind that you need a 'known state' in case of returning from an interrupt routine. You can always create your own variable input function using Inkey$ which will allow your interrupts to work fine, if you're interested in making 'real-time' code.

Regards,
Phil
 
Grogster

Admin Group

Joined: 31/12/2012
Location: New Zealand
Posts: 9749
Posted: 05:56pm 07 Oct 2017
Copy link to clipboard 
Print this post

....as atmega8 says.

However, I seem to recall that the way that MMBSAIC interrupts work, is that the interpreter checks for any interrupt at the end of each instruction, so what flip says is correct I think.

With respect to OA47's question, I think he would probably be correct - the interrupts will stop until the INPUT command returns with something. Not tested though - follow atmega8's advice, and write a few lines to test it.
Smoke makes things work. When the smoke gets out, it stops!
 
flip
Senior Member

Joined: 18/07/2016
Location: Australia
Posts: 117
Posted: 07:18pm 07 Oct 2017
Copy link to clipboard 
Print this post

Hi,
Further to this...here is some code that works OK on MMBasic for Dos...should be OK on Micromite versions...uses Backspace, Enter and Escape (and any normal printable Ascii keys)...should be interruptable.
I'd be interested too to see what gets you over the line...

Function GetStrInput$(prmpt$,dflt$)
Local c$
Local s$=dflt$
? Chr$(13);prmpt$;s$;
Do
c$=Inkey$
Select Case Asc(c$)
Case 0 ' nothing pressed yet
Case 13:?:GetStrInput$=s$:Exit Function
Case 8 'Backspace - print string less the last character
If Len(s$) Then
s$=Left$(s$,Len(s$)-1)
? Chr$(13);prmpt$;s$;" ";
? Chr$(13);prmpt$;s$;
Else
? Chr$(7); ' Beep (zero length string - can't backspace)
EndIf
Case 32 To 126: s$=s$+c$: ? c$;
Case 27:?:Exit Function ' Escape pressed...return nothing
Case Else:? Chr$(7); ' Beep - non-printable character
End Select
Loop
End Function

'Test using following
YourPrompt$="Enter text (use <BKSPC> if required), then press <Enter> (or press <ESC> to Cancel) > "
YourVariable$="default"
Do
YourVariable$=GetStrInput$(YourPrompt$,YourVariable$)
? "You typed '";YourVariable$;"'"
Loop While Len(YourVariable$)


[Edit] minor edit to tidy up and comments and addition to include default value capability
Regards PhilEdited by flip 2017-10-09
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 09:07pm 07 Oct 2017
Copy link to clipboard 
Print this post

... another reason to use a nice input sub with control Edited by CaptainBoing 2017-10-09
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025