On 11/29/2015 02:13 PM, Jeppe Johansen wrote:
Not sure the timer initialization is right, but it looks ok.
One thing you need is the interrupt procedure directive:
procedure TIMER0_overflow; interrupt; public name 'TIMER0_COMPA_ISR';
Otherwise it'll probably reset at some point.
Ok I got it to work. I have an interrupt:
procedure TIMER0_COMPA; noreturn; public name 'TIMER0_COMPA_ISR';
begin
ToggleLED;
end;
and the timer is setup with:
procedure TimerInit;
begin
TCCR0A := TCCR0A or (1 shl WGM01);
OCR0A := $F9;
TIMSK0 := TIMSK0 or (1 shl OCIE0A);
sei;
TCCR0B := TCCR0B or 5;//scale 5 = Clock / 1024
end;
The keywords "interrupt" or "noreturn" seem to have the same effect but
are mutually exclusive.
Without the interrupt or noreturn keyword, TIMER0_COMPA is only called
once and presumably a crash or infinite loop starts somewhere. ( return
is causing an error?)
With the interrupt or noreturn keyword and those timer settings, the led
blinks at the edge of human detection. Success!
Setting interrupts for TIMER0_COMPB and TIMER0_OVC have no effect; they
are never called. I'm probably not understanding some of how to
configure timers.
Regards,
Andrew
_______________________________________________
fpc-devel maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel