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...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>PICBASIC</strong> <strong>PLUS</strong> CompilerAlso the STATUS, PCLATH, FSR, and Working register must be returnedto their original conditions (context restoring). Again, the CON-TEXT command may be used, but this time with RESTORE after it.i.e. CONTEXT RESTORE.The CONTEXT RESTORE command also returns the PIC back to themain body code where the interrupt was called from.Precautions.Note that the code between the context saving and restoring does notnecessarily need to be in assembler, a small subset of BASIC commandsSHOULD work just as well, but care must be used as to thecommands that are placed within the interrupt handler itself, as mostcommands are non re-entrant. I 2 CBUS, SERIAL, and LCD routinesetc, should be avoided, as they use system variables that may be alreadyin use in the main body code.Also, DELAY commands should be avoided at all costs, as theseplace the PIC into a timed loop, thus, altering any interrupt timing.IF-THEN, REPEAT-UNTIL, and WHILE-WEND comparisons shouldbe safe, along with register or variable altering commands.LOOKUP and LOOKDOWN are permitted, but not LOOKUPL orLOOKDOWNL.Because a hardware interrupt may occur at any time, I cannotfully guarantee that a SYSTEM variable will not be disturbedwhile inside the interrupt handler, therefore, the safest way touse an interrupt is to write the code in assembler. This willguarantee that no system variables are being altered. Alternatively,the assembler code may be viewed in order to ascertain whether anysystem variables are being used. These are: -PP0, PP0H, PP1, PP1H, PP2, PP2H, PP3, PP3H, PP4, PP4H, PP5,PP5H, PP6, PP6H,PP7, PP7H, GEN, GENH, GEN2, GEN2H, GEN3,GEN3H, GPR, BPF.The code within the interrupt handler should be as quick and efficientas possible because, while it’s processing the code the main programis halted.When using assembler interrupts, care should be taken to ensure thatthe watchdog timer does not time-out. Placing a CLRWDT instructionat regular intervals within the code will prevent this from happening.An alternative approach would be to disable the watchdog timer altogetherat programming time.82Copyright Crownhill 2001

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

Saved successfully!

Ooh no, something went wrong!