Hi,
I suppose that the line has issue.
__attribute__((section (".m_data_2"))) uint8_t foo = 123;
The above line declares a variable uint8_t foo, and save it in SRAM section .m_data_2. But as you know that the data in SRAM will be lost after power off, so the value 123 is lost after power off.
If you want to keep the value 123, the 123 must be saved in flash and copy to RAM.
1)you can define:
__attribute__((section (".m_data_2"))) uint8_t foo;
int main(void)
{
foo=123;
PRINT(foo);
}
2)you can use the line:
uint8_t foo=123;
int main(void)
{
PRINT(foo);
}
3)const uint8_t var=123;
__attribute__((section (".m_data_2"))) uint8_t foo;
int main(void)
{
foo=var;
PRINT(foo);
}
Hope it can help you
BR
XiangJun Rong