hi everybody
i still face problems with the receiver… :?
i have changed the clock to 4Mhz…
i’m posting the assembly code of the receiver module…
please give me sugestions… or the modifications required…
swapnil
LIST P=16F73
#INCLUDE <P16F73.INC>
__CONFIG _BODEN_OFF & _CP_OFF & _PWRTE_OFF & _WDT_OFF & _XT_OSC
#DEFINE CE PORTC,7 ; OUTPUT ONLY
#DEFINE CS PORTC,6 ; OUTPUT ONLY
#DEFINE DR1 PORTC,2 ; INPUT ONLY
#DEFINE LED1 PORTB,7 ; OUTPUT ONLY
#DEFINE LED2 PORTB,6 ; OUTPUT ONLY
#DEFINE KEY1 PORTB,3 ; INPUT ONLY
#DEFINE KEY2 PORTB,2 ; INPUT ONLY
ORG 0X0000
;*****************************************************************************************
; MEMORY CONFIGRATION
;**************************************************
; 15 BYTES OF CONFIGRATION WORD
; CONFIGRARION BITS OF MODULE SEND COUNTER ( 0F COUNTS )
CBLOCK 0X20
CON_ARR: 0X0F ; CONFIG ARRAY
CON_COUNT ; CONFIG COUNTER
DEL3MS1REG ; DELAY REG
DEL3MS2REG ; DELAY REG
SENDREG ; REG TO SEND DATA
READREG ; REG TO READ DATA
ENDC
GOTO START
;**************************************************
; PORT CONFIGRATION
;**************************************************
START
NOP
; PORT B RB7 & 6 LEDS, RB2 & 1 INPUT KEYS, REST OUTPUTS
BANKSEL TRISB
MOVLW 0X06 ; B 0 0 0 0 0 1 1 0
MOVWF TRISB
; PORT C INPUT ( SPI & CONTROL SIGNALS OF TRW-24G )
MOVLW 0X14 ; B 0 0 0 1 0 1 0 0
MOVWF TRISC
; CONFIGURE SPI
MOVLW 0X40 ; SMP = 0 SAMPLE AT MIDDLE..
MOVWF SSPSTAT ; CKE = 1 DATA TRANSMISSION ON RISING EDGE
; ENABLE SPI
BANKSEL SSPCON
MOVLW 0X21 ; SSPEN=1 SSP ENABLE, CKP=0 IDLE STATE CLK IS 0
MOVWF SSPCON ; SPI MASTER FOC/16
;**************************************************
; TRW-2.4G MODULE CONFIGRATION
;**************************************************
; INITIALISE FSR
CALL DELAY3MS ; WAIT FOR RF MODULE TO START
MOVLW 0X20
MOVWF FSR
; LOAD 15 BYTES OF CONFIGRATION DATA NO TEST BITS WRITTEN
MOVLW 0X00 ; DATA2_W 8 BIT DATA ON CHANNEL 2
MOVWF INDF
INCF FSR,1
MOVLW 0X08 ; DATA1_W 8 BIT DATA ON CHANNEL 1
MOVWF INDF
INCF FSR,1
MOVLW 0X00 ; 5 BYTES OF ADDRESS ON R2
MOVWF INDF
INCF FSR,1
MOVLW 0X00
MOVWF INDF
INCF FSR,1
MOVLW 0X00
MOVWF INDF
INCF FSR,1
MOVLW 0X00
MOVWF INDF
INCF FSR,1
MOVLW 0X00 ; 40 BYTE ADDR
MOVWF INDF
INCF FSR,1
MOVLW 0X11 ; 5 BYTES OF ADDRESS ON R1
MOVWF INDF
INCF FSR,1
MOVLW 0X33
MOVWF INDF
INCF FSR,1
MOVLW 0X55
MOVWF INDF
INCF FSR,1
MOVLW 0X99
MOVWF INDF
INCF FSR,1
MOVLW 0XAA ; 40 BYTE ADDR
MOVWF INDF
INCF FSR,1
MOVLW 0XC3 ; ADDR_W & CRC
MOVWF INDF ; 8 BIT ADDRESS, 8 BIT CRC, CRC ENABLED
INCF FSR,1
; GENERAL CONFIGRATION
MOVLW 0X4F ; SINGLE RX CHANNEL
MOVWF INDF ; SHOCK BURST MODE
INCF FSR,1 ; 250 KBPS
; 16MHZ CLOCK
; 0 dB GAIN
; RF CHANNEL AND DIRECTION
MOVLW 0X05 ; RECEIVER
MOVWF INDF
;********************************************************
; SEND CONFIGRATION WORD
;********************************************************
MOVLW 0X0F ; 15 DEC = 0F HEX
MOVWF CON_COUNT ; LOAD COUNTER FOR 18 BYTES TRANSFER
MOVLW 0X20 ; REINITIALISE FSR
MOVWF FSR
BSF CS ; TO ENABLE WRITE TOTWR-2.4G CONFIGRATION
CALL DELAY5US
LOOPCONF
MOVF INDF,W
MOVWF SENDREG
CALL SENDDATA
INCF FSR,1
DECFSZ CON_COUNT,1
GOTO LOOPCONF
; END OF LOOP1
BCF CS ; ACTIVATE CONGIGRATION OF TWR-2.4G
CALL DELAY5US
GOTO MAIN
;*******************************************************************
; SEND BYTE
;*******************************************************************
SENDDATA
MOVF SENDREG,W
MOVWF SSPBUF
BANKSEL SSPSTAT
CHAR0
BTFSS SSPSTAT,BF ; WAIT TILL END OF TRANSMISSION
GOTO CHAR0
;LOOP CHAR0
BANKSEL SSPBUF
MOVF SSPBUF,W ; AT END OF TRANSMISSION THROW
; AWAY DUMMY RECEIVED DATA.
RETURN
;*******************************************************************
; READ BYTE
;*******************************************************************
READDATA
MOVLW 0X00 ; DUMMY DATA TRANSMITTED
MOVWF SSPBUF
BANKSEL SSPSTAT
CHAR1
BTFSS SSPSTAT,BF ; WAIT TILL END OF TRANSMISSION
GOTO CHAR1
;LOOP CHAR0
BANKSEL SSPBUF
MOVF SSPBUF,W ; AT END OF TRANSMISSION THROW
MOVWF READREG ; STORE RECEIVED DATA.
RETURN
;********************************************************************
; 1uS DELAY FOR EACH INST.. AT 4MhZ
;*******************************************************************
; 5uS DELAY
;*******************************************************************
DELAY5US
NOP
; CALL = 2 uS, NOP = 1 uS, RETURN = 2 uS
; 1 + 2 + 2 = 5 us
RETURN
;********************************************************************
; 3mS DELAY
;*********************************************************************
DELAY3MS
MOVLW 0X03
MOVWF DEL3MS1REG ; 1ms X 3 = 3ms
LOOP3MSOUT
MOVLW 0XFA
MOVWF DEL3MS2REG ; 4us X 250 = 1ms
LOOP3MSIN ; T
; |
NOP ; \|/
DECFSZ DEL3MS2REG,1 ; V
GOTO LOOP3MSIN ; 4 us DELAY
; INNER LOOP
DECFSZ DEL3MS1REG,1
GOTO LOOP3MSOUT
; OUTER LOOP
RETURN
;*******************************************************************
MAIN
BANKSEL PORTB
BCF LED1 ; POWER ON
BSF CE ; START LOADING 8 BIT ADDRESS
; & 8 BIT DATA
CALL DELAY5US
READTEST
BTFSS DR1
GOTO READTEST
CALL READDATA
MOVLW 0X66
SUBWF READREG,W
BTFSC STATUS,Z
GOTO READTEST
MOVLW 0X40
XORWF PORTB,F
NOP
NOP
GOTO READTEST
;********************************************************************
END
please post the corrections…
i was able to receive junk data with 8 bit adderss and 8 bit crc… but nothing is received with 40 bit address and 16bit crc.
swapnil