Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 05:30 02 Aug 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 : ON ERROR SKIP and Interrupts

     Page 3 of 3    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 09:24pm 10 Apr 2022
Copy link to clipboard 
Print this post

Wow      
 
Turbo46

Guru

Joined: 24/12/2017
Location: Australia
Posts: 1642
Posted: 11:26pm 10 Apr 2022
Copy link to clipboard 
Print this post

Very very nice!  

  Quote  I ask as an appreciative and frequent user of MMBasic DOS: Is there any functional reason to use it now instead of MMB4W?

Because I am pig-headed. MMB4W is still in beta and I want my programs to run on as many MMBasic platforms as it can.

Plus no-one has shown me a better way.

I agree that ON ERROR should not be a catch-all for lazy programming but it has its uses. In my program in question, the user creates database files and some must be created before others can be and I need a way of checking this. I found no other way to check that the files had been created. I cannot set flags to indicate this because the program will be re-run several (many) times to refine the data structure after testing. I could save those flags in yet another file but how would I know if that one  existed?

Bill

EDIT: I found a way:
From the manual - I can use the SYSTEM command:

SYSTEM "DIR /b > flist.txt"

Then open that file and search in it for the filename I want. I think I stick with the way I am doing it.
Edited 2022-04-11 18:09 by Turbo46
Keep safe. Live long and prosper.
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 675
Posted: 08:35am 11 Apr 2022
Copy link to clipboard 
Print this post

  lizby said  Neat case. Glad to see the 2x20 connector. What's it look like inside?


There is an piggyback PCB for a speaker and class d amplifier with EMI
-filter too. But I didn't want to take the case apart again for a picture.

 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 09:50am 11 Apr 2022
Copy link to clipboard 
Print this post

  matherp said  Tom:

If you want the fix the changes are in MM_Misc.c. OPTION ERROR IGNORE sets OptionErrorSkip to minus-1 so this would work in both the main code and the interrupt


Thanks Peter, I've been keeping an eye on your GitHub for PicoMite and MMB4W.

Have you considered this case:

10  ' Code to setup interrupt omitted

20  ON ERROR SKIP
30  COMMAND_THAT_DOESN'T FAIL
40  If MM.ERRNO <> 0 Then PRINT "Fail in main code: " MM.ERRMSG$
50  END

60  SUB interrupt
70    ON ERROR SKIP
80    COMMAND_THAT_DOES_FAIL
90    If MM.ERRNO <> 0 Then PRINT "Fail in interrupt: " MM.ERRMSG$
100 END SUB


If the interrupt is called between lines 30 and 40 then I think line 40 will (IMO incorrectly) report the error thrown from line 80.

Best wishes,

Tom
Edited 2022-04-11 19:50 by thwill
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 10:26am 11 Apr 2022
Copy link to clipboard 
Print this post

  Quote  If the interrupt is called between lines 30 and 40 then I think line 40 will (IMO incorrectly) report the error thrown from line 80.


Is this supposition or have you demonstrated it?

Does it matter anyway? Does anyone but you use error numbers or error messages?
Edited 2022-04-11 20:28 by matherp
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:28am 11 Apr 2022
Copy link to clipboard 
Print this post

  matherp said  Is this supposition or have you demonstrated it?


Only supposition, though it is on my TODO list.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 12:31pm 11 Apr 2022
Copy link to clipboard 
Print this post

  Amnesie said  But I didn't want to take the case apart again for a picture.


Nice work. What do you use the INA219 for--I've not seen that part used before?

Did you have a specific reason for running the ADC pins to the 2x20 connector and relatively few other pins (or had you run out of "other pins")?

~
Edited 2022-04-11 22:32 by lizby
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 675
Posted: 01:16pm 11 Apr 2022
Copy link to clipboard 
Print this post

  lizby said  
  Amnesie said  But I didn't want to take the case apart again for a picture.


Nice work. What do you use the INA219 for--I've not seen that part used before?

Did you have a specific reason for running the ADC pins to the 2x20 connector and relatively few other pins (or had you run out of "other pins")?

~


The INA219 is used on the SYSTEM I2C bus and works as an option to messure voltage and current of a some devices to visualize / plot it graphically on the VGA screen. Since it can handle voltages up to 26 volts and 3A it can be used with a lot of projects in mind. And it luckily was used before! There is even a whole port of an (arduino?) library here! I tested the code and it works pretty well.

