#define PINA (*((volatile unsigned char *)0x20))
#define DDRA (*((volatile unsigned char *)0x21))
#define PORTA (*((volatile unsigned char *)0x22))
#define EICRA (*((volatile unsigned char *)0x69))
#define EICRB (*((volatile unsigned char *)0x6A))
#define EIMSK (*((volatile unsigned char *)0x3D))
#define SREG (*((volatile unsigned char *)0x5F))
#define INT7 7
#define INT6 6
#define INT5 5
#define INT4 4
#define INT3 3
#define INT2 2
#define INT1 1
#define INT0 0
#define ISC7 6
#define ISC6 4
#define ISC5 2
#define ISC4 0
#define ISC3 6
#define ISC2 4
#define ISC1 2
#define ISC0 0
#define sei() __asm__ __volatile__ ("sei" ::)//7번비트만 1로 만들어줌.어셈블리코드
#define sleep() __asm__ __volatile__ ( "sleep" "\n\t" :: )
void __vector_1(void) __attribute__((signal, used, externally_visible));//인터럽트 신호를 받는다,사용된다,외부에서 이걸 볼 수 있어야한다.(호출가능하다)
int main(void)
{
DDRA=0xff;
PORTA=0x00;
EICRA=(3<<ISC0);//ISC0==INT0
EIMSK=(1<<INT0);//==EIMSK=1;,INT0만 열고 나머지문은 다 닫는다.만약 다른것도 열고 싶으면 (1<<INT0) | (1<<INT3);이렇게 쓴다.
SREG=SREG|(1<<7);//어셈블리보다 코드보다 느리다.SREG=SREG | (1<<7)==sei();
while(1)
{
sleep();
}
return 0;
}
void __vector_1(void)
{
volatile unsigned int uiCnt;
for(uiCnt = 0; 30000>uiCnt ; ++uiCnt);
PORTA=~PORTA;
}
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
미 정부 오픈소스 직접개발 &배포 (0) | 2016.03.15 |
---|---|
20160311-조재찬-업무일지-펌웨어분석 (2) | 2016.03.15 |
20160314_장진웅_업무일지_펌웨어 분석 (4) | 2016.03.15 |
인터럽트 (0) | 2016.03.14 |
인터럽트 (1) | 2016.03.14 |
20160311_김도관_업무일지_Artmega_7Segment & LED8개 교차점멸 (4) | 2016.03.14 |
2016.03.08 민경호 업무일지 - 파일 입출력 (1) | 2016.03.14 |
20160310-허도경-CPU모듈2 (3) | 2016.03.13 |