|
Forum Index : Microcontroller and PC projects : Interupts During Input
| Author | Message | ||||
| OA47 Guru Joined: 11/04/2012 Location: AustraliaPosts: 1013 |
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: GermanyPosts: 727 |
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: FrancePosts: 435 |
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 |
||||
| flip Senior Member Joined: 18/07/2016 Location: AustraliaPosts: 117 |
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 ZealandPosts: 9749 |
....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: AustraliaPosts: 117 |
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 Phil |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
... another reason to use a nice input sub with control |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |