오전수업
------------------------------------------------------------
#define DDRF (*(volatile unsigned char *)0x61)
#define PORTF (*(volatile unsigned char *)0x62)
#define DDRD (*(volatile unsigned char *)0x31)
#define PORTD (*(volatile unsigned char *)0x32)
#define PIND (*(volatile unsigned char *)0x30)
#define DDRC (*(volatile unsigned char *)0x34)
#define PORTC (*(volatile unsigned char *)0x35)
#define PINC (*(volatile unsigned char *)0x33)
#define SET_FND(num) PORTF=((num%10)+((num/10)<<4))
#define NOP() asm volatile ("nop");
#define DELAY_MS 400 //딜레이 시간설정
#define FIRST 0
int main(void)
{
unsigned int us = 0; //10^-6
unsigned int ms = 0; //10^-3
unsigned char fnd;
unsigned char start;
DDRF= 0xff; //FND 연결
PORTF = 0x00;
DDRD = 0xf2; //스위치
PORTD = 0x00;
if(FIRST)
{
fnd = 0;
start = 1;
}
else
{
fnd = 10;
start = 0;
}
while(1)
{
if(PIND&0x01)
{
start = 1;
if(fnd>100) //12345678910..21~
{
fnd = FIRST?0:10;
}
}
if(start)
{
SET_FND(fnd);//20
fnd++;//29
if((fnd%10)==0)
{
start = 0;
fnd+=10; //fnd의 값
PORTD = 0x02;
}
}
for(ms = 0; ms < DELAY_MS; ms++) //16 * ms * 1000
{
for(us = 0; us < 1000; us++)//4
{
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1
NOP(); //1 = 16
NOP(); //1
NOP(); //1
NOP(); //1
}
}
PORTD = 0x00;
}
return 0;
}
-------------------------------------------------------
ATMega 2기를 이용하여 카운터를 연동하여 세는 실습.
강사님이 코딩한 소스이다.
오후수업
1번문제.
2번문제
3번
5번
후..-_-;;
'School Study' 카테고리의 다른 글
[BSP]업무일지 -20100608 -임종현 (0) | 2010.06.08 |
---|---|
[BSP]업무일지 - 20100607 - 임종현 (0) | 2010.06.07 |
[BSP]업무일지 - 20100527 -임종현 (0) | 2010.05.27 |
[BPS]업무일지-20100526-임종현 (0) | 2010.05.26 |
[BSP]업무일지-20100525-임종현 (0) | 2010.05.25 |