I routed the ADC-pins, including direct sperate GND to the 2x20 connector in case I need the Pico to use it's internal ADC (which is not really good and has some flaws documented in the pico documentation) But maybe there are cases I need to process data as fast as possible, which is not possible via I2C-bus (minimal latency).

  Quote  relatively few other pins


I routed almost all available pins to the conncetor which are not used by the system components like SD card, VGA etc. because I don't need them "externally", the only exception is the SYSTEM I2C bus, which is also available on the 2x20p connector.

I dislike the fact that the original picoVGA-PCB has every single pin, even VGA pins routed to the 2x20 connector - for me - I don't see any reason to this for doing so. And this doesn't mean that it is useless. It is just not what I need and it is not such a routing nest (stray capacitance etc etc) with two additional footprints of the pico on the PCB. But again, I understand the point of beeing compatible with some Pico add-on-boards. I just designed the PCB to fit my needs :)
Edited 2022-04-11 23:40 by Amnesie
 
lizby
Guru

Joined: 17/05/2016
Location: United States
Posts: 3378
Posted: 02:42pm 11 Apr 2022
Copy link to clipboard 
Print this post

Thanks. I'll keep that INA219 in mind.
PicoMite, Armmite F4, SensorKits, MMBasic Hardware, Games, etc. on fruitoftheshed
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 09:07am 12 Apr 2022
Copy link to clipboard 
Print this post

  thwill said  Only supposition, though it is on my TODO list.


Supposition no longer:
> list "interrupt_test_2.bas"
Option Console Both
Option Base 0
Option Default None
Option Explicit Off

Timer = 0

SetTick 20, my_interrupt

On Error Skip
Pause 40
If Mm.ErrMsg$ <> "" Then ? "main: unexpected error: " Mm.ErrMsg$
End

Sub my_interrupt()
 ? "Interrupt entered"
 ? Timer
 On Error Skip
 Open "file-that-does-not-exist" For Input As #1
 If Mm.ErrMsg$ = "" Then
   ? "my_interrupt: expected error did not occur!"
 Else
   ? "my_interrupt: " Mm.ErrMsg$
 EndIf
 ? "Interrupt exited"
End Sub
> run
Interrupt entered
22.9601
my_interrupt: Error in line 19: Failed to open file C:\home-thwill\git_sandbox\github\file-that-does-not-exist
Interrupt exited
main: unexpected error: Error in line 19: Failed to open file C:\home-thwill\git_sandbox\github\file-that-does-not-exist    <========== THIS LINE
Interrupt entered
47.4794
my_interrupt: Error in line 19: Failed to open file C:\home-thwill\git_sandbox\github\file-that-does-not-exist
Interrupt exited
>


And while we are messing with interrupts, this sometimes runs forever (?) on CMM2, MMB4W (and MMB4L):
> list "interrupt_test.bas"
Option Console Both
Option Base 0
Option Default None
Option Explicit Off

Timer = 0

SetTick 5, my_interrupt
Pause 10
End

Sub my_interrupt()
 ? "Interrupt entered"
 Print Timer
 Local i%
 For i% = 1 To 100000 : Next
 ? "Interrupt exited"
End Sub
> run "interrupt-test.bas"
Interrupt entered
8.4482
Interrupt exited
Interrupt entered
21.5915
Interrupt exited
Interrupt entered
33.5412
Interrupt exited
...


I know what you're going to say "Don't perform long tasks in interrupts", but I thought it was still an interesting observation .

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10315
Posted: 10:26am 12 Apr 2022
Copy link to clipboard 
Print this post

The first is fixable by saving then clearing MMerrno and MMErrMsg in gotaninterupt and restoring them in Ireturn

The second appears to be insoluble
 
thwill

Guru

Joined: 16/09/2019
Location: United Kingdom
Posts: 4311
Posted: 10:35am 12 Apr 2022
Copy link to clipboard 
Print this post

  matherp said  The first is fixable by saving then clearing MMerrno and MMErrMsg in gotaninterupt and restoring them in Ireturn


I hoped you would say that.

  Quote  The second appears to be insoluble


Ack. I will take a look myself when I get to this point in MMB4L and let you know if I find differently.

Best wishes,

Tom
MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures
 
     Page 3 of 3    
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