728x90
반응형
펌웨어실습
1. LED 이동
#define DDRA (*((volatile unsigned char *)0x21))
#define PINA (*((volatile unsigned char *)0x20))
#define PORTA (*((volatile unsigned char *)0x22))
int main(void)
{
volatile unsigned int uiLoop;
unsigned int uiPos;
int iDir;
DDRA = 0xff;
PORTA = 0x00;
iDir = 1;
uiPos = 0;
while(1)
{
if(1 == iDir)
{
PORTA=~(1<<uiPos); //순방향
}
else
{
PORTA=~(0x0080>>uiPos); //역방향
}
for(uiLoop = 0 ; uiLoop<60000 ; uiLoop++);
uiPos = uiPos+1;
if(7<uiPos)
{
iDir = iDir * -1;
uiPos = 0;
}
}
return 0;
}
2. FND(0~99 카운트)
#define DDRA (*((volatile unsigned char *)0x21))
#define PINA (*((volatile unsigned char *)0x20))
#define PORTA (*((volatile unsigned char *)0x22))
#define PINA (*((volatile unsigned char *)0x20))
#define PORTA (*((volatile unsigned char *)0x22))
int main(void)
{
volatile unsigned long uiLoop;
unsigned int uiCnt;
DDRA=0xff;
PORTA=0x00;
uiCnt=0;
uiLoop=0;
while(1)
{
PORTA=((uiCnt/10)<<4)|(uiCnt%10);
for(uiLoop=0 ; uiLoop<100000 ; uiLoop++); //시간지연
uiCnt++;
if(uiCnt>99)
{
uiCnt=0;
}
}
return 0;
}
728x90
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
Lcd.h (0) | 2016.03.16 |
---|---|
Alpha Yong (1) | 2016.03.16 |
20160310_업무일지_정우민_펌웨어실습 (0) | 2016.03.16 |
20160314_김도관_업무일지_펌웨어실습_인터럽트_버튼으로 LED점멸 (0) | 2016.03.16 |
20160315-이보원 AVR2560 LCD 실험 준비 (2) | 2016.03.16 |
20160314_박진한_업무일지_펌웨어 분석 (1) | 2016.03.16 |
20160310_노유찬_CPU모듈 (0) | 2016.03.16 |
20160315_업무일지_정우민_인터럽트(FND실습) (0) | 2016.03.16 |