'SPI Output
'This program requires a 74HC595 (serial to parallel shift register with
'output latch). The 74HC595 serial in and serial clock is connected to the
'SPI port and the latch clock is connected to RA4 of the SV200B/C. The
'program shifts out an alternating bit patteren and latches the value to the
'output of the 74HC595.

DIM bTRISA4 as Bit 4 of TRISA 'Port direction register
DIM bSPIlatch as BIT 4 of RA  '

bTRISA4 = 0    'Set RA.4 as output
bSPIlatch = 1  'Set latch clock high
Main:
  SPIreg = 01010101b  'Set value to be shifted
  call SPIout         'Shift out the data
  bSPIlatch = 0       'pulse latch clock
  bSPIlatch = 1
  delay 1000          'Pause one second

  SPIreg = 10101010b  'Alternate the bit pattern
  call SPIout         'Shift out the data
  bSPIlatch = 0       'pulse latch clock
  bSPIlatch = 1
  delay 1000          'Pause one second
Goto Main

