Example code 10.1 – Wavetronix Click 500 (programmable controller) (CLK-500) - Developer Guide User Manual
Page 111
110
CHAPTER 10 • MEMORY MANAGEMENT
void Setup1( void )
{
ClickflashRead(&flashData, sizeof(flashData), 0);
if ( (flashData.messageIdx < 0)
|| (flashData.messageIdx > 3)
)
{
flashData.messageIdx = 3;
}
ClickLedOff(ALL);
ClickLedOn(YELLOW1+flashData.messageIdx);
printf(“Message index read from flash is: %d\r\n”,
flashData.messageIdx );
}
Example Code 10.1
Example Code 10.1 shows how to place a constant string in far memory. Then based on
button presses, the text string can be copied into a near memory buffer and a far memory
buffer, using the ClickUtilSetDefaultString and _f_memcpy functions.
The example code further illustrates that by running TaskA, an index associated with this
string can store in non-volatile flash memory. The yellow LED bank and STDIO printf mes-
sages (see Figure 10.8) are used to indicate which message is currently selected. Likewise,
after a power cycle, the yellow LED bank will indicate which index is stored in memory.
Figure 10.8 – Standard I/O Window