■ SCHEMATIC 5. To supply a variable voltage to the
target PIC, we would jumper pin 1 of J30 with pin 2 of
J14. In this configuration, the V_VAR output voltage is
determined by resistors R19 and R20.

Like most LED code, ours is simple.
Our LED code shifts a bit within the
ledsMask variable and writes the shifted
value of the ledsMask variable out to
the selected I/O port.

Explorer 8 LCD Driver
— Basic SPI

Check out Schematic 6. PBP3

(PICBASIC PRO) has a built-in LCD
driver. We can’t use the PBP3’s automatic
LCD driver here because the Explorer 8’s
LCD is driven by an MCP23S17 SPI I/O
Expander. To add insult to injury, PBP3
doesn’t have any built-in SPI drivers either.

Not to worry. We can simply write our
own PBP3 SPI routines, which we will pitch
to the Explorer 8 LCD driver that we are also
going to craft from scratch. After consulting
the PIC18F47K40 datasheet, I figure we’ll
need to dial up the PIC’s PPS (Peripheral Pin

■ SCHEMATIC 6.

Select) subsystem to realize our SPI
hardware portal. We’ll do the work in the
program initialization routine:

The bit masks associated with I/O pins RC3 and RC5
assign the I/O functions that the pins will perform. We are
only concerned with the first SPI portal here. So, there are
no other PPS assignments we need to perform while the
PPS system is unlocked. The PPS subsystem is locked by
the same byte pattern with the exception of setting bit 0
of the PPSLOCK register following the 0x55-0xAA
sequence. The RC3 and RC5 TRIS values are set
appropriately before leaving the init subroutine.

PBP3 is heavily linked to the Microchip MPASMX
assembler. That’s a good thing as it allows us to use the
PIC18F47K40 datasheet names in our programs. We will
use these definitions in our SPI driver routines:
To use the PIC18F47K40’s PPS subsystem, we must
first unlock it. We do this by writing the byte pattern 0x55-
0xAA to the PPSLOCK register. The unlock sequence is
completed by clearing bit 0 of the PPSLOCK register.