DK128으로 LED 켰다 끄기----------------
<소스>
#define DDRA (*((volatile unsigned long *)0x21))
#define PORTA (*((volatile unsigned long *)0x22))
#define PINA (*((volatile unsigned long *)0x20))
#define EICRA (*((volatile unsigned long *)0x69))
#define EICRB (*((volatile unsigned long *)0x6A))
#define EIMSK (*((volatile unsigned long *)0x3D))
#define SREG (*((volatile unsigned long *)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" ::) //sei는 어셈블리어로 7번 bit만
#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); // INT0 2진수 11->3 ex)(2<<ISC2)|(3<<ISC0) 상승과 하강엣지를 동시에 사용
EIMSK = (1<<INT0);
SREG = SREG|(1<<7);//SREG = SREG|(1<<7);는 sei();와 같은 것.
while(1)
{
sleep();
}
return 0;
}
void __vector_1 (void) //벡터 영역 부터 시작한다.
{
PORTA = ~PORTA;
}
<작동 영상>
구동 이론--------------------------
이해하기 어려워지고 있지만 그만큼 더 재미있습니다.
ATmega와 DK128로 어떤 것들 더 구현할 수 있을지 앞으로가 더 기대됩니다.
'코스웨어 > 16년 스마트컨트롤러' 카테고리의 다른 글
2016.03.11 이종찬 업무일지 (3) | 2016.03.15 |
---|---|
20160314_송민규_업무일지_펌웨어분석 (3) | 2016.03.15 |
미 정부 오픈소스 직접개발 &배포 (0) | 2016.03.15 |
20160311-조재찬-업무일지-펌웨어분석 (2) | 2016.03.15 |
인터럽트 (0) | 2016.03.14 |
인터럽트 (0) | 2016.03.14 |
인터럽트 (1) | 2016.03.14 |
20160311_김도관_업무일지_Artmega_7Segment & LED8개 교차점멸 (4) | 2016.03.14 |