Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 23:34 12 Nov 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 : Armmite L4: 5.05.09 with DOCUMENTATION!

     Page 2 of 2    
Author Message
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 06:01pm 27 Mar 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 06:05pm 27 Mar 2019
Copy link to clipboard 
Print this post

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 issueEdited by matherp 2019-03-29
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 06:20pm 27 Mar 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 08:09am 28 Mar 2019
Copy link to clipboard 
Print this post

Please find attached a trivial update that closes an open file before executing a save or autosave command

2019-03-28_180338_ArmmiteL4.zip

  Quote  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?


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.

  Quote  How is the timed sleep implemented ? are you using the RTC wakeup timer ?
Which clock domain : RTCclock with post divider


Yes

  Quote  Are there commmands to manipulate the registers directly ( like peek and poke )


PEEK and POKE should both work on registers but let me know if there appear to be issues

  Quote  when invoking SLEEP 10 :
PC13 goes low and the cpu goes to sleep for 10 seconds.
after the time has elapsed PC13 goes high and the cpu wakes up.
PC13 is controlled by the vbat power domain so it can toggle even if the main
power of the cpu is off.


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 commandEdited by matherp 2019-03-29
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 11:59am 28 Mar 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 02:40pm 28 Mar 2019
Copy link to clipboard 
Print this post

  Quote  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


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"

Edited by matherp 2019-03-30
 
sagt3k

Guru

Joined: 01/02/2015
Location: Italy
Posts: 313
Posted: 05:14pm 28 Mar 2019
Copy link to clipboard 
Print this post

Thanks matherp
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 05:18pm 28 Mar 2019
Copy link to clipboard 
Print this post

  matherp said  
LOAD "filename",r as per Micromite+



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 Kingdom
Posts: 10572
Posted: 05:32pm 28 Mar 2019
Copy link to clipboard 
Print this post

  Quote  and with that the memory size limit on any program is gone (as if it mattered with the MMX etc...)


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 Kingdom
Posts: 4134
Posted: 06:25pm 28 Mar 2019
Copy link to clipboard 
Print this post

Interesting... I did not expect variables to keep their values.

John
 
CaptainBoing

Guru

Joined: 07/09/2016
Location: United Kingdom
Posts: 2171
Posted: 06:33pm 28 Mar 2019
Copy link to clipboard 
Print this post

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 Kingdom
Posts: 10572
Posted: 06:48pm 28 Mar 2019
Copy link to clipboard 
Print this post

  Quote  it is possible to have programs that run as overlays and you simply "page in" the section of code o run.


No - sorry, all or nothing

  Quote  Question... there is no library with MMX, is there any way to maintain a "kernel" of key functions between overlays in the same way variables survive?


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.

  Quote  Interesting... I did not expect variables to keep their values.


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 Kingdom
Posts: 4134
Posted: 07:44pm 28 Mar 2019
Copy link to clipboard 
Print this post

Oh - sorry - yes you are indeed doing that!!

Thanks for saying so (and the code already does but I failed to see it).

John
 
     Page 2 of 2    
Print this page


To reply to this topic, you need to log in.

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025