MikroElektronika PIC Microcontrollers PIC16 Datový list Strana 156

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 194
  • Tabulka s obsahem
  • ŘEŠENÍ PROBLÉMŮ
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 155
Programming PIC Microcontrollers in BASIC - mikroElektronika
Here is a simple example:
In the main loop, program keeps LED_run diode on and LED_int diode off. Pressing the button T causes the interrupt –
microcontroller stops executing the main program and starts the interrupt procedure.
program testinterrupt
symbol LED_run = PORTB.7 ' LED_run is connected to PORTB pin
7
symbol LED_int = PORTB.6 ' LED_int is connected to PORTB pin
6
sub procedure interrupt ' Interrupt service routine
if INTCON.RBIF = 1 then ' Changes on RB4-RB7 ?
INTCON.RBIF = 0
else if INTCON.INTF = 1 then ' External interupt (RB0 pin) ?
LED_run = 0
LED_int = 1
Delay_ms(500)
INTCON.INTF = 0
else if INTCON.T0IF = 1 then ' TMR0 interrupt occurred ?
INTCON.T0IF = 0
else if INTCON.EEIF = 1 then ' Is EEPROM write cycle finished ?
INTCON.EEIF = 0
end if
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/06.htm (2 sur 12)05/11/2004 02:26:24
Zobrazit stránku 155
1 2 ... 151 152 153 154 155 156 157 158 159 160 161 ... 193 194

Komentáře k této Příručce

Žádné komentáře