#include<avr/io.h>
void Delay_us(unsigned int time_us) /* time delay for us */
{
register unsigned char i;
for(i = 0; i < time_us; i++) // 4 cycle +
{ asm volatile(" PUSH R0 "); // 2 cycle +
asm volatile(" POP R0 "); // 2 cycle +
asm volatile(" PUSH R0 "); // 2 cycle +
asm volatile(" POP R0 "); // 2 cycle +
asm volatile(" PUSH R0 "); // 2 cycle +
asm volatile(" POP R0 "); // 2 cycle = 16 cycle = 1 us for 16MHz
}
}
void Delayms(unsigned int time_ms) /* time delay for ms */
{ register unsigned int i;
for(i = 0; i < time_ms; i++)
{ Delay_us(250);
Delay_us(250);
Delay_us(250);
Delay_us(250);
}
}
int main(void)
{
DDRE=0xFF;
PORTE=0xFF;
//DDRF=0xFF;
//PORTF=0xFF;
volatile unsigned char b=0;
volatile unsigned char a=0;
for(;;)
{
asm("NOP");
//PORTF = PINC;
for(a=9;a>0;a--)
{
for(b=9;b>0;b--)
{
PORTE =a<<4 | b;// 예 0001==>> 0001 0001
Delayms(500);
}
}
}
return 1;
}
'ATMEGA' 카테고리의 다른 글
/* cds 이용 led 불켜기 adc07이용*/ (0) | 2009.12.17 |
---|---|
FND 두자리 동시에 같은숫자표현 (0) | 2009.12.10 |
1칸?씩 쉬프트시키면서 불켜기 (0) | 2009.12.10 |
/*0~99까지 순차적으로 숫자를 1씩 증가하면서 FND(7 SEGMENT)에 표시 하기*/ (0) | 2009.12.10 |
1칸?씩 쉬프트시키면서 LED 쌓이면서 켜기 (0) | 2009.12.10 |