??? 05/05/08 19:24 Read: times |
#154444 - Some questions Responding to: ???'s previous message |
It's hard to give exact advice about what to do without knowing more about the project like how does a user enter this mode where they enter parameters? Do these buttons have other functions when they are not in this mode? Here are a few comments:
1) You seem to have a variable for every mode (CTParam, PRTParam...), why not one varaiable that holds the current state of entering the parameters. An enumerated type would seem to fit this well, like: enum Parameter_Enty_States = { NO_ENTRY, CT_PARAMETER, PRT_PARAMETER.... }; typedef enum Parameter_Entry States Parameter_Entry_States ... Parameter_Entry_States Entry_State; Whenever this entry mode is to entered Entry_State is set to CT_PARAMETER then increment when the next parameter is to be entered. I would do the same sort of thing with IncPB, DecPB, etc. 2) If you do the above you use Entry_State as the index for an array of parameters, there is no reason to have 5 blocks of code with only the name of a variable changed. This is what arrays are for. You replace CycleTime with ParameterValues[Entry_State] and these is no need for the redundant code. 3) You can either save each value to flash after entry or write all entires after the user has completed entering the values. Don't forget you need to erase the flash page where they are being stored before you write them. 4) Erik and Craig have addressed the possible need of a walking write. If these values could be changed more times than the minimum number of erase/write cycles for the flash in your microcontroller (appears to be 20K) then you need to implement a walking write. |
Topic | Author | Date |
Config. Parameter save to Flash | 01/01/70 00:00 | |
erase, then write, both are ... | 01/01/70 00:00 | |
The chip is a Silabs F8051F020 | 01/01/70 00:00 | |
Walking write | 01/01/70 00:00 | |
an issue and an answer | 01/01/70 00:00 | |
Some questions | 01/01/70 00:00 | |
Brief postings.... | 01/01/70 00:00 | |
Parameter Storage.... | 01/01/70 00:00 | |
The issue with migration..from ASM to C | 01/01/70 00:00 | |
killing a possible misconception![]() | 01/01/70 00:00 |