Hi.
A buddy and I are playing around with timers, trying to get it to run on an atmega328p for 6 hours (he wants to build a program to automatically turn on low-power LEDs on and off).
I wrote a little program to print the CLKPR register to console (which should be readable based on the datasheet table of CLKPR- p. 37)
The console runs and prints:
CLKPR Before:0
CLKPR After:0
CLKPR Before:0
CLKPR After:0
Why is it 0? I was expecting 3.
#define SET(y,x) y &= (1 << x)
#define CLEAR(x,y) y &= ~(1 << x)
#define befaft_print(xdes,x,expr,ydes,y) \
Serial.print(xdes " Before:");\
Serial.println(x);\
expr;\
Serial.print(ydes " After:");\
Serial.println(y);
void setup() {
Serial.begin(9600);
befaft_print("CLKPR",CLKPR, CLKPR=3 ,"CLKPR",CLKPR);
befaft_print("CLKPR",CLKPR, SET(CLKPR,3) ,"CLKPR",CLKPR);
}
void loop() {
// put your main code here, to run repeatedly:
}