11.07.2015 Views

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

PICBASIC PLUS LITE Manual - Profe Saul

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerThis flag is only of any importance when determining what caused theinterrupt. However, it is not cleared by hardware and should becleared before the SLEEP command is used (or the interrupt handleris exited).The program below will wake the PIC when a change occurs onPortB, bits 4-7.DECLARE XTAL 4' Set Xtal FrequencySYMBOL LED = PORTB.0 ' Assign the LED's pinSYMBOL RBIF = INTCON.0 ' PORTB[4..7] Change Interrupt FlagSYMBOL RBIE = INTCON.3 ' PORTB[4..7] Change Interrupt EnableSYMBOL RBPU = OPTION_REG.7 'PortB pull-upsSYMBOL GIE = INTCON.7 ' Global interrupt enable/disable' ** THE MAIN PROGRAM STARTS HERE **Main: GIE = 0 ' Turn OFF global interruptsWHILE GIE = 1 : GIE = 0 : WEND ' And make sure they are offTRISB.4 = 1' Set PortB.4 as an InputRBPU = 0' Enable PortB Pull-up ResistorsRBIE = 1' Enable PortB[4..7] interruptAgain: DELAYMS 100LOW LEDRBIF = 0SLEEPDELAYMS 100HIGH LEDGOTO Again' Turn off the LED' Clear the PORTB[4..7] interrupt flag' Put the PIC to sleep' When it wakes up, delay for 100ms' Then light the LED' Do it foreverSee also :SNOOZE127Copyright Crownhill 2001

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!