Hallo,

ich möchte mit Timer0 einen 50ms Takt erzeugen:

Quartz: 16 MHz.
uC: AT90CAN128
CKDIV8 ist aus (avrstudio)

Code:
#ifndef F_CPU
#define F_CPU 16000000UL	// Takt des Quarz
#endif

// Header-Dateien
// -------------------------------
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <stdbool.h>
#include <util\delay.h>

volatile unsigned short t0_prescaler = 0;
bool fuenfzig_ms = false;




// Funtkionsprototypen
//--------------------------------
void init(void);

int main()
{
	init();				// Initialisierungsfunktion

	while(1)			// Endlossschleife 
	{
		if (fuenfzig_ms = true)
		{
			fuenfzig_ms = false;
		}

	}	
}



void init (void)
{
	sei();
	//
	// Initialisierung Timer 0
	// Waveform Generation Mode: normal Mode
	// Compare Output Mode: disconnected
	// Clock Select: CLK/1024
	// Timer Overflow Interrupt enabled ----> abfangen mit: ISR (TIMER0_OVF_vect){ ; }
	TCCR0A |= (1<<CS00) | (0<<CS01) | (1<<CS02);    	
	TIMSK0 |= (1<<TOIE0);
}


ISR (TIMER0_OVF_vect)
{
	t0_prescaler++;

	if (t0_prescaler >= 781 )
	{
		fuenfzig_ms = true;
		t0_prescaler = 0;
	}	
}
Das Problem ist, dass der TIMER0-Overflow-Interrupt nur alle 16,38ms ausgelöst werden.
Nach Rechnung sollte er aber alle 64us ausgelöst werden (=1024/16MHz).


Also ich reg mich hier nur noch auf Ich verstehs einfach nicht...


Viele Grüße
Almic