I am trying to setup my timer on the STK-500 using the AT90S8515 that came with
the kiit. I can get the timer running but I am having trouble getting the output pin to
toggle at the frequency I want. It seems to be toggling at Clk/2 or 1.854 MHz.
The code I have written (In AVRStudio 3.54) is as follows:
.def Temp = r16
.org 0x0000 ;Place following code at address 0x0000
rjmp Reset ;Relative jump to Reset Label
out DDRD,Temp ;Set PortD to Output
ldi Temp,(1 << COM1A0) ;Toggle OC1X
out TCCR1A,Temp ;Set Timer Counter Control Register 1A
out TCCR1B,Temp ;Set update rising edge ICES1
;Clear on Match CTC1
;Use System Clock
ldi Temp,(1 << OCIE1B)
out TIMSK,Temp ;Set Timer Interrupt Mask to Output Compare channel B
out OCR1BH,Temp ;Set Compare value high byte
out OCR1BL,Temp ;Set Compare value low byte
sei ;Enable interrupts
rjmp Loop ;Endless loop for testing
This Code gives a frequency on Pin D5 of 1.854 MHz.
Changing the prescale changes this value so the timer is basically set.
I am sure there is something small I am missing if someone can point it out
I would be very appreciative.