Цитата(otrog @ Sep 27 2006, 16:30)

Ошибка настройки таймера скорей всего.
Приведите исходник.
Думаю, причина не в этом... Однако привожу )
//Файл timer2.cpp
CTimer2 g_Timer2;
void CTimer2::Init(PfnOnTimer2Interrupt pfnOnInterrupt)
{
m_pfnOnInterrupt = pfnOnInterrupt;
ASSR= 1<<AS2; // Enable asynchronous
// mode
// Clear timer on compare match / Timer Clock =
// system clock / 1024
TCCR2 = (1<<WGM21)|(1<<CS22)|(1<<CS21)|(1<<CS20);
TIFR= 1<<OCF2; // Clear OCF2/ Clear
// pending interrupts
TIMSK= 1<<OCIE2; // Enable Timer2 Output
// Compare Match Interrupt
OCR2= 32; // Set Output Compare
// Value to 32
while (ASSR&(1<<OCR2UB)); // Wait for registers to update
// Wait 1sec for 32768Hz crystal to stabilize
__delay_cycles(1000000UL);
}
#pragma vector=TIMER2_COMP_vect
__interrupt void Timer2InterruptHandler()
{
// TIFR= 1<<OCF2;
g_Timer2.m_pfnOnInterrupt();
}
// Файл main.c
int main()
{
g_Lcd.Init();
g_Uart.Init();
printf("\r\nProgram started.\r\n");
g_Timer2.Init(OnTimer2Interrupt);
__enable_interrupt();
uint8_t n = 0;
DATETIME dt;
while(true)
{
__disable_interrupt();
g_SystemTime.ToDateTime(dt);
__enable_interrupt();
if( (n++%10) < 3 )
{
g_Lcd.ShowDate(dt);
}
else
{
g_Lcd.ShowTime(dt);
}
/* Разрешаем Sleep-режим, PowerSafe mode */
MCUCR = (1<<SE) | (1<<SM1) | (1<<SM0);
__no_operation();
__sleep();
__no_operation();
}
}
void OnTimer2Interrupt()
{
g_SystemTime.Tick();
}