How long before the processor starts entering an ISR? That is, 2.9375 µS before entering your interrupt handler, and another 2.1875 µS after it returns. I count 82 cycles there (5.125 µS in total at 16 MHz) as overhead plus whatever is actually done in the supplied interrupt routine. a timer reaching a certain value, or overflowing) and certain other events, such as an incoming I2C message. The processor can also be awoken by a timer interrupt (eg. Pin-change interrupts could be used to wake the processor if a key is pressed on a keypad, or similar. if you press a button on it), or a "watchdog timer" interrupt might wake it up periodically (eg. A rising, falling, or low-level interrupt can be used to wake up a gadget (eg. This can be very handy, as in sleep mode the processor can be configured to use a lot less power (eg. The "data transfers" can be used to let a program do something else while data is being sent or received on the serial port, SPI port, or I2C port.Įxternal interrupts, pin-change interrupts, and the watchdog timer interrupt, can also be used to wake the processor up. Timer interrupts - used for comparing/overflowing timers.if nothing happens after 8 seconds, interrupt me) The main reasons you might use interrupts are: Warning: If you misspell the interrupt vector name, even by just getting the capitalization wrong (an easy thing to do) the interrupt routine will not be called, and you will not get a compiler error. Internal names (which you can use to set up ISR callbacks) are in brackets. In a more complicated example, the main loop might be doing something useful, like taking temperature readings, and allow the interrupt handler to detect a button being pushed.Ģ External Interrupt Request 0 (pin D2) (INT0_vect)ģ External Interrupt Request 1 (pin D3) (INT1_vect)Ĥ Pin Change Interrupt Request 0 (pins D8 to D13) (PCINT0_vect)ĥ Pin Change Interrupt Request 1 (pins A0 to A5) (PCINT1_vect)Ħ Pin Change Interrupt Request 2 (pins D0 to D7) (PCINT2_vect)Ĩ Timer/Counter2 Compare Match A (TIMER2_COMPA_vect)ĩ Timer/Counter2 Compare Match B (TIMER2_COMPB_vect)ġ0 Timer/Counter2 Overflow (TIMER2_OVF_vect)ġ1 Timer/Counter1 Capture Event (TIMER1_CAPT_vect)ġ2 Timer/Counter1 Compare Match A (TIMER1_COMPA_vect)ġ3 Timer/Counter1 Compare Match B (TIMER1_COMPB_vect)ġ4 Timer/Counter1 Overflow (TIMER1_OVF_vect)ġ5 Timer/Counter0 Compare Match A (TIMER0_COMPA_vect)ġ6 Timer/Counter0 Compare Match B (TIMER0_COMPB_vect)ġ7 Timer/Counter0 Overflow (TIMER0_OVF_vect)ġ8 SPI Serial Transfer Complete (SPI_STC_vect)Ģ0 USART, Data Register Empty (USART_UDRE_vect)Ģ5 2-wire Serial Interface (I2C) (TWI_vect)Ģ6 Store Program Memory Ready (SPM_READY_vect) The change in the pin is detected by a CHANGE interrupt, which causes the Interrupt Service Routine (ISR) to be called. The internal pullup (enabled in setup) forces the pin HIGH normally. To test this, just connect a wire (or switch) between D2 and Ground. This example shows how, even though the main loop is doing nothing, you can turn the LED on pin 13 on or off, if the switch on pin D2 is pressed. PinMode (LED, OUTPUT) // so we can update the LEDĭigitalWrite (BUTTON, HIGH) // internal pull-up resistorĪttachInterrupt (digitalPinToInterrupt (BUTTON), switchPressed, CHANGE) // attach interrupt handler
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |