인터럽트의 종류를 크게 나누자면 크게 4종류로 나뉜다.
External Interrupts
TIMER Interrupts
Analog to Digital Converter Interrupts
Data Interrupts
상세히 정리하면 아래와 같다.
External Interrupts
they are namemd INTx (Like INT0, INT1 etc),
they provide a means for External Hardware
to generate Interrupts.
Like if you connect a touchscreen controller
to your PIC MCU.
Then the touchscreens PENINT (pen interrupt = 팬으로 터치하면 인터럽트)
can be connected to INT0.
Then whenever the pen (or stylus) touches the screen
it will interrupt the CPU.
This interrupt will be explained in details in its own tutorial.
TIMER interrupts
They are also very common in MCUs.
Today’s MCUs comes with very sophisticated timers that can do lots of magic for you.
They have they related interrupts.
In most simple situation
they can act like alarm clocks that can interrupt the CPU at predefined intervals.
If you toggle a i/o pin in response to these alarms (interrupts),
what you have is a frequency generator!
(in response to : ~에 대한 응답으로)
For more info on timers on PIC18, read this article.
Analog to Digital Converter Interrupts –
A/D Converter takes some time to complete its operation.
So the CPU can either wait for it to complete
or
set up an AD conversion complete interrupt.
In the latter case CPU can do other tasks while A/D converter converts the input.
(the latter case : 후자의 경우)
As soon as A/D converter completes its job it will inform CPU to read the value from its buffer. For more info on A/D Converter of PIC18, read this article.
Data Interrupts
MCUs have many different types of data i/o engines,
like USART, SPI, I2C, Parallel etc.
They can also interrupt the CPU
when data transmission is complete or data arrives from external source.
Like an RFID reader send a packet
because a user just brought his or her card near the reader.
Or the GSM module detected an incoming call.
How interrupts are managed?
In general each interrupt source have following related bits.
Enable Bit
The are suffixed with IE (Interrupt Enable) example
TMR0IE stands for TIMER0 Interrupt Enable.
It can be used to enable/disable the related interrupt.
When set to ’1′ it enables the interrupt.
Flag Bit
It is set automatically by the related hardware
when the interrupt condition occurs.
It is generally suffixed with IF (Interrupt Fag).
When it is set to ’1′ we know that interrupt has occurred.
For example when TMR0IF is set by TIMER0,
it indicates that TIMER0 has overflowed.
Priority Bit -
We can leave this for now to keep things simple.
We won’t be using interrupt priority feature of PIC18.
Arduino Interrupt
▼Original Code
▼아직은 Error 있음
▼HEX코드
sketch_apr30a.ino.standard.hex
▲위 그림에서 O표시한 "Connect it to Arduino Input" 그림을 주의깊게 봐야한다.
"To verify the Output"라고 표시된 LED는 VCC,GND 만 연결해놓은 상태에서 PhotoInterrupt의 중간을 차단하면 눈으로 확인하기 위해서 탈부착으로 연결했다.
이때의 출력용 LED를 제거하면, 그 전류가 "Connect it to Arduino Input"핀으로 흘러간다.
(C:Collector, E:Emitor -- Emitor의 전류가 출력용 LED에 흘러간다.)
그리고 여기 O표시한 핀과 아래그림의 O표시한 핀을 Jumper로 연결하면 된다.
위에 표시된 글을 좀더 크게 적었다.
아까 PhotoInterrupter의 출력을 여기 OO로 표한 핀에 연결하면 된다.
두OO사이는 Open되있으므로 따로따로 입력이 들어간다.
두개의 PhotoInterrupt를 사용해서 출입문을 만들면 된다.