#include<avr/io.h>

int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;

a=0;
while(1){
if(9>=a)
{
//PORTE=R;
_delay_ms(200);
a++;
R++;
}
else if(0x99>=R)
{
a=0;
R=0;
L=L+0x10;
R=L;
}
else
{
a=0;
R=0;
L=0;
}
PORTE=R;
}}
return 0;
}


/* 00~99까지 증가 FND
#include<avr/io.h>

int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;

a=0;
while(1){
if(9>=a)
{
//PORTE=R;
_delay_ms(200);
a++;
R++;
}
else if(0x99>=R)
{
a=0;
R=0;
L=L+0x10;
R=L;
}
else
{
a=0;
R=0;
L=0;
}
PORTE=R;
}}
return 0;
}
*/

/*   스위치+FND숫자표시
#include<avr/io.h>

int main()
{
DDRC = 0x00;
DDRE = 0xff;
volatile unsigned char a=0;
volatile unsigned char R=0;
volatile unsigned char L=0;
for(;;)
{
asm("NOP");
R=0x00;
L=0x00;

a=~PINC;
while(a>=1)
{
a/=2;
R++;
L=R<<4;
}
PORTE=R+L;
}
return 0;
}

0000 0001 = 0000 0001 1
0000 0010 = 0000 0010 2
0000 0100 = 0000 0011 3
1000 0000 = 0000 1000 8

*/
하버드 ☜ data bus : 8bit, adress bus : 16bit, RISC, 133개의 명령어
PIN ☜  Port A~F 까지는 8bit G만 5bit 총 54개

char : 1byte.
int : 2byte.
float : 4byte.
long : 4byte.
dubble : 4byte.
*(포인트) : 2byte.






















I/O reg 3가지
DDRx : 데이터 입출력 방향
PORTx : 데이터 출력
PINx : 포트x로 들어오는 입력값

포트F  출력용 사용
#include <avr/io.h>
int main()
{
DDRF = 0xFF; //F포트를 출력으로 설정
PORTF =  0x00; //F포트의 LED on
return 0;
}

+ Recent posts