Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 19:54 04 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 release candidates - all versions

     Page 26 of 37    
Author Message
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 10:39am 14 Apr 2025
Copy link to clipboard 
Print this post

Yes, I found that, as I mentioned, when I changed between using individual pixel blanking, which was faster on a 2040 VGA and LCD, to a frame buffer, which is faster on a 2350 (don't understand why though, memory bandwidth?), and clearing the whole screen with CLS, this freed up several large arrays
',y,z,f(16,65),l(16,65)
'Dim Integer e(65)
Initially I just left them in place, until I noticed that by removing them it made a significant difference to the speed of the program?
PS, I'm currently failing to get my 2040 VGA going again after updating, the USB is not working for some reason, almost certainly a problem with my hardware.
Edited 2025-04-14 20:41 by Bleep
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 11:18am 14 Apr 2025
Copy link to clipboard 
Print this post

OK, got my 2040 VGA USB running on RC12. Just found another interesting feature.

These observations apply to the 2040 VGA, so far, will now try 2350 HDMI.
If I run Bubble at 378MHz, I get the following.
Bubble running with and without file opening.
416mS and 607mS
Un comment the two places in the code, which have.
,y,z,f(16,65),l(16,65)
Dim Integer e(65)
They are not used, but get allocated.
416mS and 669mS
Note that the speed with the extra memory allocated slows a lot, but with the file open it does not change?
Very curious.
Edited 2025-04-14 21:19 by Bleep
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 11:24am 14 Apr 2025
Copy link to clipboard 
Print this post

V6.00.02RC14 is available on

https://geoffg.net/Downloads/picomite/PicoMite_Beta.zip

Fixes bug in play pause with i2s audio
Enables mouse cursor in higher res VGA and HDMI editing
Mouse cursor now updates line and character after left press

New temporary option OPTION FAST TRIG ON/OFF

Setting this to ON in a program tells the firmware to use single precision calculations for the various trig functions. This can significantly speed up processing for programs that do not require full resolution trig calcs and use a lot of trig

I don't think I can do anything about the performance variations discussed above. I'm now pretty sure they are to do with memory allocation of code and variables. The RP chips have a paged memory structure where things like DMA can read from one page without affecting performance of system activity on another page. However, they don't have enough memory to allow me to partition the application code and data into different pages so all I can suggest is that for performance critical applications you play with how you order dimensioning data and things like framebuffers to achieve the optimum performance in your specific case.
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 11:27am 14 Apr 2025
Copy link to clipboard 
Print this post

I get exactly the same effect on the 2350 HDMI running at 372MHz.
Bubble running with and without file open.
235mS and 285mS
Un comment large arrays.
235mS and 330mS
?
Crossed posts, I'll try your new reduced precision Trig function.
Edited 2025-04-14 21:29 by Bleep
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 12:24pm 14 Apr 2025
Copy link to clipboard 
Print this post

Using latest RC14.
Using the new 'OPTION FAST TRIG ON' I only see a couple of mS speed up on a 2350 HDMI, presumably because of the partial hardware acceleration, is that what you'd expect?.

On the 2040 VGA, I'm seeing about a 6 to 9% speed up, when using Fast Trig.
Exact figures at 378MHz.
Standard Bubble. 622mS - Bubble with open file. 429mS
Now with fast trig.
Standard Bubble. 588mS - Bubble with open file. 394mS

A useful amout of speed up, Thanks. :-)
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 03:28pm 14 Apr 2025
Copy link to clipboard 
Print this post

One last data point, incase it triggers a brain wave.

Standard Bubble, with file open, & heap   and without. & heap
Exactly as original,     225mS     165888 and  276mS     166400
Add 'Dim Integer e(1)'   252mS     165632 and  276mS     166144
No change by increasing dim size.
Make 'Dim Integer e(31)' 252mS     165632 and  276mS     166144
Make 'Dim Integer e(32)' 278mS     165376 and  277mS     165888

So the speed drops in steps as the heap gets larger by increasing the dim size when a file is open, but the speed does not change with no file open.
Note that the speed when the heap jumps to 165376, with an open file, gives the exact same speed as with no file open, ie no speed up. (when e is an array of 33).
This also happens to be the point when the heap is 165888, without an open file, which is exactly the same size as the original, with no dim defined, but with a file open and the fastest speed??

But whatever I try I can't get even close to the 225mS by simply playing around with variable definitions or Frame buffers.
Is there anything I can define that shifts or alligns the memory layout in different ways, maybe defining a C function or something, so I can experiment a bit more?
Edited 2025-04-15 01:30 by Bleep
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4825
Posted: 04:25pm 14 Apr 2025
Copy link to clipboard 
Print this post

Kevin,

The moment of creating the framebuffer will move all arrays in ram memory.
This was essential for the logic analyzer, where I needed to create a ring buffer before i created the framebuffer.

Volhput
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 04:46pm 14 Apr 2025
Copy link to clipboard 
Print this post

  Quote  The moment of creating the framebuffer will move all arrays in ram memory.

Not in HDMI or RP2350 VGA as the framebuffer memory is pre-allocated and the same symptoms occur in both
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 05:02pm 14 Apr 2025
Copy link to clipboard 
Print this post

