Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 18:29 10 May 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 : PicoMite V6.00.02 betas

     Page 17 of 23    
Author Message
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10067
Posted: 09:25am 23 Feb 2025
Copy link to clipboard 
Print this post

javavi has created an edge case where there is just enough memory to allocate for the variable storage but not enough to complete the creation which would include some temporary memory usage. I don't intend to try an fix this as doing so would slow down all variable creation.
In all versions memory is partitioned between heap where strings and arrays are stored (amongst other things) and the hash table for simple variables and variable headers for strings and arrays. This is why there will typically be free memory showing even after the heap is full
 
javavi

Guru

Joined: 01/10/2023
Location: Ukraine
Posts: 436
Posted: 09:38am 23 Feb 2025
Copy link to clipboard 
Print this post

The same bug also appears with an integer array if the HEAP SIZE is slightly exceeded when creating it.
If the Heap size is exceeded by 256 bytes when creating an array, the array will be created and can be cleared.
If the Heap size is exceeded by 256 bytes + 1 array element when creating an array, the volume will go to the general one when clearing and will not be cleared.
> ? MM.Info(HEAP)
97792
> Dim d(12223) 'Array 12224 integers * 8 byte = 97792
> ? MM.Info(HEAP)
0
> clear
> ? MM.Info(HEAP)
97792  'OK
> Dim d(12223+32+1) 'Array 12224+32+1  integers = 97792+256+8 byte
> ? MM.Info(HEAP)
Error : Not enough Heap memory
> clear
> memory
RAM:
  0K ( 0%) 0 Var
 96K (77%) General
 28K (23%) Free

If you use the ERASE d command instead of the CLEAN command, the array is deleted normally and the Heap is cleared.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10067
Posted: 10:21am 23 Feb 2025
Copy link to clipboard 
Print this post

As I said I don't intend to look at this as fixing it would have significant performance implications. Also, if the memory is so full then it is guaranteed that the program would fail as soon as you try and do anything else. You have demonstrated a edge case artifact which has no general relevance.
Edited 2025-02-23 20:22 by matherp
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7504
Posted: 10:22am 23 Feb 2025
Copy link to clipboard 
Print this post

You're trying to break it. You naughty person.   ;)
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 529
Posted: 10:59am 23 Feb 2025
Copy link to clipboard 
Print this post

  matherp said  As I said I don't intend to look at this as fixing it would have significant performance implications. Also, if the memory is so full then it is guaranteed that the program would fail as soon as you try and do anything else. You have demonstrated a edge case artifact which has no general relevance.


You are right, I think the same, but maybe it would be good to mention this in the manual?

Greetings
Daniel
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7504
Posted: 11:10am 23 Feb 2025
Copy link to clipboard 
Print this post

Nah... If your program is that big the last thing you will be bothered about is the last bit of memory. It's not going to run, or even if it does manage to start the chances are that something will crash it unpredictably. Using the last bit of memory is something you do in assembler, not in a high level language where things are constantly changing.
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4854
Posted: 11:46am 23 Feb 2025
Copy link to clipboard 
Print this post

Kong also ran into it.

I think the difference with earlier releases is that there simply is less memory. I feel with larger programs memory is a primary task, and use of libray and flash slots should be planned from the start.
.
.
Edited 2025-02-24 02:59 by Volhout
PicomiteVGA PETSCII ROBOTS
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 09:20am 24 Feb 2025
Copy link to clipboard 
Print this post

@Peter,

Can I propose that OPTION LIST returns the list sorted alphabetically so that it makes it easier to find a specific option when the list becomes lengthy.

Even though the list currently seems to be sorted in a consistent sequence between PicoMites, having it sorted alphabetically would definitely help the end user.

I am not in front of any PicoMite, but from memory I think that HEARTBEAT isn’t showing in the list (b11 2350B). Will confirm later when back home….
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 06:55pm 24 Feb 2025
Copy link to clipboard 
Print this post

@Peter, @all

I'm not sure if I'm misunderstanding something.
I tried this code:
Print "Start of the program."
End
Sub MM.END
Print "This is the END."
End Sub

I would have expected mm.end to be executed, i.e. Print "This is the END". But it doesn't.

> option list
PicoMiteHDMI MMBasic USB RP2350A Edition V6.00.02b11
OPTION SERIAL CONSOLE COM2,GP8,GP9
OPTION SYSTEM I2C GP20,GP21
OPTION FLASH SIZE 4194304
OPTION COLOURCODE ON
OPTION KEYBOARD GR
OPTION CPUSPEED (KHz) 315000
OPTION SDCARD GP22, GP26, GP27, GP28
OPTION RTC AUTO ENABLE
OPTION F9 FLASH RUN 2
OPTION PLATFORM HDMIUSB

Kind regards
Michael
causality ≠ correlation ≠ coincidence
 
Amnesie
Guru

Joined: 30/06/2020
Location: Germany
Posts: 529
Posted: 07:04pm 24 Feb 2025
Copy link to clipboard 
Print this post

  twofingers said  @Peter, @all


I would have expected mm.end to be executed, i.e. Print "This is the END". But it doesn't.



But why should the interpreter jump to the mm.end subroutine if you tell him to END before, since this is a statement.

?? I think this is correct behavior.

Greetings
Daniel
 
