Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Store variable between microcontroller resets using noinit memory problem

Status
Not open for further replies.

my_abousamra

Junior Member level 3
Joined
Nov 25, 2008
Messages
25
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,478
Hi,

I want to store a variable value between microcontroller resets (not power off). The case is that the microcontroller goes to sleep and woke up by interrupt caused by a button press where in interrupt handler I should assign a certain value to a variable and reset the controller and after controller reset it should read the new value. I tried to do it using no init section in linker script but it doesn't work. Here's what I did

Code:
uint8 u8FastOperationAfterReset __attribute__ ((section (".noinit")));     // a variable changed in ISR then reset the controller

and in gnu ld linker script
Code:
	.noinit :
	{
		_noinit_start = . ;
		*(.noint)
	} >ram
	
	. = ALIGN(4);						
	_noinit_end = . ;

I'm using AT91SAM7X microcontroller and gnu arm tools

thanks
 

Suggest to find out more about "doesn't work", e.g. by using the debugger. Did you assign a valid memory address, is the value written, is it unwantedly reset by the RTL init code, etc. I'm doing similar things with other GNU targets like PIC32.
 

Suggest to find out more about "doesn't work", e.g. by using the debugger. Did you assign a valid memory address, is the value written, is it unwantedly reset by the RTL init code, etc. I'm doing similar things with other GNU targets like PIC32.

Unfortunately, I don't have a debugger. I put this section after data and bss sections so no absolute address. part of the problem that I don't know how to do it (in another words, does what I did is right?) and I don't do anything in start code, I don't know should I do or not.

Code:
/* now define the output sections  */
SECTIONS 
{
	. = 0;								/* set location counter to address zero  */
	.text :								/* collect all sections that should go into FLASH after startup  */ 
	{	
		*(.sup)							/* Startup code has to be the first thing !! */				
		*(.text)						/* all .text sections (code)  */
		*(.rodata)						/* all .rodata sections (constants, strings, etc.)  */
		*(.rodata*)						/* all .rodata* sections (constants, strings, etc.)  */
		*(.glue_7)						/* all .glue_7 sections  (no idea what these are) */
		*(.glue_7t)						/* all .glue_7t sections (no idea what these are) */
		_etext = .;						/* define a global symbol _etext just after the last code byte */
	} >flash							/* put all the above into FLASH */

	.data :								/* collect all initialized .data sections that go into RAM  */ 
	{
		_data = .;						/* create a global symbol marking the start of the .data section  */
		*(.data)						/* all .data sections  */
		_edata = .;						/* define a global symbol marking the end of the .data section  */
	} >ram AT >flash          			/* put all the above into RAM (but load the LMA initializer copy into FLASH)  */

	.bss :								/* collect all uninitialized .bss sections that go into RAM  */
	{
		_bss_start = .;					/* define a global symbol marking the start of the .bss section */
		*(.bss)							/* all .bss sections  */
	} >ram								/* put all the above in RAM (it will be cleared in the startup code */

	. = ALIGN(4);						/* advance location counter to the next 32-bit boundary */
	_bss_end = . ;						/* define a global symbol marking the end of the .bss section */
	
	.noinit :
	{
		*(.noint)
	} >ram
	
	. = ALIGN(4);						/* advance location counter to the next 32-bit boundary */	
	.eh_frame :
    {
        KEEP (*(.eh_frame))
    } > flash	
}

In startup code, It copies data and clears and copies bss to ram then calls main function

- - - Updated - - -

Solved, bss initialization in start up code was overwriting it
 
Last edited:

Hi,

* You may wake up by interrupt (it usually continues after the SLEEP instruction)
* or you may use true RESET (it starts where the RESET vector points to)
In detail it deoends on microcontroller type

When it continues after the SLEEP there is no memory initialisation.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top