Welcome! Log In Create A New Profile

Advanced

Storing a variable to flash from within a function

Posted by jon1977 
Storing a variable to flash from within a function
January 12, 2016 05:46PM
Hi,
I would like to use the BV507 in a multidrop network terminal like application.
To do this, I would like to assign an ID, using the keypad so I can later 'address' one BV507 in a multidrop RS485 network.
I could program each BV507 with a fixed / hidden ID, but I would like to set this using the LCD & keypad locally and save it so it is stored on power cycle.

I see that I should be able to use:

constant flash MyID {MyNewID}
where MyNewID is a defined variable, for instance '1'.
And I should be able to read that 'constant' back at startup.
But, I see the statement that this can not be used from within a function in the manual.
As an aside, if I manually enter this command in PyPic, the constant MyID appears to be saved, but the value of the constant is not. I note again from the manual that this is probably expected.

Is there any way to store a number or string to the internal flash, from within a function, e.g. to store or update a variable that will remain 'set' on a power cycle, or do I need to use an external eeprom?

With thanks
Jon
Re: Storing a variable to flash from within a function
January 13, 2016 08:38AM
Jon,
you are quite right, there is no mechanism for saving data within the ByPc structure, this is assigned to external devices. For small amounts of data the best way as suggested is to use EEPROM for example the one here as part of the RTC and using the I2C interface.

The other alternative is to use an SD Card and change the firmware.

Jim
Re: Storing a variable to flash from within a function
January 13, 2016 06:15PM
ok cheers.
Shame it cant work with the existing flash.
I'll probably go down the external EEprom route, or fix an ID in the firmware.
Maybe consider for future upgrades if it is physically possible?
Jon
Sorry, you do not have permission to post/reply in this forum.