Eureka !!!

The issue is to do with how long it takes to allocate temporary memory to parse the commands.

This is fastest if the program finds free memory right at the top of the heap and doesn't need to search down it.

By fluke, the OPEN command allocates 512 bytes of memory which it then frees leaving a hole at the top of memory. We can simulate this by allocating 512 bytes of memory which we then free before entering the tight loop. See the attached. Now I need to discuss with Geoff, Tom and Gerry to see if we can do this in some sort of systemic way to improve performance of MMbasic

' Bubble Universe

'2 Nested loops each 52 =2704 points calculated VGA
'Pico 2040Anal @ 378MHz normal 316mS Framebuff 397mS
'Pico 2350Anal @ 378MHz normal 185mS Framebuff 185mS

'2 Nested loops each 66 =4356 points calculated VGA
'Pico 2040Anal @ 378MHz normal 553mS Framebuff 683mS
'Pico 2040Anal @ 378MHz Framebuff/CLS 607ms
'Pico 2350Anal @ 378MHz normal 341mS Framebuff 341mS
'Pico 2350HDMI @ 372MHz normal 333mS Framebuf 333mS
'Pico 2350HDMI @ 372MHz normal 278mS Framebuf 279mS CLS,remove arrays
MODE 2
Font 8
Option fast trig on
Dim SSS$,qqq$ 'allocate some memory at the top of the heap
FRAMEBUFFER create
FRAMEBUFFER write f
'Play mp3 "B:/hmp3"
'Play wav "b:/16"
Pause 1000
'Play pause


Dim Float u(65),w(65),p,q,t,v=0,x=0,b
Dim Integer c(65),d(65),n(65),m(32,65),nn,dd,xc,yc,xs,ys
Dim Integer a,g,i,j,cc',y,z,f(16,65),l(16,65)
'Dim Integer e(65):Math Set 2,e()
Const r=(2*Pi)/235,k=255,s=50
CLS RGB(black)
t=Rnd*10
't=1
nn=Peek(varaddr n())
dd=Peek(varaddr d())
cc=Peek(varaddr c())
'calculate centre and scale factor
xc=MM.HRES\2:yc=MM.VRES\2
xs=MM.HRES/4.2:ys=MM.VRES/4.0  'Oval
'xs=MM.HRes/6:ys=MM.VRes/4      'Circular
Erase sss$,qqq$ 'free the memory to create space for command parsing
For a=0 To 65
For g=0 To 65
If a<18 And g<18 Then
 n(g)=RGB(0,255,0)
Else
 n(g)=RGB(a*3.93,g*3.93,128*(a+g<65))
EndIf
Next 'g
Memory pack nn, Peek(varaddr m(0,a)),66,32 'pack pixel colours
Next 'a
Do
CLS
Inc t,0.035:g=0:Print Timer:Timer =0
For i=60To 255Step 3
'z=Peek(varaddr f(0,g)):Memory unpack z,cc,66,16
'y=Peek(varaddr l(0,g)):Memory unpack y,dd,66,16
'Pixel c(),d(),0'Box c(),d(),e(),e(),0,,0
b=r*i+t
For j=0To 65:u(j)=Sin(i+v)+Sin(x):v=Cos(i+v)+Cos(x):x=u(j)+b:w(j)=v:Next
Math Scale u(),xs,c():Math Scale w(),ys,d():Math add c(),xc,c():Math Add d(),yc,d()
Memory unpack Peek(varaddr m(0,g)),nn,66,32 'unpack pixel colours
Pixel c(),d(),n()'Box c(),d(),e(),e(),0,,n()
'Memory pack cc,z,66,16:Memory pack dd,y,66,16
Inc g
Next 'i
FRAMEBUFFER copy f,n
Loop
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4825
Posted: 05:48pm 14 Apr 2025
Copy link to clipboard 
Print this post

@Peter,

If you allocate a fixed amount of memory on the top of the heap, before user can allocate heap with LOCAL, DIM and FRAMEBUFFER, can you please check if user space can start at a 16k boundary for the logic analyzer ring buffer ?

-Or- eat 1k from the LOCAL variables RAM space.

Thanks,

Volhout

B.t.w: good work that you found it! Solving this will indeed make the performance more consistent.
Edited 2025-04-15 03:50 by Volhout
PicomiteVGA PETSCII ROBOTS
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 07:25pm 14 Apr 2025
Copy link to clipboard 
Print this post

Fantastic, let's hope it makes a difference elsewhere, not just the bubble. :-)
Is 512 bytes enough for any sized program, or only enough for something small like Bubble? Or does the free ram on the top of the heap somehow need to be dynamically sized?
Edited 2025-04-15 06:59 by Bleep
 
JanVolk
Senior Member

Joined: 28/01/2023
Location: Netherlands
Posts: 217
Posted: 10:03pm 14 Apr 2025
Copy link to clipboard 
Print this post

Peter,

