본문 바로가기
코스웨어/16년 스마트컨트롤러

20160314-허도경-업무일지-펌웨어분석2

by 알 수 없는 사용자 2016. 3. 16.
728x90
반응형

내, 외부 인터럽트: 신호를 내는것이 내부냐 왜부냐에 따라 결정

벡터넘버: 인터럽트에 번호를 넣음(고유번호)

---------------------------------------------------------------------------

DK128 LED켜고 끄기

Main.c통합방식

#include(void)

#define DDRA (*((volatile unsigned char *)0x21))
#define PORTA  (*((volatile unsigned char *)0x22))
#define PINA  (*((volatile unsigned char *)0x20))
#define EIMSK  (*((volatile unsigned char *)0x3D))
#define EICRA   (*((volatile unsigned char *)0x69))
#define EICRB   (*((volatile unsigned char *)0x6A))
#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" ::)
#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);
 EIMSK = (1<<INT0);//
 SREG = SREG|(1<<INT7);//sei();
 
 
 
 
 while(1);
 
 return 0;
}
void __vector_1(void)//이름안에 들어갈수 있는것은 언더바(_),알파벳(대 소문자),숫자
{
 volatile unsigned int uiCnt;
 for(uiCnt = 0; 30000>uiCnt ; ++uiCnt);
 PORTA = ~PORTA;
 
 }


나누어서 만들기(main.c와 main.h로 나눔)

main.c

#include<"main.h">

int main(void)
{
 DDRA = 0XFF;
 PORTA = 0X00;
 EICRA = (3<<ISC0);
 EIMSK = (1<<INT0);//
 SREG = SREG|(1<<INT7);//sei();
 
 
 
 
 while(1);
 
 return 0;
}
void __vector_1(void)//이름안에 들어갈수 있는것은 언더바(_),알파벳(대 소문자),숫자/
{
 volatile unsigned int uiCnt;
 for(uiCnt = 0; 30000>uiCnt ; ++uiCnt);
 PORTA = ~PORTA;
 
 }


main.h

#ifndef __MAIN_H

#define __MAIN_H

#define DDRA (*((volatile unsigned char *)0x21))
#define PORTA  (*((volatile unsigned char *)0x22))
#define PINA  (*((volatile unsigned char *)0x20))
#define EIMSK  (*((volatile unsigned char *)0x3D))
#define EICRA   (*((volatile unsigned char *)0x69))
#define EICRB   (*((volatile unsigned char *)0x6A))
#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" ::)
#define sleep() __asm__ __volatile__ ( "sleep" "\n\t" :: )

void __vector_1(void) __attribute__((signal, used, externally_visible));

#endif//__MAIN_H_


728x90