Hi,
I'm trying to get my 16F877 to
talk to an Analog Devices SSM2160 (6 VCAs with an SPI interface used for audio
level control in Surround systems). The PIC receives data via RS-232 thru it's
USART, does a few calculations and then sets the 2160's VCA levels accordingly
via SPI. Everything seems to be working OK except for SPI. I suspected some
clock mode incompatibility so I wanted to change the CKP and CKE bits but found
that I'm unable to change anything in the SSPSTAT register. SSPCON works ok, and
I think I've got my banks ok to. I joined the source of the I/O Init part of my
program. Any comments are welcome.
Thanks,
Tobie
;******************************************************************************
;
I/O SETUP
;
INIT
bcf
STATUS,RP0
clrf
PORTB
clrf
PORTC
bsf
STATUS,RP0
clrf
TRISB
clrf
TRISC
movlw b'00000000'
; PORTB is all outputs.
movwf TRISB
movlw b'10000000'
; PORTC : set USART Rx bit
movwf TRISC
bcf
STATUS,RP0
bsf
SND ;
Set SPI chip select at idle.
clrf
STATUS
clrf
INTCON
bsf
STATUS,RP0
clrf
PIE1
movlw
b'00100000' ;
Set :Rx interrupt enabled
movwf PIE1
movlw
b'11000000' ;
Set :General IRQ, Peripheral IRQ
movwf INTCON
movlw 64
movwf SPBRG
movlw
b'00000100' ;
Set : BRGH=1
movwf
TXSTA
movlw
b'01000000' ;
Set : CKE (transmit on falling edge of SCK)
movwf
SSPSTAT ;!!!!!!!!!!!!!!!!!!PROBLEM
HERE!!!!!!!!!!!!!!!!!!!!
bcf
STATUS,RP0
movlw
b'10010000' ;
Set :Serial Port enabled, Continuous Rx
movwf RCSTA
clrf
SSPCON
movlw
b'00110010' ;
Set :SSPEN, CKP bits and Fosc/64
movwf SSPCON
bcf
STATUS,RP0
bsf
Power_Led
; Turn on Soft Power Led
etc ...