Pin may be a constant, 0 - 15, or a variable that contains a number 0 - 15 (e.g. To turn off interrupts permanently (or until needed again) once ON INTERRUPT has been used, set INTCON to $80: Myint: led = 1 ' Turn on LED when interrupted INTCON = %10010000 ' Enable RB0 interrupt ON INTERRUPT GOTO myint ' Interrupt handler is myint More than one ON INTERRUPT may be used in a program. Usually the additional instruction will not be much of a problem, but long programs in small microcontrollers could suffer. DISABLE turns off the addition of this instruction. ON INTERRUPT will add an instruction after every statement to check whether or not an interrupt has occurred. If it is unacceptable and the interrupts must be handled more quickly, an assembly language interrupt routine must be used. The program must be designed with this latency in mind. If the statement is a PAUSE or SERIN, it could be quite a while before the interrupt is acknowledged. PBP will not enter the BASIC interrupt handler until it has finished executing the current statement. Statement while one is being executed), there can be considerable latency before the interrupt routine is entered. PICBASIC PRO™ statements are not re-entrant (i.e. Latency is the time it takes from the time of the actual interrupt to the time the interrupt handler is entered. Or the interrupt handler may be placed before the ON INTERRUPT statement as the interrupt flag is not checked before the first ON INTERRUPT in a program. The most notable place to use DISABLE is right before the actual interrupt handler. PICBASIC PRO™ program to execute without the possibility of being interrupted. Once the interrupt handler is complete, a RESUME statement sends the program back to where it was when the interrupt occurred, picking up where it left off.ĭISABLE and ENABLE allow different sections of a Statement = s execution is complete, the program jumps to the BASIC interrupt handler at Label. PICBASIC PRO™ subroutine but ends with a RESUME. The second method is to write a PICBASIC PRO™ interrupt handler. This method is discussed under advanced topics in a later section. This is the way to handle interrupts with the shortest latency and lowest overhead. The first is to write an assembly language interrupt routine. There are 2 ways to handle interrupts using the PICBASIC PRO™ Compiler. ON INTERRUPT allows the handling of microcontroller interrupts by a This variable should be set to 0 at the beginning of the program.Īdding this variable to a program does add overhead in that the value of the variable must be incremented and decremented at each GOSUB and RETURN. The supplied variable will be incremented at each GOSUB and decremented at each RETURN. MCUs, 12 for 17Cxxx devices or 27 for 18Cxxx devices in a PICBASIC PRO™ program. This level should never be greater than 4 for 12- and 14-bit core PICmicro A small monitor program example is posted on our web site.Ī word-sized system variable that resides in BANK0 is required to provide place to store the address the program was at before the monitor routine was called by ON DEBUG GOTO :Īn Additional byte-sized variable may be used to return the level of the current program stack: Any program information may be displayed or even altered in this manner.
Picbasic pro 3 lcd problems serial#
This routine can send data to an LCD or to a serial comm program. DISABLE DEBUG prevents the insertion of this call while ENABLE DEBUG resumes the insertion of the call.Ī monitor routine may be written that is activated before each instruction. PICBASIC PRO™ instruction in the program. Once ON DEBUG GOTO is encountered, a call to the specified debug label is inserted before each The method by which this happens is similar to the method used by ON INTERRUPT GOTO. ON DEBUG allows a debug monitor program to be executed between each NAP 7 ' Low power pause for about 2.3 seconds Since NAP uses the Watchdog Timer, its timing is independent of the oscillator frequency. The listed periods are only approximate because the timing is derived from the Watchdog Timer which is R/C driven and can vary greatly from chip to chip and over temperature. During this NAP, power consumption is reduced to minimum. Places the microcontroller into low power mode for short periods of time.