I’ve already tried that. In my program the value 17 is picked and the value stays at 17. I need to initialise the value outside the function somehow then allow the function to change the value from (say) 17 to 16 during the operation.
variable declaration (or) declaration and initialisation
This is done in the .c-file at the top, outside any function:
[tt]unsigned char record_button_state;[/tt] (or)
[tt]unsigned char record_button_state = 17;[/tt]
The additional keyword “volatile” is used to tell the compiler that this variable may be changed in other places. So it’s a good idea to add this for globals:
I think, that the initialisation of RAM variables outside a function won’t work, because this requires a special SDCC specific copy routine, which copies the value from flash memory into RAM.
I am nearing the end of the organ project ( I hope!) and found that there was a problem in starting the organ in a common sense way. In fact to select any organ stops it was necessary to push either the “Record” or “Playback” button first.
This was not logical.
I decided to see if I could initialise the variable to the “non Record” “non Playback” state (7). I knew that if I could achieve this, the organ would start by selecting an organ stop.
and made the following entry in the void Init(void) function