The jpic library interfaces to the basic 16x84 and SX hardware:
Shadows of the tris and port values are maintained to avoid page switching and read-modify-write problems when individual pin values are modified. This induces a small code and file register overhead.
The portc and associated declarations are implemented only in the SX28. The eeprom is implemented only in the 16x84.
The following special function registers are declared:
var volatile byte indf at 0
var volatile byte tmr0 at 1
var volatile byte pcl at 2
var volatile byte status at 3
var volatile byte fsr at 4
var volatile byte porta at 5
var volatile byte portb at 6
var volatile byte portc at 6
var volatile byte eedata at 8
var volatile byte eeadr at 9
var volatile byte pclath at 10
var volatile byte intcon at 11
var volatile byte option
var volatile byte trisa
var volatile byte trisb
var volatile byte trisc
The option variable is a pseudo-variable maintained by small routines. The porta .. portc and trisa ... trisc variables are explained in the next section.
The following bits are declared within the special function registers:
var volatile bit status_c at status : 0
var volatile bit status_dc at status : 1
var volatile bit status_z at status : 2
var volatile bit status_pd at status : 3
var volatile bit status_to at status : 4
var volatile bit status_rp0 at status : 5
var volatile bit status_rp1 at status : 6
var volatile bit status_irp at status : 7
var volatile bit intcon_rbif at intcon : 0
var volatile bit intcon_intf at intcon : 1
var volatile bit intcon_t0if at intcon : 2
var volatile bit intcon_rbie at intcon : 3
var volatile bit intcon_inte at intcon : 4
var volatile bit intcon_t0ie at intcon : 5
var volatile bit intcon_eeie at intcon : 6
var volatile bit intcon_gie at intcon : 7
At startup all pins are inputs.
The following constants should be used to change directions:
For the half-port (nibble) variables the direction is according to the lower 4 bits. The higher 4 bits are ignored and read as 0.
The following pseudo-variables are provided which can be used either to the right or to the left of an assignment statement:
For the half-port (nibble) variables the value is according to the lower 4 bits. The higher 4 bits are ignored and read as 0.
The following routines are provided to get and put data at a specified file register:
procedure file_get( byte in a, byte out d )
procedure file_put( byte in a, byte in d )
The address passed to the file_get and file_put routines must be a linear address. The linear file register addresses are consequtive and non-overlapping.
The following routines are provided to get and put data at a specified data eeprom address:
procedure eeprom_get( byte in a, byte out d )
procedure eeprom_put( byte in a, byte in d )
The eeprom_put routine waits (busy looping) for the write to complete.
The sleep procedure is equivalent to an asm sleep statement.
procedure sleep
The clear watchdog procedure is equivalent to an asm clrwdt statement.
procedure clear_watchdog
The sleep procedure is equivalent to an asm swapf x,f statement.
procedure swap_nibbles( byte in out x )
These procedures are equivalent to option_rp0 = false
and option_rp0 = true.
procedure page_0
procedure page_1