안녕하세요 L입니다.
오늘은 ARM7 의 AIC를
이용해 Interrupt 를
구현해
보았습니다.
★ Advanced Interrupt Controller (AIC)
※ spec :: 183p
ㆍ8개의 Interrupt(중단하다, 끼어들다) 를
운선순위에
따라
개별적으로
32개의 pin을 Interrupt 제어할
수
있다.
ㆍ IRQ : Interrupt 가
들어왔다.
ㆍ FIQ : 패스트
인트럽트
ㆍ각 핀마다 레벨을 다르게 줄수 있다.
ㆍ0V, 3V 전압에 민감하게 만들거나 모서리에 민감하게 프로그래밍 할 수 있다.
[ cstartup .S ]
ㆍ reset value (ARM) :: Initial value (AVR) ::
ㆍ PC (ARM) :: IP(인텔) :: 명령의
주소
ㆍATMEL ARM에서는 reset 주소값은 0번지부터 시작한다.
ㆍldr : 대입 연산자
ㆍb : 점프
ㆍPC : 프로그램 카운터
[ swi_vector ]
ㆍ소프트웨억 발생시키는 Interrupt.
[ pabt_vector ]
※ spec :: 16p
ㆍ명령어 수행 단계
ㆍARM 의 속도를 빠르게 하기위해 3단 pipe가 존재
[ IRQ ]
ㆍ하드웨어에서 발생하는 Interrupt.
[ FIQ ]
ㆍ점프하지않고 현재위치에서 코드를 처리한다.
ㆍ가장 먼저 실행되어야 할부분을 fiq 바로 아래 위치시키면 빠르게 처리할 수 있다.
ㆍ라벨로 점프하여 처리되기 때문에 주소값이 밀릴 걱정은 없다.
※ spec :: 183p
ㆍEmbedded Peripheral : FIQ, IRQ 에 연결 되어 있다.
ㆍFIQ, IRQ 핀 외의 것은 외부장치를 나타낸다.
ㆍWake UP : 슬립모드
ㆍFIQ, IRQ : PIO 컨트롤을 거치므로 PIO를 세팅해야 사용가능하다.
[ PIO 세팅 ]
ㆍInterrupt가 처리된후 지워지지 않음으로 아무 값이나 넣어 함수종료 부분에 위치 시킨다.
ㆍVECTOR : 주소
ㆍAIC 함수 VECTOR 을 받는다.
ㆍ본
사용자는
우선순위
레벨을 0~7 에서 0으로
사용
하였다.
ㆍ외부에서 신호를 받음으로 External Interrupt 사용
ㆍ즉 하강 엣지는 1로 주고 우선순위는 0으로 줌
ㆍGlitch Input Fliter 활성
ㆍPIOA Interrupt 를 set 한다.
ㆍPIO_ISR : 위와
같이
정의하면
한번 read 된다.
ㆍ위 소스는 글리치 필터와 같이 잡음제거 역할을 하게 된다.
ㆍ바로아래 딜레이를 걸어 잡음을 확실하게 제거한다.
※ spec :: 187p
ㆍ위의
회로도에따라
필요한
레지스터를
활성화
시키고
코드를
작성한다.
Ex) AIC 인터럽트
발생
실습
[ 헤더 파일 ] |
//////////////////////////////////////////////////////////////////////// /////////// [ 2012. 07. 18.By.L ] ////////// /////////// REF :: 6175G.ATARM.22- Nov- 60 :: SPEC ////////// //////////////////////////////////////////////////////////////////////// #ifndef __ARM_H__ #define __ARM_H__
/*========================================================================= [ Parallel Input Output Controller ( PIO > : SPEC :: P.88 ]================ ===========================================================================*/ #define PIO_PER (*((volatile unsigned int *)0xFFFFF400)) #define PIO_PDR (*((volatile unsigned int *)0xFFFFF404)) #define PIO_PSR (*((volatile unsigned int *)0xFFFFF408)) //<Reserved>=================================================== #define PIO_OER (*((volatile unsigned int *)0xFFFFF410)) #define PIO_ODR (*((volatile unsigned int *)0xFFFFF414)) #define PIO_OSR (*((volatile unsigned int *)0xFFFFF418))
//<Reserved>=================================================== #define PIO_IFER (*((volatile unsigned int *)0xFFFFF420)) #define PIO_IFDR (*((volatile unsigned int *)0xFFFFF424)) #define PIO_IFSR (*((volatile unsigned int *)0xFFFFF428)) //<Reserved>=================================================== #define PIO_SODR (*((volatile unsigned int *)0xFFFFF430))
#define PIO_CODR (*((volatile unsigned int *)0xFFFFF434)) #define PIO_ODSR (*((volatile unsigned int *)0xFFFFF438)) #define PIO_PDSR (*((volatile unsigned int *)0xFFFFF43C)) #define PIO_IER (*((volatile unsigned int *)0xFFFFF440)) #define PIO_IDR (*((volatile unsigned int *)0xFFFFF444)) #define PIO_IMR (*((volatile unsigned int *)0xFFFFF448)) #define PIO_ISR (*((volatile unsigned int *)0xFFFFF44C)) #define PIO_MDER (*((volatile unsigned int *)0xFFFFF450)) #define PIO_MDDR (*((volatile unsigned int *)0xFFFFF454)) #define PIO_MDSR (*((volatile unsigned int *)0xFFFFF458)) //<Reserved>=================================================== #define PIO_PUDR (*((volatile unsigned int *)0xFFFFF460)) #define PIO_PUER (*((volatile unsigned int *)0xFFFFF464)) #define PIO_PUSR (*((volatile unsigned int *)0xFFFFF468)) //<Reserved>=================================================== #define PIO_ASR (*((volatile unsigned int *)0xFFFFF470)) #define PIO_BSR (*((volatile unsigned int *)0xFFFFF474)) #define PIO_ABSR (*((volatile unsigned int *)0xFFFFF478)) //<Reserved>=================================================== #define PIO_OWER (*((volatile unsigned int *)0xFFFFF4A0)) #define PIO_OWDR (*((volatile unsigned int *)0xFFFFF4A4)) #define PIO_OWSR (*((volatile unsigned int *)0xFFFFF4A8))
/*========================================================================= [ Power Management Controller ( PMC ) User Interface : SPEC :: P.222 ]===== ==========================================================================*/ #define PMC_PCER (*((volatile unsigned int *)0xFFFFFC10)) #define PMC_PCDR (*((volatile unsigned int *)0xFFFFFC14)) #define PMC_PCSR (*((volatile unsigned int *)0xFFFFFC18))
/*========================================================================= [ Peripheral Identifiers : SPEC :: P.34 ]================================== ==========================================================================*/ #define AIC_FIQ 0 // Advanced Interrupt Controller #define SYSC 1 // System #define PIOA 2 // Parallel I/O Controller A #define ADC 4 // Analog-to Digital Converter #define SPI 5 // Serial Peripheral Interface #define US0 6 // USART 0 #define US1 7 // USART 1 #define SSC 8 // Synchronous Serial Controller #define TWI 9 // Two-wire Interface #define PWMC 10 // PWM Controller #define UDP 11 // USB Device Port #define TC0 12 // Timer/Counter 0 #define TC1 13 // Timer/Counter 1 #define TC2 14 // Timer/Counter 2 #define AIC_IRQ0 30 // Advanced Interrupt Controller #define AIC_IRQ1 31 // Advanced Interrupt Controller
/*====================================================================== [ Advanced Interrupt Controller (AIC) : SPEC :: P.198 ]================= ========================================================================*/ #define AIC_SMR0 (*((volatile unsigned int *)0xFFFFF000)) #define AIC_SMR1 (*((volatile unsigned int *)0xFFFFF004)) #define AIC_SMR2 (*((volatile unsigned int *)0xFFFFF008)) #define AIC_SMR3 (*((volatile unsigned int *)0xFFFFF00C)) #define AIC_SMR4 (*((volatile unsigned int *)0xFFFFF010)) #define AIC_SMR5 (*((volatile unsigned int *)0xFFFFF014)) #define AIC_SMR6 (*((volatile unsigned int *)0xFFFFF018)) #define AIC_SMR7 (*((volatile unsigned int *)0xFFFFF01C)) #define AIC_SMR8 (*((volatile unsigned int *)0xFFFFF020)) #define AIC_SMR9 (*((volatile unsigned int *)0xFFFFF024)) #define AIC_SMR10 (*((volatile unsigned int *)0xFFFFF028)) #define AIC_SMR11 (*((volatile unsigned int *)0xFFFFF02C)) #define AIC_SMR12 (*((volatile unsigned int *)0xFFFFF030)) #define AIC_SMR13 (*((volatile unsigned int *)0xFFFFF034)) #define AIC_SMR14 (*((volatile unsigned int *)0xFFFFF038)) #define AIC_SMR15 (*((volatile unsigned int *)0xFFFFF03C)) #define AIC_SMR16 (*((volatile unsigned int *)0xFFFFF040)) #define AIC_SMR17 (*((volatile unsigned int *)0xFFFFF044)) #define AIC_SMR18 (*((volatile unsigned int *)0xFFFFF048)) #define AIC_SMR19 (*((volatile unsigned int *)0xFFFFF04C)) #define AIC_SMR20 (*((volatile unsigned int *)0xFFFFF050)) #define AIC_SMR21 (*((volatile unsigned int *)0xFFFFF054)) #define AIC_SMR22 (*((volatile unsigned int *)0xFFFFF058)) #define AIC_SMR23 (*((volatile unsigned int *)0xFFFFF05C)) #define AIC_SMR24 (*((volatile unsigned int *)0xFFFFF060)) #define AIC_SMR25 (*((volatile unsigned int *)0xFFFFF064)) #define AIC_SMR26 (*((volatile unsigned int *)0xFFFFF068)) #define AIC_SMR27 (*((volatile unsigned int *)0xFFFFF06C)) #define AIC_SMR28 (*((volatile unsigned int *)0xFFFFF070)) #define AIC_SMR29 (*((volatile unsigned int *)0xFFFFF074)) #define AIC_SMR30 (*((volatile unsigned int *)0xFFFFF078)) #define AIC_SMR31 (*((volatile unsigned int *)0xFFFFF07C)) #define AIC_SVR0 (*((volatile unsigned int *)0xFFFFF080)) #define AIC_SVR1 (*((volatile unsigned int *)0xFFFFF084)) #define AIC_SVR2 (*((volatile unsigned int *)0xFFFFF088)) #define AIC_SVR3 (*((volatile unsigned int *)0xFFFFF08C)) #define AIC_SVR4 (*((volatile unsigned int *)0xFFFFF090)) #define AIC_SVR5 (*((volatile unsigned int *)0xFFFFF094)) #define AIC_SVR6 (*((volatile unsigned int *)0xFFFFF098)) #define AIC_SVR7 (*((volatile unsigned int *)0xFFFFF09C)) #define AIC_SVR8 (*((volatile unsigned int *)0xFFFFF0A0)) #define AIC_SVR9 (*((volatile unsigned int *)0xFFFFF0A4)) #define AIC_SVR10 (*((volatile unsigned int *)0xFFFFF0A8)) #define AIC_SVR11 (*((volatile unsigned int *)0xFFFFF0AC)) #define AIC_SVR12 (*((volatile unsigned int *)0xFFFFF0B0)) #define AIC_SVR13 (*((volatile unsigned int *)0xFFFFF0B4)) #define AIC_SVR14 (*((volatile unsigned int *)0xFFFFF0B8)) #define AIC_SVR15 (*((volatile unsigned int *)0xFFFFF0BC)) #define AIC_SVR16 (*((volatile unsigned int *)0xFFFFF0C0)) #define AIC_SVR17 (*((volatile unsigned int *)0xFFFFF0C4)) #define AIC_SVR18 (*((volatile unsigned int *)0xFFFFF0C8)) #define AIC_SVR19 (*((volatile unsigned int *)0xFFFFF0CC)) #define AIC_SVR20 (*((volatile unsigned int *)0xFFFFF0D0)) #define AIC_SVR21 (*((volatile unsigned int *)0xFFFFF0D4)) #define AIC_SVR22 (*((volatile unsigned int *)0xFFFFF0D8)) #define AIC_SVR23 (*((volatile unsigned int *)0xFFFFF0DC)) #define AIC_SVR24 (*((volatile unsigned int *)0xFFFFF0E0)) #define AIC_SVR25 (*((volatile unsigned int *)0xFFFFF0E4)) #define AIC_SVR26 (*((volatile unsigned int *)0xFFFFF0E8)) #define AIC_SVR27 (*((volatile unsigned int *)0xFFFFF0EC)) #define AIC_SVR28 (*((volatile unsigned int *)0xFFFFF0F0)) #define AIC_SVR29 (*((volatile unsigned int *)0xFFFFF0F4)) #define AIC_SVR30 (*((volatile unsigned int *)0xFFFFF0F8)) #define AIC_SVR31 (*((volatile unsigned int *)0xFFFFF0FC)) #define AIC_IVR (*((volatile unsigned int *)0xFFFFF100)) #define AIC_FVR (*((volatile unsigned int *)0xFFFFF104)) #define AIC_ISR (*((volatile unsigned int *)0xFFFFF108)) #define AIC_IPR (*((volatile unsigned int *)0xFFFFF10C)) #define AIC_IMR (*((volatile unsigned int *)0xFFFFF110)) #define AIC_CISR (*((volatile unsigned int *)0xFFFFF114)) //<Reserved>=================================================== //<Reserved>=================================================== #define AIC_IECR (*((volatile unsigned int *)0xFFFFF120)) #define AIC_IDCR (*((volatile unsigned int *)0xFFFFF124)) #define AIC_ICCR (*((volatile unsigned int *)0xFFFFF128)) #define AIC_ISCR (*((volatile unsigned int *)0xFFFFF12C)) #define AIC_EOICR (*((volatile unsigned int *)0xFFFFF130)) #define AIC_SPU (*((volatile unsigned int *)0xFFFFF134)) #define AIC_DCR (*((volatile unsigned int *)0xFFFFF138)) //<Reserved>================================================== #define AIC_FFER (*((volatile unsigned int *)0xFFFFF140)) #define AIC_FFDR (*((volatile unsigned int *)0xFFFFF144)) #define AIC_FFSR (*((volatile unsigned int *)0xFFFFF148))
#define PRIOR 0 #define SRCTYPE 5 #endif // __ARM_H__ |
[ LED 헤더 파일 ] |
#ifndef __LED_H__ #define __LED_H__
void Init_LED(void); void LED_toggle(void);
#define LED_Pin 0 // LED Pin Number
#endif // __LED_H__ |
[ LED 함수 파일 ] |
#include "arm.h" #include "led.h"
void Init_LED(void) { PMC_PCER = 1 << PIOA; PIO_OWER = 1 << LED_Pin; PIO_PER = 1 << LED_Pin; PIO_OER = 1 << LED_Pin; PIO_SODR = 1 << LED_Pin; return ; }
void LED_toggle(void) { if(0 != (PIO_ODSR & (1<<LED_Pin))) // LED off 이면... { PIO_CODR = 1 << LED_Pin; } else // LED on 이면... { PIO_SODR = 1 << LED_Pin; } return ; } |
[ AIC 헤더 파일 ] |
#ifndef __AIC_H__ #define __AIC_H__
void Init_AIC(void); void AIC_IRQ_Led(void); #define IRQ_Pin 15 // IRQ Pin Number
#endif //__AIC_H__ |
[ AIC 함수 파일 ] |
#include "arm.h" #include "aic.h" #include "led.h"
void Init_AIC(void) { PMC_PCER = 1 << PIOA; // System Clock Enable PIO_ODR = 1 << IRQ_Pin; // Output Disable PIO_PER = 1 << IRQ_Pin; // PIO Enable PIO_IDR = 1 << IRQ_Pin; // Interrupt Disable AIC_IDCR = 1 << PIOA; // Interrupt Disable Command AIC_SVR2 = (unsigned int)AIC_IRQ_Led; AIC_SMR2 = (1 << SRCTYPE) | (0 <<PRIOR); AIC_ICCR = 1 << PIOA; // AIC Interrupt clear Command PIO_IFER = 1 << IRQ_Pin; // Glitch Filter AIC_ISCR = 1 << PIOA; // AIC Interrupt Set PIO_IER = 1 << IRQ_Pin; // PIO Interrupt Enable AIC_IECR = 1 << PIOA; // AIC Interrupt Enable return ; }
void AIC_IRQ_Led(void) { volatile unsigned int dly; if((1<<IRQ_Pin)==PIO_ISR) { LED_toggle(); } for(dly = 0;300000 > dly; dly++);
PIO_ISR; AIC_EOICR = 0; // End of Interrupt return ; } |
[ main 함수 파일 ] |
#include "arm.h" #include "led.h" #include "aic.h"
//[ 함수 선언부 ]==================== void Init(void); // 함수 호출 함수
int main() {
Init();
while(1); return 0; }
void Init(void) { Init_LED(); Init_AIC(); return ; } |
< 실행
결과
동영상
참고 >
궁금하신
점은
댓글로
남겨주세요 !!
오늘도
좋은
하루
되세요