![]() |
Forum Index : Microcontroller and PC projects : PicoMite V6.01.00 betas
![]() ![]() ![]() ![]() |
|||||
Author | Message | ||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10364 |
V6.01.00b8 PicoMiteV6.01.00b8.zip Should fix the merge bug Also fixes an HDMI bug reported a few days ago |
||||
stanleyella![]() Guru ![]() Joined: 25/06/2022 Location: United KingdomPosts: 2602 |
I had problems like invalid address using framebuffer copy with f and l. when I go back to mmcc it flashes code and says saved but doesn't run. got to unplug pico and restart mmcc. I didn't know there was ili9341 buffer option, I set up ili9341 as per manual wiring and setup, system spi |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 651 |
Hi Peter, I can confirm that Merge on my setup is working fine now. My Setup :- PicoMite MMBasic USB RP2350A Edition V6.01.00b8 OPTION SERIAL CONSOLE COM2,GP8,GP9 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION LCD SPI GP26,GP27,GP28 OPTION SYSTEM I2C GP20,GP21 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION KEYBOARD UK OPTION CPUSPEED (KHz) 360000 OPTION LCDPANEL CONSOLE 7,,, 50,NOSCROLL OPTION DISPLAY 40, 80 OPTION LCDPANEL ST7796S, LANDSCAPE,GP12,GP13,GP14,GP15 OPTION LCD BACKLIGHT 50 OPTION TOUCH GP17,GP7 OPTION SDCARD GP22 OPTION RTC AUTO ENABLE OPTION DEFAULT FONT 7, 1 However this has thrown up another problem, possibly only with this setup. If I use Framebuffer Sync, immediately after a Framebuffer Merge 0,b it appears to work fine, however if I use the Framebuffer Sync, just before I trigger another Background Merge, the program freezes, as though it is waiting forever? Simple example:- FRAMEBUFFER CREATE FRAMEBUFFER LAYER FRAMEBUFFER write F Box 50,50,150,50,4,RGB(blue),RGB(Black) FRAMEBUFFER write L FRAMEBUFFER copy F,L Do For n=5 To 60 Circle 125,75,n,,,RGB(gold) FRAMEBUFFER merge 0,b FRAMEBUFFER sync Next n 'Dummy, to force a Sync 'Framebuffer Merge 0,b For n=5 To 60 Circle 125,75,n,,,RGB(black) FRAMEBUFFER sync FRAMEBUFFER merge 0,b Next n Loop I realise in this simple case the Sync is unnecessary however in the Lissajous program it would be benificial, or am I using it incorrectly? Regards, Kevin. Ok I've found the problem, the Sync is waiting because the Merge hasn't completed, it's never even started. So if I put a Merge outside the begining of the loop, then it works. But is this to be expected? Kevin. |
||||
mozzie Senior Member ![]() Joined: 15/06/2020 Location: AustraliaPosts: 171 |
G'day, Peter, thanks for sorting that out, now working on ILI9341 and ST7796S, another one squashed ![]() As Kevin has mentioned, FRAMEBUFFER SYNC is now hit and miss, it works on my ST7796S ok but not on ILI9341, this is on the non buffered drivers and with / without putting a FRAMEBUFFER MERGE 0,b at the start of the program. It was working on b7 on both displays. Regards, Lyle. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10364 |
Correct. Executing SYNC clears a flag and waits for a merge to set it. If no merge is running or has previously run or sync has already been called it will wait forever. } else if((p=checkstring(cmdline, (unsigned char *)"SYNC"))) { //merge the layer onto the physical display mergedone=false; while(mergedone==false){CheckAbort();} The code doesn't know the difference. If you want to use SYNC your code must look like this Edited 2025-08-16 02:10 by matherp |
||||
mozzie Senior Member ![]() Joined: 15/06/2020 Location: AustraliaPosts: 171 |
G'day Peter, Some more testing has shown that the initial MERGE 0,b needs to be placed within one framebuffer time of the sync command for it to work, if it is outside this, or the program takes too long to get back, the program will hang at the sync command. I can confirm it does work on both the ILI9341 and ST7796S. Hope this helps. Regards, Lyle. |
||||
mozzie Senior Member ![]() Joined: 15/06/2020 Location: AustraliaPosts: 171 |
Peter, I think these posts crossed ![]() Would it be possible to set the flag when the Merge has finished regardless of whether the program is waiting at the sync command? I can see problems where something takes a bit longer than anticipated and the program then hangs forever. Not knowing whats going on "under the hood" makes it sound easy of course. Regards, Lyle. |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 651 |
Hi Peter, A question about the screen updates. I'm seeing wildly different apparent screen updates, but I can't make any sense of them. When you first issued the Beta software, you mentioned that CPUSPEED of 360000 was the sweet spot for the SPI bus driving a ST7796S, so I have assumed this should give me the best update rate? However using this cut down program:- Option ANGLE DEGREES FRAMEBUFFER CREATE FRAMEBUFFER LAYER RX=MM.HRES:RY=MM.VRES:CX=RX\2:CY=RY\2 Scale=0.95: AX=CY*Scale: AY=CY*Scale Dim Integer i,j,a=1: b=0: p=0: f=0: c=0 Dim Integer sx(360),ex(360),sy(360),ey(360) FRAMEBUFFER WRITE L '<===== Write the following to Layer L Do Print Timer:Timer =0 If p>360 Then p=0: EndIf If b>6 Then a=a+1: b=0: c=0: EndIf If a>5 Then a=1: b=0: c=0: EndIf If c=50 Then f=1 If a=Fix(b) Then f=0: c=0: EndIf EndIf If c=130 Then f=0: c=0: EndIf 'calculate the x and y start points sx(0)= AX * Sin(p) + CX sy(0)= AY * Sin(p) + CY 'calculate all remaining points For i= 0 To 360 ex(i) = AX * Sin(a*i + p) + CX ey(i) = AY * Sin(b*i + p) + CY Next i 'Copy whole array(0 to 360 less 1) offset by one Integer Memory copy integer Peek(varaddr ex(0)),Peek(varaddr sx(1)),360 Memory copy integer Peek(varaddr ey(0)),Peek(varaddr sy(1)),360 CLS 0 Line sx(),sy(),ex(),ey(),,RGB(Yellow) FRAMEBUFFER MERGE ' 0,b '<======== copy both layers to the screen Inc p: Inc c If f=0 Then b=b+.02 Loop Until Inkey$<>"" End If I set CPUSPEED to 360000 My loop timer gives me 103mS If I set CPUSPEED to 363000 My loop timer gives me 85mS initially then after a while jumps to 95mS or 103mS If I set CPUSPEED to 376000 My loop timer gives me an almost constant 85mS The code takes between 17 and 18mS, whatever the CPUSPEED within this range, so the only thing that can vary is the Framebuffer Merge, why is there such a large variation? > option cpuspeed 360000 > run 103.41 103.397 103.384 103.409 103.397 95.27 94.283 103.417 103.399 103.366 103.383 103.381 103.38 103.402 103.414 103.421 103.417 103.407 103.399 103.408 103.401 103.394 95.277 94.298 > option cpuspeed 363000 > run 87.804 86.234 86.257 86.264 86.228 86.192 86.193 86.183 86.199 86.203 86.192 86.176 After about 10 seconds 95.383 94.383 95.385 94.382 95.399 94.399 103.541 103.521 103.525 103.542 103.555 103.521 103.532 103.517 103.536 103.531 103.523 > option cpuspeed 376000 > run 84.024 86.161 86.163 86.162 86.156 86.174 86.157 86.175 86.175 86.175 PicoMite MMBasic USB RP2350A Edition V6.01.00b8 OPTION SERIAL CONSOLE COM2,GP8,GP9 OPTION SYSTEM SPI GP18,GP19,GP16 OPTION LCD SPI GP26,GP27,GP28 OPTION SYSTEM I2C GP20,GP21 OPTION FLASH SIZE 4194304 OPTION COLOURCODE ON OPTION KEYBOARD UK OPTION CPUSPEED (KHz) 363000 OPTION LCDPANEL CONSOLE 7,,, 50 OPTION DISPLAY 40, 80 OPTION LCDPANEL ST7796S, LANDSCAPE,GP12,GP13,GP14,GP15 OPTION LCD BACKLIGHT 50 OPTION TOUCH GP17,GP7 OPTION SDCARD GP22 OPTION RTC AUTO ENABLE OPTION DEFAULT FONT 7, 1 Any Sugestions, Thanks. Regards, Kevin. |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10364 |
merge waits for frame blanking so will be susceptible to tiny variations in loop time if they cause a trip over to the next frame |
||||
Bleep Guru ![]() Joined: 09/01/2022 Location: United KingdomPosts: 651 |
Does Merge do this for the Background Merge as well, it was initially large variations in the Background Merge that made me look at this more deeply. Regards Kevin. |
||||
Volhout Guru ![]() Joined: 05/03/2018 Location: NetherlandsPosts: 5156 |
For a 2350 at 252MHz the merge takes roughly 30ms (42MHz SPI, 320x240), so 20ms for a 360MHz (480x320 @90MHz SPI) seems realistic. The difference between 103 and 85ms is roughly 20ms. Volhout Edited 2025-08-16 05:28 by Volhout PicomiteVGA PETSCII ROBOTS |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1613 |
Hi Peter, have you changed anything in PicoMite V6.01.00 beta? I'm getting an error message about this recently. Do :GetCKey1: Loop Until CKey Print CKey End Sub GetCKey1 Static AltFlag CKey=Asc(Inkey$) End Sub PicoMiteHDMI MMBasic USB RP2350A Edition V6.01.00b5 I'm also getting the same error in an FM version where I use "static." However, it's not an error that can't be easily circumvented. This is just to inform you. Kind regards Michael Edited 2025-08-17 04:56 by twofingers causality ≠ correlation ≠ coincidence |
||||
disco4now![]() Guru ![]() Joined: 18/12/2014 Location: AustraliaPosts: 1012 |
Hi Peter, Probably nothing to do with above report, but if a static variable is declared as a short string so it does not allocated any HEAP memory it fails with various symptoms. The fix would be same as previous one in ERASE command. i.e call FreeMemorySafe in lieu of FreeMemory. (I have not actually tested it) Gerry x$=Inkey$ Do :GetCKey1: Loop Until CKey Print CKey End Sub GetCKey1 'Static altflag$ LENGTH 16 'OK Static altflag$ LENGTH 7 'Fails variable ways CKey=Asc(Inkey$) End Sub // LOCAL also uses this function the routines only differ in that LOCAL can only be used in a sub/fun void MIPS16 cmd_dim(void) { ... ... // if it is a STATIC var create a local var pointing to the global var if(StaticVar) { .... .... if(g_vartbl[VIndexSave].dims[0] > 0 || (g_vartbl[VIndexSave].type & T_STR)) { //FreeMemory(tv); // we don't need the memory allocated to the local FreeMemorySafe(tv); // we don't need the memory allocated to the local .... .... F4 H7FotSF4xGT |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10364 |
Sorry, can't replicate ![]() FM version? Thanks - will make the change Edited 2025-08-17 17:34 by matherp |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1613 |
@Peter Thanks! But it seems weird. I'll avoid "Static". No problem! FM02099 (canceled) Kind regards Michael causality ≠ correlation ≠ coincidence |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3295 |
The LENGTH parameter for a non-arrayed string variable has no meaning. For any simple string variable (static or not) MMBasic always allocates 256 bytes. This the size of a memory block and is built into the interpreter and cannot be easily changed. The LENGTH parameter is intended for string arrays which can get unreasonably large with 256 bytes allocated to each element. I have not tested it but using the LENGTH parameter on a non-array static variable could conceivably interfere with the parsing of the declaration and trip the interpreter up. The STATIC declaration is fine, just don't use the LENGTH parameter. As a side note, it is generally not a good idea to try and optimise what MMBasic is doing regarding memory usage and speed. Modern processors such as the RP2350 have so much RAM and speed that the inefficiencies of an interpreter do not matter and trying to optimise memory usage (as in this case) is futile. Geoff Geoff Graham - http://geoffg.net |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1613 |
Thanks Geoff, although I remembered differently. Regards Michael causality ≠ correlation ≠ coincidence |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10364 |
PicoMite MMBasic and CMM2 MMBasic both support the length command for individual strings. It works by using the unused DIM array in the vartbl header. It is therefore limited to short strings (from memory: 7 chars for RP2040 and 15 for RP2350). It is particularly useful for short string constants saving 256 bytes for each |
||||
twofingers![]() Guru ![]() Joined: 02/06/2014 Location: GermanyPosts: 1613 |
Hi Peter, thanks for the clarification. Maybe it should be included in the manual (if it isn't already ![]() Regards Michael causality ≠ correlation ≠ coincidence |
||||
Geoffg![]() Guru ![]() Joined: 06/06/2011 Location: AustraliaPosts: 3295 |
Ah, my apologies. Peter has made an enhancement that I was not aware of. Geoff Geoff Graham - http://geoffg.net |
||||
![]() ![]() ![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |