avr123.nm.ru писал(а):
GIGAWAT писал(а):
первым делом я стал проверять мременные задержки.
А в чем вы проверяли ?
Проверял я реальным осцилографом.
Кстати, оцените кусок кода (особенно красным цветом):
/*****************************************************************************
*
* Function name : OSCCAL_calibration
*
* Returns : None
*
* Parameters : None
*
* Purpose : Calibrate the internal OSCCAL byte, using the external
* 32,768 kHz crystal as reference
*
*****************************************************************************/
void OSCCAL_calibration(void)
{
unsigned char calibrate = FALSE;
int temp;
unsigned char tempL;
CLKPR = (1<<CLKPCE); // set Clock Prescaler Change Enable //Может вот сдесь надо поменять
// set prescaler = 8, Inter RC 8Mhz / 8 = 1Mhz
CLKPR = (1<<CLKPS1) | (1<<CLKPS0);TIMSK2 = 0; //disable OCIE2A and TOIE2
ASSR = (1<<AS2); //select asynchronous operation of timer2 (32,768kHz)
OCR2A = 200; // set timer2 compare value
TIMSK0 = 0; // delete any interrupt sources
TCCR1B = (1<<CS10); // start timer1 with no prescaling
TCCR2A = (1<<CS20); // start timer2 with no prescaling
while((ASSR & 0x01) | (ASSR & 0x04)); //wait for TCN2UB and TCR2UB to be cleared
#ifdef debug_on
Delay(0);
#else
Delay(1000); // wait for external crystal to stabilise
#endif
while(!calibrate)
{
cli(); // mt __disable_interrupt(); // disable global interrupt
#ifdef debug_on
calibrate = TRUE; // the interRC is correct
#endif
TIFR1 = 0xFF; // delete TIFR1 flags
TIFR2 = 0xFF; // delete TIFR2 flags
TCNT1H = 0; // clear timer1 counter
TCNT1L = 0;
TCNT2 = 0; // clear timer2 counter
while ( !(TIFR2 && (1<<OCF2A)) ); // wait for timer2 compareflag
TCCR1B = 0; // stop timer1
sei(); // __enable_interrupt(); // enable global interrupt
if ( (TIFR1 && (1<<TOV1)) )
{
temp = 0xFFFF; // if timer1 overflows, set the temp to 0xFFFF
}
else
{ // read out the timer1 counter value
tempL = TCNT1L;
temp = TCNT1H;
temp = (temp <<

;
temp += tempL;
}
if (temp > 6250)
{
OSCCAL--; // the internRC oscillator runs to fast, decrease the OSCCAL
}
else if (temp < 6120)
{
OSCCAL++; // the internRC oscillator runs to slow, increase the OSCCAL
}
else
calibrate = TRUE; // the interRC is correct
TCCR1B = (1<<CS10); // start timer1
}
}
Как я понял у меня частота установлена на 8Мгц и установкой бита она делится на 8 т.е. 1Мгц может быть в этом и суть ?