Hi guys

I have been looking around for a while (almost the whole day) to find an example on how to use the SPI interface on a PIC 16F876 and I couldn't succeed. It works fine with SHIFTOUT but I would liek to try something else :-). This is to drive a MAX7219 display driver.

I am trying to get my PIC sending me data and clock signals via PORT C via the MSSP module in my PIC and no way.

That would be nice if some one could help.

I have been trying the examples given on the Mel web site and these are expecting input on the SPI bus and I couldn't make them running as well.

Here is my basic testing progamme:

' Pic Configuration
' =================
asm
device pic16F876A, hs_osc, wdt_off, lvp_off, protect_off, bod_off
endasm

SSPEN VAR SSPCON.5 'SSP Enable bit
CKP VAR SSPCON.4 'Clock Polarity Select
SSPM3 var SSPCON.3
SSPM2 var SSPCON.2
SSPM1 var SSPCON.1
SSPM0 var SSPCON.0
SMP VAR SSPSTAT.7 'Data input sample phase
CKE VAR SSPSTAT.6 'Clock Edge Select bit
SSPIF VAR PIR1.3 'SPI interrupt flag

TRISC = 0 'set PORTC I/O
'TRISB = 0
ADCON1 = %00000100
TRISA = %00100000
'PORTA = %00100000

SSPEN = 1 'enable SPI pins
CKP = 0 'clock idle low
CKE = 0 'transmit on idle to active transition
SSPIF = 0 'clear buffer full status
SMP = 0 'sample in middle of data

SSPM0 = 1
SSPM1 = 1
SSPM2 = 0
SSPM3 = 0

main:
toggle PORTB.0 ' to see if something is happening
SSPBUF = "A" ' write to SSPBUF to start clock
goto main
end