> option list
PicoMiteHDMI MMBasic USB RP2350A Edition V6.00.02RC14
OPTION SERIAL CONSOLE COM1,GP0,GP1
OPTION SYSTEM I2C GP20,GP21
OPTION FLASH SIZE 4194304
OPTION COLOURCODE ON
OPTION KEYBOARD US
OPTION CPUSPEED (KHz) 372000
OPTION RESOLUTION 1280x720
OPTION DISPLAY 30, 80
OPTION HDMI PINS  1, 3, 7, 5
OPTION SDCARD GP22, GP6, GP7, GP4
OPTION AUDIO GP26,GP27', ON PWM CHANNEL 5
OPTION RTC AUTO ENABLE
OPTION MODBUFF ENABLE  192
OPTION PLATFORM OLIMEX USB
OPTION DEFAULT FONT 3, 1

Various tests done with a separate HDMI monitor and a somewhat older TV with HDMI.
With this version the mouse cursor works perfectly with the right mouse button and the Ln: and Cur: are adjusted neatly and with Pg Up and Pg Dn and Backspace it can now be used perfectly.
What is noticeable is that if you want to move the mouse outside the last line, a sync problem occurs in the block of the cursor and disappears again when you move up.
It would also be useful to mention in the manual for each option resolution how many lines and how many characters the different modes in the editor can handle.
Here are some results with Option resolution xxx with HDMI and USB so a separate computer with SD, HDMI, MOUSE, Keyboard, AUDIO, RTC etc.
Compare it with a Commodore64 and Floppy drive and this composition.

The HDMI monitor.  
xxx Ln: Char:
640 38  80  
720 31  90
800 48 100
848 38 106
1024 30  64
1280 28  80

The HDMI TV.
xxx Ln: Char:
848 38  106
1024 30   64
1280 does give a very nice image but unfortunately the outer characters fall outside the image on all sides of the screen.
The other 640, 720, 800 do work but are very small on this screen.

Conclusion with the HDMI monitor with 1280 a beautiful image and once you have worked with it for a while you do not want to go back to the terminal.
With HDMI TV 1024 gives a good clear image spread over the entire screen. So try all resolutions for the best result.
Thanks Peter.

Greetings,

Jan.
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 07:47am 15 Apr 2025
Copy link to clipboard 
Print this post

Harm and anyone else interested

Please could you try the attached with your bank of programs. Tested OK with Petscii and LA_24_2 + my usuals.
Fixes the issue in bubble and give a performance improvement in all programs tested varying from very little to almost 50%
All "fixes" in bubble should be removed to prove the change

PicoMiteVGARP2040.zip
 
Bleep
Guru

Joined: 09/01/2022
Location: United Kingdom
Posts: 570
Posted: 09:19am 15 Apr 2025
Copy link to clipboard 
Print this post

Hi Peter,
I've tried with your sugestion of declaring a couple of strings and then erasing them and that definately works.
Unfortunately all my VGA Mites that are easily updatable are USB so I can't currently test  your new improved firmware. :-(

Footnote added 2025-04-15 19:45 by Bleep
or they are 2350.
 
bfwolf
Regular Member

Joined: 03/01/2025
Location: Germany
Posts: 68
Posted: 09:28am 15 Apr 2025
Copy link to clipboard 
Print this post

  matherp said  Eureka !!!

The issue is to do with how long it takes to allocate temporary memory to parse the commands.

This is fastest if the program finds free memory right at the top of the heap and doesn't need to search down it.

...


Hi Peter. Are you ready to reveal the secret of which strategy you used to provide "fast RAM" to the command parser?  
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4825
Posted: 11:35am 15 Apr 2025
Copy link to clipboard 
Print this post

@Peter,

The version looks stable to me. Tried the variety of games and programs, all run.
Just started a game on the basic chess game. If that still runs tomorrow, testing should be complete.
I can confirm some performance increase on 2040 VGA PS2 (varies per program, but averages around 8-10%) This is great !!

Volhout
Edited 2025-04-15 21:44 by Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 11:56am 15 Apr 2025
Copy link to clipboard 
Print this post

I've just re-engineered the solution a different (better/faster?) way. Please test to destruction

Here is the HDMIUSB version for test.


PicoMiteHDMIUSBV6.00.02RC14.zip

and the RP2040 VGA version


PicoMiteRP2040VGAV6.00.02RC14.zip
 
Volhout
Guru

Joined: 05/03/2018
Location: Netherlands
Posts: 4825
Posted: 12:06pm 15 Apr 2025
Copy link to clipboard 
Print this post

  matherp said  
and the RP2040 VGA version

PicoMiteRP2040VGAV6.00.02RC14.zip


The VGA version may be USB version ? It does not connect on USB to my teraterm.

Volhout
PicomiteVGA PETSCII ROBOTS
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 12:08pm 15 Apr 2025
Copy link to clipboard 
Print this post

Please try again - works for me loaded from the zip. If not try clear-flash but shouldn't be needed.


PicoMiteRP2040VGAV6.00.02RC14.zip
Edited 2025-04-15 22:09 by matherp
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10015
Posted: 12:18pm 15 Apr 2025
Copy link to clipboard 
Print this post

Please ignore for the moment - found one small quirk
 
     Page 26 of 37    
Print this page
The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025