PROGMEM.. can it be used on Teensy 3.1

Status
Not open for further replies.

Wayne

Well-known member
Hi All,

I saw PROGMEM can save to flash on the device as well as other locations.

What I like to know can I do this for a HEX value or a decimal of 0 - 255?

I need a non volatile location to save or update with-out adding memory.
My current software only uses about 7% of current memory now. I have added new code, but,I'm not expecting to go anywhere close to 10% with the addition.
I just need a way to save this data and have it available when power is applied again.

Wayne
 
Note, PROGMEM on AVR processors CANNOT do what you want. It can only be modified when you install a new program, as it is stored in program memory (flash memory). The AVR is what is typically called a Harvard architecture where the program memory is distinct from the data memory, and you have to use different instructions to access data in the program memory. The Teensy is what is called a Von Nuemann architecture, where the program memory is in the same address space as the data memory, though in normal mode, the program memory has write permission turned off.

To put constant strings or structure/arrays in program memory you use PROGMEM, and the <xxx>_p functions will copy the data into a temporary buffer and do the normal operation. In the Teensy, you just declare the data to be const at top level, and the compiler will do this automatically. The PROGMEM macros are provided as a stub on the Teensy. If you are adapting 1.0.x Arduino code, you will need to add the const keyword to the data.

What you want is the EEPROM library (http://arduino.cc/en/Reference/EEPROM). EEPROM is an area of memory that is not cleared when the power is reset. Note that EEPROM memory can only be written so many times before it starts failing, so you want to update the EEPROM value only occasionally and not in the inner loop of your program. The Teensy 3.0/3.1 has 2K of EEPROM bytes. The LC emulates EEPROM with 128 bytes, but if you are doing heavy access to EEPROM, you probably don't want to use the LC.
 
Thank you Michael,

I expect it will only be written to very seldom, but be read from at every boot of the system.
I discovered on the program I did is when a tech would run a proprietary program and access the display and saves updated information (its going into my program and not storing into theoriginal monitor) caused the workstation to null out max brightness.
When this happened, the sleep function (lowering the brightness) did no longer work.
In other words, My program sends default data that I have set that is sent to the workstation during booting of generic values just to satisfy the workstation. My display has its own controls for brightness, contrast and like stuff. But I found out if I made a change
to anything of my default values, the outside software would go through the routine of updating data that my program would not even accept. So it fails and zeroes the brightness data on the workstation.
This had created an issue of a sleep function because of the fail saving to the workstation of updated of data. I think I have fooled it enough by looking for any saving data and echoing it back which it thinks it was saved ok..
I know, the above is confusing, Trust, so am I..

So I had this hairy bright idea of maybe I can update the brightness value if they wanted too. Thus I have no idea why they would want to since I can supply a simple button. And they would need to pay like $250 / hour for tech to do it.

I saw PROGMEM, but never looked into EEPROM.. So I might play a bit.. Since my Demo monitors are not due for a few more weeks.
I call this tweaking programming.

Again, Thanks for the pointer..
 
Status
Not open for further replies.
Back
Top