My first question here and please excuse my English. I am playing with Nordic nrf51 Timer module (using a BBC microbit v1.5). I am using Timer1 to flash a LED. I stored a value to the capture register CC[1] which, according to the reference manual, will generate a event compare[1] when the Timer counter register reaches that value. The compare[1] has an offset address and whenever the compare[1] turns to 1 I toggle the LED and have to manual set compare[1] to 0 + clear the timer counter to count from 0 again. The pseudo code is something like this:
Timer_source=timer1;
timer_bitmode is 16 bit
Prescaler=9 => 16MHz/2^9= 31250 ticks per second
Write 31250 to CC[1] ( 1 second) => compare[1] event will be generated when timer reaches CC[1]'s value
set LED_pin as output;
Start timer;
while(1){
check compare[1] (timer address + offset) if it equals 1 => toggle LED, set compare[1] to 0 and restart the timer
}
It works as expected but I would like to make sure I understand it: the compare events each of them is it a register or just 1 bit of a register which turns 1 when generated?