[chbot] C question: variables in GCC

Mark Atherton markaren1 at xtra.co.nz
Thu Jun 1 19:47:54 BST 2023


Hi All,

I am working on a low-power application for an ATmega328P where the 
watchdog is used to repeatedly restart the machine for one particular state.

One of the mechanisms (part of a bootloader) requires that the number of 
WD restarts are counted by a U16.

I am pretty sure that C99 normally only supports initialized variables 
(with associated value) and uninitialized variables (which are set to 0).

Is it possible to declare storage in C that isn’t touched by the 
associated startup code ?

Options seem to be to resort to assembler (and possibly have to do 
battle with the linker script), or to find a couple of unused Read/Write 
peripheral registers within the 328 and use them.

Thoughts please.

Thanks, Mark




More information about the Chchrobotics mailing list