If you want to use the MSSP, (Master Synchronous Serial Port) to receive data simultaneously while sending, then you should let the MSSP do them both.
It'll be a lot simpler.
This example might help, but it doesn't take the CC2500 into account, since I've never seen one ...
Code:
SDI VAR PORTC.4 ; Data IN Pin for 18F2420
SDO VAR PORTC.5 ; Data OUT
SCK VAR PORTC.3 ; Clock
BF VAR SSPSTAT.0 ; Buffer Full Flag
CKE VAR SSPSTAT.6 ; SPI Clock Select bit
TXbyte VAR BYTE ; Byte to Send
RXbyte VAR BYTE ; Received Byte
SSP_Init:
LOW SCK ; Start with clock and data out (OUTPUT LOW)
LOW SDO
INPUT SDI ; Input is already Default, but just in case
CKE = 1 ; Transmit occurs on transition from
; active to Idle clock state
SSPCON1 = %00100010 ; Enable MSSP, SPI Master, CLK idles low, FOSC/64 clk
;_____________________________________________________________________________
Main:
TXbyte = $69
GOSUB SendReceive
; at this point, RXbyte will hold the byte that was shifted in at
; the same time TXbyte was shifted out
PAUSE 1000
GOTO Main
SendReceive:
SSPBUF = TXbyte
REPEAT : UNTIL (BF = 1) ; wait for MSSP to finish shifting
RXbyte = SSPBUF
RETURN
HTH,
Bookmarks