I am trying to make a variable pulse with on a pulse period of +-65ms (15Hz)
I use PWM on Timer1 in ATMEGA16.
PWM-Mode 5, Fast Pwm 8-Bit, Top = 0x00FF
Atmega16 is running on 4Mhz internal clock. The Timer1 prescallers are set to clk/1024. Timer1 will increment every 4k clock cycles.
When Top value of 255 is reached i will have the period of +-65ms.
It is the intention to change OCR1A register between 0-255 to have a variable pulse width.
The problem is that the changements of OCR1A are not reflected in the Pulse width!!!!
The pulse width stays the same, corresponding to the value filled in OCR1A during initialization.
I have the TOIE1, Timer-Overflow interrupt enabled.
I update OCR1A in this interrupt routine, with interrupts disabled.
The OCR1A Register however, is double buffered.
/* This feature allows the OCR1A I/O location to be written anytime.
/* When the OCR1A I/O location is written the value written will be put into the OCR1A
/* Buffer Register. The OCR1A Compare Register will then be updated with the value in
/* the Buffer Register at the next timer clock cycle the TCNT1 matches TOP. The update is
/* done at the same timer clock cycle as the TCNT1 is cleared and the TOV1 Flag is set */
This i don't understand.
OCR1A is double buffered. In my code i update OCR1A in the Timer Overflow interrupt routine. Should i update another register?
Thanks for help,