Mixtel90

Guru

Joined: 05/10/2019
Location: United Kingdom
Posts: 7504
Posted: 07:14pm 24 Feb 2025
Copy link to clipboard 
Print this post

MM.END isn't documented in a manual yet AFAIK.
See the matherp posts from this point onward:  https://www.thebackshed.com/forum/ViewTopic.php?TID=17283&PID=229949#229949#229949

  Quote  END [noend]
END cmd$
End the running program and return to the command prompt. If a subroutine
named MM.END exists in the program it will be executed whenever the
program ends with an actual or implied END command. It is not executed if
the program ends with a ctrl-C. The optional parameter ‘noend’ can be used to
block execution of the MM.END subroutine eg, “END noend”
if 'cmd$' is specified then it will be executed as though at the command prompt after the program finishes. NB: if "END cmd$" is used but a subroutine MM.END exists it will be executed and cmd$ ignored.



Anything after an END statement is ignored. The SUB MM.END must occur before the END statement or it won't be detected.

.
Edited 2025-02-25 05:20 by Mixtel90
Mick

Zilog Inside! nascom.info for Nascom & Gemini
Preliminary MMBasic docs & my PCB designs
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 07:17pm 24 Feb 2025
Copy link to clipboard 
Print this post

MMBasic manual p18:
(2025-01-25_063652_PicoMite_User_Manual)
  Quote  MM.END
If a subroutine named MM.END exists in the program it will be executed whenever the program ends with an
actual or implied END command. It is not executed if the program ends with a Ctrl-C.
The optional parameter ‘noend’ to the END command can be used to block execution of the MM.END
subroutine if needed (see the END command for more information),

causality ≠ correlation ≠ coincidence
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 07:22pm 24 Feb 2025
Copy link to clipboard 
Print this post

@Mick

Thanks, that helps!

  Quote  d. Like MM.STARTUP, you could then save a MMBasic subroutine named MM.END in the library and that would be run whenever any program exits.


I will try that!

Regards
Michael

This doesn't work either:
Sub MM.END
Print "This is the END."
End Sub

Print "Start of the program."
End

Edited 2025-02-25 05:26 by twofingers
causality ≠ correlation ≠ coincidence
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 07:30pm 24 Feb 2025
Copy link to clipboard 
Print this post

@Daniel:
  Quote  But why should the interpreter jump to the mm.end subroutine if you tell him to END before, since this is a statement.

?? I think this is correct behavior.

Because the manual says so? (p18+p108)
Kind regards
Michael

END [noend]
or
END cmd$
End the running program and return to the command prompt. If a subroutine
named MM.END exists in the program it will be executed whenever the
program ends with an actual or implied END command. It is not executed if
the program ends with the break character (ie, Ctrl-C).
The optional parameter ‘noend’ can be used to block execution of the
MM.END subroutine eg, “END noend”
if 'cmd$' is specified then it will be executed as though at the command prompt
after the program finishes. Note: if "END cmd$" is used but a subroutine
MM.END exists it will be executed and cmd$ ignored.

causality ≠ correlation ≠ coincidence
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 07:56pm 24 Feb 2025
Copy link to clipboard 
Print this post

> list
Print "Start of the program."
End

> RUN
Start of the program.

> library list
Sub MM.END
Print "This is the END."
End Sub


I don't understand it   ...
causality ≠ correlation ≠ coincidence
 
WhiteWizzard
Guru

Joined: 05/04/2013
Location: United Kingdom
Posts: 2927
Posted: 08:06pm 24 Feb 2025
Copy link to clipboard 
Print this post

I am seeing the same here on several Pico’s I have under test (i.e not running the code within the mm.end sub).

All my Pico’s have b11 HDMI USB
 
twofingers
Guru

Joined: 02/06/2014
Location: Germany
Posts: 1526
Posted: 08:12pm 24 Feb 2025
Copy link to clipboard 
Print this post

@WW
Thanks for the cross-check!
Michael
causality ≠ correlation ≠ coincidence
 
dddns
Senior Member

Joined: 20/09/2024
Location: Germany
Posts: 259
Posted: 02:12pm 25 Feb 2025
Copy link to clipboard 
Print this post

both on b11 usb:

I am not able to read an ADC value constantly, neither on a 2040 nor a 2350B:
do:? pin(gp27):pause 100:loop
2.334444444
2.334041514
0.3886935287
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
....

After that has happend, none of the ADC inputs can be read anymore and all showing this number.
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3998
Posted: 02:31pm 25 Feb 2025
Copy link to clipboard 
Print this post

  dddns said  both on b11 usb:

I am not able to read an ADC value constantly, neither on a 2040 nor a 2350B:
do:? pin(gp27):pause 100:loop
2.334444444
2.334041514
0.3886935287
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
-0.0008058608059
....

After that has happend, none of the ADC inputs can be read anymore and all showing this number.

Do you need a SETPIN or such?

John
 
Martin H.

Guru

Joined: 04/06/2022
Location: Germany
Posts: 1193
Posted: 10:27am 26 Feb 2025
Copy link to clipboard 
Print this post

Am I the only one who can not download the Beta? (HTTP ERROR 418)
Link
Edited 2025-02-26 20:28 by Martin H.
'no comment
 
     Page 17 of 23    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025