![]() |
Forum Index : Microcontroller and PC projects : ON ERROR SKIP and Interrupts
![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10315 |
Wow ![]() ![]() ![]() |
||||
Turbo46![]() Guru ![]() Joined: 24/12/2017 Location: AustraliaPosts: 1642 |
Very very nice! ![]() 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: GermanyPosts: 675 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 10315 |
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 KingdomPosts: 4311 |
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 StatesPosts: 3378 |
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: GermanyPosts: 675 |
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). 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 StatesPosts: 3378 |
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 KingdomPosts: 4311 |
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 KingdomPosts: 10315 |
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 KingdomPosts: 4311 |
I hoped you would say that. 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 |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |