//#include "AT91SAM7S256.h"
//#include "lib_AT91SAM7S256.h"
//#include "OK7S256ads.h"
#define PIO_SODR (*(volatile unsigned int *) 0xFFFFF430) //출력
#define PIO_CODR (*(volatile unsigned int *) 0xFFFFF434) //출력 하지 않음
#define PIO_OER (*(volatile unsigned int *) 0xFFFFF410) //출력 방향 설정
#define PIO_PER (*(volatile unsigned int *) 0xFFFFF400) //병렬 입출력 제어 레지스터 병렬 입출력 포트로 사용한다.
#define PIO_IFER (*(volatile unsigned int *) 0xFFFFF420)
#define PIO_IER (*(volatile unsigned int *) 0xFFFFF440)
#define AIC_IDCR (*(volatile unsigned int*) 0xFFFFF124)
#define AIC_SVR ((volatile unsigned int*) 0xFFFFF080)
#define AIC_SMR ((volatile unsigned int*) 0xFFFFF000)
#define AIC_IECR (*(volatile unsigned int*) 0xFFFFF120)
#define AIC_ICCR (*(volatile unsigned int*) 0xFFFFF128)
#define PIO_ISR (*(volatile unsigned int*) 0xFFFFF44C)
#define PIO_PUDR (*(volatile unsigned int*) 0xFFFFF460)// 풀업저항 인터럽트 레지스터
//---------- 전력 제어 설정
#define PMC_PCER (*(volatile unsigned int *) 0xFFFFFC10)
#define MASTERCLOCK 48000000
void Delay_ms(unsigned int ms) //딜레이 함수..
{
volatile unsigned int count, countmax = (MASTERCLOCK / 10000) * ms;
for(count = 0; count < countmax; count++);
}
//--------- 전역 변수
void PIO_ISR001(void)
{ unsigned int i,status;
//status =(AT91F_PIO_GetInterruptStatus(AT91C_BASE_PIOA)>>7) & 0x00000003;
status =PIO_ISR & 0x00000600;// 9번,10번 인터럽트 신오가 들어恙철?
if(status == 0x200) //포트PA9번에 입력이들어올때
{ for(i=1;i<3;i++)
{
PIO_SODR = 0x00000001;//PA0 LED ON
//LED_on(LED1);
Delay_ms(500);
//LED_off(LED1);
PIO_CODR = 0x00000001;// PA0 LED OFF
Delay_ms(500);
}
}
else if(status == 0x400)// WHEN PA10번에 입려이들어
{ for(i=1;i<3;i++)
{
PIO_SODR = 0x00000002;//PA1번에 LED ON
//LED_on(LED2);
Delay_ms(500);
//LED_off(LED2);
PIO_CODR = 0x00000002;//PA1 LED OFF
Delay_ms(500);
}
}
}
/*
void Delayms(unsigned int ms) //딜레이 함수..
{
volatile unsigned int count, countmax = (MASTERCLOCK / 10000) * ms;
for(count = 0; count < countmax; count++);
}
*/
int main(void)
{
PMC_PCER = (unsigned int )1<<2;
PIO_OER = 0x00000FFF; //포트PA0~PA10 출력 을 허용 한다
//PIO_SODR = 0x00000600; //PA9,10번 출력 1로 출력 한다
PIO_PUDR = 0x00000600;// 9 번 10번 으로 입력 허용
//PIO_IFER = 0x00000600;//
//Delay_ms(50);
//MCU_initialize();
//Delay_ms(50);
//AT91F_PIO_InputFilterEnable(AT91C_BASE_PIOA,KEY2|KEY1);
PIO_IFER=(unsigned int)1<<9|(unsigned int)1<<10;// 인터럽트 필터 이네이블
//AT91F_PIO_InterruptEnable(AT91C_BASE_PIOA,KEY2|KEY1);
PIO_IER=(unsigned int)1<<9|(unsigned int)1<<10;//인터럽트 이네이블레지스터
//AT91F_AIC_ConfigureIt(AT91C_BASE_AIC,AT91C_ID_PIOA,7,1,PIO_ISR);
AIC_IDCR = (volatile unsigned int)1<<2;
AIC_SVR[2] = (unsigned int) PIO_ISR001;
AIC_SMR[2] = 7;// 병렬 입출력포트(2번임)에 우선 순위 인터럽트 7(가장높若??를 주어라
//AT91F_AIC_EnableIt(AT91C_BASE_AIC,AT91C_ID_PIOA);
AIC_IECR=(volatile unsigned int)1<<2; //인터럽트 허용 명령 레지스터
AIC_ICCR=(volatile unsigned int)1<<2; //인터럽트를 금지 한다
while(1);
}
// PIO_CODR = 0x0000000F;
// Delayms(500);}
// End Main....
'ARM7' 카테고리의 다른 글
ARM 7 타이머 카운트의 정리 (0) | 2010.03.11 |
---|---|
가속도 센서 로 스텝모터 전후진 하기 (0) | 2010.02.10 |
타이머 카운터 파형발생 모드 0x8989C402 ==>>WAVESELL= 10(C) LED점점 밝아 지기 (0) | 2009.12.14 |
타이머 카운터 파형발생 모드 WAVESELL=01 0x8989A402=>1010(바이너리) 10=(A)16진수 LED서서히점멸 (0) | 2009.12.14 |
수신 인터럽트에의한 직렬 통신 (0) | 2009.12.10 |