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: AustraliaPosts: 512 |
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 StatesPosts: 535 |
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: AustraliaPosts: 122 |
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 Sounds like better programming practice. Rob Gray, AKA the Graynomad, www.robgray.com |
||||
MicroBlocks Guru Joined: 12/05/2012 Location: ThailandPosts: 2209 |
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. Microblocks. Build with logic. |
||||
graynomad Senior Member Joined: 21/07/2010 Location: AustraliaPosts: 122 |
Then that's a WHOLE different ball of wax. Rob Gray, AKA the Graynomad, www.robgray.com |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
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: AustraliaPosts: 512 |
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: AustraliaPosts: 935 |
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 KingdomPosts: 284 |
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: ThailandPosts: 2209 |
@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. Microblocks. Build with logic. |
||||
Geoffg Guru Joined: 06/06/2011 Location: AustraliaPosts: 3194 |
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 |