|
Forum Index : Microcontroller and PC projects : Armmite L4: 5.05.09 with DOCUMENTATION!
| Author | Message | ||||
sagt3k![]() Guru Joined: 01/02/2015 Location: ItalyPosts: 313 |
Hi matherp I noticed something strange about file management (I have stm32l431+flash W25Q32) after I break with ctrl+c a file in append mode. In practice after having done the breack of an append it does not allow me to do "save" except after having done an "edit" Here the steps: >format >save "code.bas" >run after a loops I break the code with CTRL+C > print mm.free 3837952 > files A: 267 code.bas 160000 OUT.TXT Ok then I kill the file: > kill "code.bas" > files A: 160000 OUT.TXT > save "code.bas" Error: No more memory available > files A: 160000 OUT.TXT 0 code.bas > Now I do "edit" and (save or exit without change code) > save "code.bas" > files A: 160000 OUT.TXT 268 code.bas > I can save more several times without errors > save "code.bas" > save "code.bas" > This is the code: Option autorun on SetPin 2,dout Dim X As Integer = 0 Open "OUT.TXT" For APPEND As #1 Do X=X+1 Print #1,Timer If X Mod 1000=0 Then Close #1 Print Timer,X, " - A:diskfree:"MM.FREE Open "OUT.TXT" For APPEND As #1 End If Pin(2)=Not Pin(2) Loop |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
This is because the Armmite only supports a single file handle and there is a file left open by your program. If you just type "close 1" before the save you will find it works. I'll put an automatic close into the next version if you try and save. I fell over this today testing lizby's issue |
||||
sagt3k![]() Guru Joined: 01/02/2015 Location: ItalyPosts: 313 |
Ok thank Is there the possibility to close file and save data after ctrl+c if there is an opened file? So this would avoid losing data. Do you think it makes sense? |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Please find attached a trivial update that closes an open file before executing a save or autosave command 2019-03-28_180338_ArmmiteL4.zip Not really, because then you couldn't CONTINUE in any program that had an open file. With the update above the situation is pretty safe as NEW, RUN, LOAD, SAVE, AUTOSAVE, permanent OPTION all close any open files before executing. Yes PEEK and POKE should both work on registers but let me know if there appear to be issues Let me know if you can get it to work and I'll look at incorporating it. RTC wakeup was a pig to get working as there was a bug in the CubeMX code. Also be aware that the processor "wakes" every 32 seconds regardless of the length of SLEEP. This is a hardware limitation and is handled inside the CPU SLEEP command |
||||
sagt3k![]() Guru Joined: 01/02/2015 Location: ItalyPosts: 313 |
Hi matherp If possible other requests - "load" with R as optional to load&run code - "filesize" function that return the size in byte of a file in the flash |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Your wish.... 2019-03-29_003730_ArmmiteL4.zip 2019-03-29_012130_Armmite_L4_Manual.pdf LOAD "filename",r as per Micromite+ Note the new command SYNCH. This flushes the buffer from the flash driver. Until this is done the filesize is not updated and the disk may or may not be written. Note also, if an existing file is opened for output then filesize will give the size of the previous version of the file until the file is closed or SYNCH is called. ![]() Timer = 0 Open "T" For output As #1 Print "Size after opening is : ",Filesize("T") For i=0 To 1000 Print #1,i, "Hello World" Next i Print "Size after writing 1000 lines is : ",Filesize("T") Synch #1 Print "Size after synch is : ",Filesize("T") For i=0 To 1000 Print #1,i, "Bye World" Next i Print "Size after writing another 1000 lines is : ",Filesize("T") Close #1 Print "SIze after closing is : ",Filesize("T") Print "Time taken is : ",Timer/1000," seconds" |
||||
sagt3k![]() Guru Joined: 01/02/2015 Location: ItalyPosts: 313 |
Thanks matherp |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
and with that the memory size limit on any program is gone (as if it mattered with the MMX etc...) |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
Yes . Didn't know if this would work but it seems to behave perfectly![]() Program 1 Dim a% VAR restore Print "program 1, run : ",a% a%=a%+1 VAR save a% Pause 1000 Load "p2",r Program 2 Dim a% VAR restore Print "program 2, run : ",a% a%=a%+1 VAR save a% Pause 1000 Load "p1",r |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4133 |
Interesting... I did not expect variables to keep their values. John |
||||
| CaptainBoing Guru Joined: 07/09/2016 Location: United KingdomPosts: 2171 |
this is excellent - it is possible to have programs that run as overlays and you simply "page in" the section of code o run. Question... there is no library with MMX, is there any way to maintain a "kernel" of key functions between overlays int he same way variables survive? |
||||
| matherp Guru Joined: 11/12/2012 Location: United KingdomPosts: 10572 |
No - sorry, all or nothing No: they will need replicating in each program. I didn't include the library in the Armmite L4 as it uses quite a lot of program memory and there is little advantage given that the Armmite doesn't support CFunctions which is where the big space saving gains are found. They don't. I'm using VAR SAVE to store the value in the uP flash memory and VAR RESTORE to read it back. This is just standard Micromite functionality. Equally I could have written variable values out to the a file and read them back. |
||||
| JohnS Guru Joined: 18/11/2011 Location: United KingdomPosts: 4133 |
Oh - sorry - yes you are indeed doing that!! Thanks for saying so (and the code already does but I failed to see it). John |
||||
| The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |