NRF24L01+PIC24F675

NRF24L01+PIC24F675,but cannot send any data

transimitter code is passed:

LIST P=12F675, R=DEC

INCLUDE “p12f675.inc”

#DEFINE ADC GPIO,0

#DEFINE irq GPIO,1

#DEFINE CSN GPIO,2

#DEFINE MOSI GPIO,5

#DEFINE sck GPIO,4

ORG 000H

BSF STATUS,PRO ;---- Select Bank 1 -----

CALL 3FFH ;retrieve factory calibration value

movwf OSCCAL ;update register with factory cal value

CLRF GPIO

CLRF ANSEL

movlw b’00000001’ ;GP0-input, other ouput

MOVWF TRISIO

movlw b’11011000’ ;Pull Ups Disabled, Rising Edge, Assigned to WDT , Prescaler is 1:1 WDT

movwf OPTION_REG

BCF STSTUS,PRO ;---- Select Bank 0 -----

MOVLW 07H

MOVWF CMCON

CALL initnrf ;SET NRf

MAIN

call GetData ; read data

call SendData ; send data

goto main


GetData

movlw b’10101010’

movwf fsr

return


SendData

movlw b’10100111’

movwf tmr1l

movlw b’11111111’

mowf tmr1h

bsf ticon,tmr1on ;enables timer1

;send cmd 00100111 - Write register 7 - STATUS

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

;send data 01111110 - Clear Ints

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bsf gpio,GPIO5 ;RX_DR

call tmr1_overflow

bsf gpio,GPIO5 ;TX_DS

call tmr1_overflow

bsf giro,GPIO5 ;MAX_RT

call tmr1_overflow

bsf giro,GPIO5 ;RX_P_ON

call tmr1_overflow

bsf giro,GPIO5 ;RX_P_ON

call tmr1_overflow

bsf giro,GPIO5 ;RX_P_ON

call tmr1_overflow

bcf giro,GPIO5 ;TX_FULL

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 11100001 - Flush TX

bcf gpio,GPIO2

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

;send data 00111010 - Power up module

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;MASK_RX_DR

call tmr1_overflow

bsf gpio,GPIO5 ;MASK_TX_DS

call tmr1_overflow

bsf giro,GPIO5 ;MASK_MAX_RT

call tmr1_overflow

bsf giro,GPIO5 ;EN_CRC

call tmr1_overflow

b0f giro,GPIO5 ;CRCO

call tmr1_overflow

bsf giro,GPIO5 ;PER_UP

call tmr1_overflow

bcf giro,GPIO5 ;PRIM_RX

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd

BCF GPIO,GPIO2 ;set csn 0

bsf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

btfsc fsr,0 ;send bit 0

bsf gpio,GPIO5

btfss fsr,0

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,1 ;send bit 1

bsf gpio,GPIO5

btfss fsr,1

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,2 ;send bit 2

bsf gpio,GPIO5

btfss fsr,2

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,3 ;send bit 3

bsf gpio,GPIO5

btfss fsr,3

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,4 ;send bit 4

bsf gpio,GPIO5

btfss fsr,4

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,5 ;send bit 5

bsf gpio,GPIO5

btfss fsr,5

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,6 ;send bit 6

bsf gpio,GPIO5

btfss fsr,6

bcf gpio,GPIO5

call tmr1_overflow

btfsc fsr,7 ;send bit 7

bsf gpio,GPIO5

btfss fsr,7

bcf gpio,GPIO5

call tmr1_overflow

BSF GPIO,GPIO2 ;set csn 1

return


initnrf

movlw b’10100111’

movwf tmr1l

movlw b’11111111’

mowf tmr1h

bsf ticon,tmr1on ;enables timer1

;send cmd 00100000 - Write register 0 - CONFIG

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

;send data 00111000 - PTX, CRC enables

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;MASK_RX_DR

call tmr1_overflow

bsf gpio,GPIO5 ;MASK_TX_DS

call tmr1_overflow

bsf giro,GPIO5 ;MASK_MAX_RT

call tmr1_overflow

