User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
99
page
mikroBasic compiler was designed with reliability and comfort in mind. Thus, cer-
tain modifications of standard Basic were necessary in order to make the compiler
more PIC MCU compatible.
PIC SFR (Special Function Registers) are implicitly declared as global variables
of byte type. Their scope is the entire project - they are visible in any part of the
program or any unit. Memory management is completely under compiler's control,
so there is no need to worry about PIC memory banks and storing the variables.
Accessing to individual bits of SFR (as accessing to bit of any variable of byte
type) is very simple. Use identifier followed by dot, and a pin:
Identifier.PIN
' PIN is a constant value between 0..7
For example:
sub procedure check
ifPORTB.1 = 1 then
counter = counter + 1
else
INTCON.GIE = 0
end if
end sub
Interrupts can be easily handled in mikroBasic by means of predefined procedure
interrupt. All you need to do is include the complete procedure definition in your
program. mikroBasic saves the following SFR when entering interrupt: PIC12 and
PIC16 series: W, STATUS, FSR, PCLATH; PIC18 series: FSR (fast context is
used to save WREG, STATUS, BSR). Upon return from interrupt routine, these
registers are restored.
NOTE: For PIC18 family, interrupts must be of high priority. mikroBasic does not
support low priority interrupts.
mikroBASIC SPECIFIC