Цитата(Labinskiy Nikolay @ Jul 22 2006, 11:20)

Код
#include <avr/io.h>
void delay_us(uint16_t t)
int i;
if (t > 10)
for (i=0;i<t/10;i++)
_delay_us(10);
else
_delay_us(t);
}
}
В этой функции 2 ошибки:
1. Вы используете деление в цикле: "for (i=0;i<t/10;i++)", на эту операцию требуеться примернр 200 циклов (AVR200: Multiply and Divide Routines). Следовательно вы получаете дополнительную задежку в 200us к каждым 10.
2. _delay_us(t); -так нельзя. Используйте '_delay_us' (и '_delay_мs') только с константами, или вы получите дополнительную задежку на несколько операций с плавуещей точкой:
Код
\note When using _delay_us() and _delay_ms(), the expressions
passed as arguments to these functions shall be compile-time
constants, otherwise the floating-point calculations to setup the
loops will be done at run-time, thereby drastically increasing
both the resulting code size, as well as the time required to
setup the loops.
В вашем случае вы можете применять '_delay_us' для задежек до 768us. Читайте описание '_delay_us'.
Анатолий.
Сообщение отредактировал aesok - Jul 22 2006, 10:37