bsf giro,GPIO5 ;EN_CRC

call tmr1_overflow

bcf giro,GPIO5 ;CRCO

call tmr1_overflow

bcf giro,GPIO5 ;PWR_UP

call tmr1_overflow

bcf giro,GPIO5 ;PRIM_RX

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 00100100 - Write register 4 - SETUP_RETR

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bSf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

;send DATA 00000000 - Wait 250+86ms - Re-transmit disabled

bcf gpio,GPIO5 ;ARD

call tmr1_overflow

bcf gpio,GPIO5 ;ARD

call tmr1_overflow

bCf gpio,GPIO5 ;ARD

call tmr1_overflow

bcf giro,GPIO5 ;ARD

call tmr1_overflow

bcf giro,GPIO5 ;ARC

call tmr1_overflow

bcf giro,GPIO5 ;ARC

call tmr1_overflow

bcf giro,GPIO5 ;ARC

call tmr1_overflow

bcf giro,GPIO5 ;ARC

call tmr1_overflow

bsf gpio,GPIO2

call delay

;Send CMD 00100011 - Write register 3 - SETUP_AW

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

;send data 00000011 - ADRESS Width = 3

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf giro,GPIO5 ;RESERVED

call tmr1_overflow

bcf giro,GPIO5 ;RESERVED

call tmr1_overflow

bcf giro,GPIO5 ;RESERVED

call tmr1_overflow

bsf giro,GPIO5 ;AW

call tmr1_overflow

bsf giro,GPIO5 ;AW

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 00100110 - Write register 6 - RF_SETUP

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

;send data 00000111 - DATA RATE = 1 Mb

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf giro,GPIO5 ;PLL_LOCK

call tmr1_overflow

bcf giro,GPIO5 ;RF_DR

call tmr1_overflow

bsf giro,GPIO5 ;RF_PWR

call tmr1_overflow

bsf giro,GPIO5 ;RF_PWR

call tmr1_overflow

bsf giro,GPIO5 ;LNA_HCURR

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 00100101 - Write register 5 - RF_CH

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

;send data 00000010 - Set Channel 2

bcf gpio,GPIO5 ;RESERVED

call tmr1_overflow

bcf gpio,GPIO5 ;RF_CN

call tmr1_overflow

bcf gpio,GPIO5 ;RF_CN

call tmr1_overflow

bcf giro,GPIO5 ;RF_CN

call tmr1_overflow

bcf giro,GPIO5 ;RF_CN

call tmr1_overflow

bCf giro,GPIO5 ;RF_CN

call tmr1_overflow

bSf giro,GPIO5 ;RF_CN

call tmr1_overflow

bCf giro,GPIO5 ;RF_CN

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 00110000 - Write register 10 - TX_ADDR

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

;send data 11100111 - Set Address E7E7E7E7E7

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bSf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf gpio,GPIO2

call delay

;send cmd 00100001 - Write register 1 - EN_AA

bcf gpio,GPIO2

bcf gpio,GPIO5

call tmr1_overflow

bcf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

;send data 00000000 - Disable AUTOACK

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bsf gpio,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bcf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bSf giro,GPIO5

call tmr1_overflow

bsf giro,GPIO5

call tmr1_overflow

bsf gpio,GPIO2

bcf ticon,tmr1on ;disables timer1


tmr1_overflow

btfss pir1,tmr1if

goto tmr1_overflow

bcf pir1,tmr1if

movlw b’10100101’

movwf tmr1l

movlw b’11111111’

movwf tmr1h

return


delay

movlw n1

movwf data1

lp0 movlw n2

movwf data2

lp1 decfsz data2,1

goto lp1

decfsz data1,1

goto lp0

return

What the heck is a “PIC24F675”???

There’s no way that this code could be successfully assembling at all - for example, you’ve got “BCF STSTUS,PRO” instead of “BCF STATUS,RP0”, and a couple of undeclared variables in your delay routine.

He means PIC12F675, which he has at the beginning of the code. The listing is completely incomprehensible, anyway.

Leon