AVR单片机ICCAVR怎么写延时函数?
AVR单片机ICCAVR怎么写延时函数? 可以参考一下//Fclk6.000 MHz
// Delay Count * 1us
void DelayX1us(unsigned int count)
{
unsigned int i;
for(i=0;i<count;i++)
{
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
//asm("nop");
//asm("nop");
//asm("nop");
//asm("nop");
//asm("nop");
}
}
// Delay Count * 1ms
void DelayX1ms(unsigned char count)
{
unsigned char j;
unsigned int i;
for(j=0;j<count;j++)
{
for (i=0;i<1000;i++)
{
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
asm("nop");
}
}
}
// Delay Count * 10ms
void DelayX10ms(unsigned char count)
{
unsigned char i;
for (i=0;i<count;i++)
DelayX1ms(9);
}
// Delay Count * 100ms
void DelayX100ms(unsigned char count)
{
unsigned char i;
for (i=0;i<count;i++)
DelayX10ms(10);
}
页:
[1]