Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 18:36 05 May 2024 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 : Internal PIC ram

Author Message
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 11:50pm 27 Dec 2012
Copy link to clipboard 
Print this post

Is there a limit to the number of times one can write to the internal RAM A: drive?

I wish to include some audio MOD files in a program and I am wondering whether it's detrimental to the life of the RAM if the files are loaded and unloaded each time it is run.

Should I load them once and leave them there, checking if they exist next time the main program is run and only loading in their absence?

Nick
 
hitsware
Guru

Joined: 23/11/2012
Location: United States
Posts: 535
Posted: 12:11am 28 Dec 2012
Copy link to clipboard 
Print this post

There is a supposed limit to all SS memory activity.
(even usb drives supposedly 'wear out')
It's probably best to operate as though this will
happen way sooner than it will (practically)
(to be on the safe side)
 
graynomad

Senior Member

Joined: 21/07/2010
Location: Australia
Posts: 122
Posted: 01:37am 28 Dec 2012
Copy link to clipboard 
Print this post

While there may be a theoretical limit to RAM writes I've never heard of anyone considering it in their programming. How many times are some of your variables changed? How often do you think the stack is written to?

Some programs modify RAM locations every mS (or less) for years (or more).

That said

  Quote  load them once and leave them there


Sounds like better programming practice.
Edited by graynomad 2012-12-29
Rob Gray, AKA the Graynomad, www.robgray.com
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 02:01am 28 Dec 2012
Copy link to clipboard 
Print this post

Drive "A:" is not located in RAM but in the flash memory.
With a pic32 it is guaranteed to work for at least a 1000 write cycles.

http://ww1.microchip.com/downloads/en/DeviceDoc/61156G.pdf
look at the table on page 191.
"Cell endurance" = 1000
Only the PIC32MX534/564/664/764 device have an extended endurance of 20000.

Above that and you start taking risks.
Reading of course is unlimited.Edited by TZAdvantage 2012-12-29
Microblocks. Build with logic.
 
graynomad

Senior Member

Joined: 21/07/2010
Location: Australia
Posts: 122
Posted: 02:04am 28 Dec 2012
Copy link to clipboard 
Print this post

  Quote  Drive "A:" is not located in RAM but in the flash memory.

Then that's a WHOLE different ball of wax.
Rob Gray, AKA the Graynomad, www.robgray.com
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:44pm 28 Dec 2012
Copy link to clipboard 
Print this post

This has been covered before but in essence MMBasic uses wear leveling to extend the flash memories endurance. The practical result varies according to how full drive A: is but typically if you wrote and then deleted a file once a day for every day of the year the endurance would range from 5 to 50 years.

Geoff

Geoff Graham - http://geoffg.net
 
Nick

Guru

Joined: 09/06/2011
Location: Australia
Posts: 512
Posted: 01:21pm 28 Dec 2012
Copy link to clipboard 
Print this post

I can't seem to be able to get OPTION ERROR working.

I have OPTION ERROR CONTINUE at the start of my code.

Then I test to see if a file exists on A: by trying to access it.

PLAYMOD "A:SOUND.MOD"

If the file doesn't exist under normal circumstances (without OPTION ERROR CONTINUE) the program stops with an error. Do a PRINT MM.ERRNO and I get 6, correct.

With OPTION ERROR CONTINUE, I get a zero for MM.ERRNO.

Am I doing something wrong?

Nick

 
BobD

Guru

Joined: 07/12/2011
Location: Australia
Posts: 935
Posted: 02:23pm 28 Dec 2012
Copy link to clipboard 
Print this post

That does not seem to agree with the manual. You are seeing the error being suppressed but the manual implies that the error code is still set but MMBasic won't stop for the error and it is up to you to read the error code and deal with it.

Looks like a bug to me.
 
cosmic frog
Senior Member

Joined: 09/02/2012
Location: United Kingdom
Posts: 278
Posted: 03:39pm 28 Dec 2012
Copy link to clipboard 
Print this post

Have you had a look at the example in MUSIC.BAS in the colour demos folder?


' First, check if the MOD files are on drive A: and if not. copy them
'
For i = 1 To 3
Option error continue
Open "A:T" + Chr$(48 + i) + ".Mod" For input As #1
If MM.Errno Then
Option error abort
If i = 1 Then
Print "This program will copy three files to drive A:"
Print "The screen will go blank for a while so please be patient"
Input "Press ENTER to continue...", t$
EndIf
Copy "B:T" + Chr$(48 + i) + ".Mod" To "A:"
Else
Option error abort
Close #1
EndIf
Next i

Dave.
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 09:24pm 28 Dec 2012
Copy link to clipboard 
Print this post

@Nick,

Could it be that you check the MM.Errno a little to late.
I can imagine that other statements could reset the value.
I guess the only one who really knows is Geoff. :)
In samples the test for MM.Errno is immediately after the line that could throw that error.

However, the best way is to get the information you want without the need to check errors.
You can use DIR$ to check for a files existence.


Edited by TZAdvantage 2012-12-30
Microblocks. Build with logic.
 
Geoffg

Guru

Joined: 06/06/2011
Location: Australia
Posts: 3165
Posted: 12:28pm 29 Dec 2012
Copy link to clipboard 
Print this post

Thanks folks, you have found a bug in the PLAYMOD command and I will fix it in V4.2.

Other commands should set MM.ERRNO correctly so you could use this as a workaround.

OPTION ERROR CONTINUE
OPEN "A:SOUND.MOD" FOR INPUT AS #1
IF MM.ERRNO THEN GOTO <error handler>
CLOSE #1
PLAYMOD "A:SOUND.MOD"
<continue with the program>

BTW the only commands that should change MM.ERRNO are file related commands. So, for example, PRINT MM.ERRNO would not change the value of MM.ERRNO.

Geoff
Geoff Graham - http://geoffg.net
 
Print this page


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

© JAQ Software 2024