THE NRF24L01+ PICBASIC & PIC MICRO-CONTROLLERS

THE NRF24L01+ PICBASIC & PIC MICRO-CONTROLLERS

USING THE NRF24L01+ WITH A PIC MICRO-CONTROLLER

By: Don McClatchie

            The NRF24L01+ is a short-range RF transceiver that operates in the 2.4GHz band with a channel bandwidth of 1 or 2 MHz.  They have a practical range of about 300 feet and some with models with an added LNA can communicate over several thousand feet (Line of sight). These low-cost modules can be purchased from many sources on the internet for just a few dollars. They are frequency agile and many aspects of the transmitter and receiver operations are programmable. They are designed to be interfaced with a micro-controller and many different designs are available online. However, my search for an NRF24L01 design using a PIC micro-controller and PICBASIC software was less than fruitful. So, I set about to make one work using a PIC16F690 micro-controller and for beginners I programmed in PICBASIC. The NRF24L01 module can use what is called Enhanced Shockburst™ on individual Rx pipes so for this application the micro-controller you choose must have a built in EUSART function, I choose the PIC16F690 for my project.

            The following project transmits an 8bit byte of information using Enhanced Shockburst™ from one NRF24L01 to another, the software is listed below. The program continuously loops to send the data from transmitter to receiver. You can program the unit to use other RF channels and up to five different data pipes. This software sends the same information on all 5 data pipes. It is just a sample of what can be done using these RF transceivers.    

            For more control see NORDIC SEMICONDUCTOR website and look up the REGISTER MAP for this IC. ™.

****************************************************************

*  Name    : NFR24L01T.BAS                                                                             *

*  Author  : Don McClatchie                                                                                *

*  Notice  : Copyright (c) 2020                                                                             *

*               : All Rights Reserved                                                                           *

*  Date    : 5/13/2020                                                                                             *

*  Version : 1.0                                                                                                      *

*  Notes   : Send an 8Bit Byte to an NRF24L01 Transceiver                               *

*          :     Transmitter                                                                                          *

****************************************************************

                                                                                                        ; PBP -p16f690

_HS_OSC               ; HS Oscillator INTOSCIO

_WDT_ON               ; Watchdog Timer ON

_PWRT_ON              ; Power Up Timer ON

_MCLR_OFF             ; INPUT PIN

_BOD_ON               ; Brown Out Reset ON

_CP_ON_ALL            ; Code Protect ON

_PROTECT_ON           ; Code Protect ON

include “modedefs.bas”              ; I/O Setup

    TRISA  = %00111111              ; Set All as Input

    TRISB  = %00010000              ; Set All Output Except Pin 13

    TRISC  = %01001111              ; Set All Output Except Pin 7,14,15,16,

    ANSEL  = %00001111              ; All Digital Except AN0,2,3,4

    ANSELH = %00000000              ; All Digital (00000000)

                                                       ; Defines

define OSC 4                                  ; Set oscillator for 4 MHz 

DEFINE HSER_RCSTA 90H               ; Enable Serial Port & Continuous Receive

DEFINE HSER_TXSTA 24H               ; Enable USART Transmit, BRGH = 1

DEFINE HSER_BAUD 19200              ; USART BAUD Rate 19,200 TX/RX

HSEROUT [$80]                                   ; USART Setting 128

define ADC_BITS 10                           ; Setup ADC read for 10 Bits .00488V 1024

DEFINE ADC_SAMPLEUS 50

                                                          ; REGISTERS

  OSCCON   = %01100011              ; 4MhZ,EXTFOSC2.0,HFINTNOT,LFINTYES,FOSC.2.0

  ADCON0   = %10000001              ; Right Justify RA0 PIN 19 AN3

  ADCON1   = %01010000              ; FOSC/16

    WPUA   = %00000010                ; Weak Pull Ups on Port A Pin 18

    WPUB   = %00000000                ; Weak Pull Ups none

OPTION_REG = %00000000              ; Weak Pull Ups Global On 

  TX_CE   VAR PORTC.5               ; OUTPUT P-5 Chip Enable 0 = OFF 1 = ON

  TX_CSN  VAR PORTC.4               ; OUTPUT P-6 SPI Enable 0 = ON 1 = OFF

  TX_SCK  VAR PORTB.6               ; OUTPUT P-11 SPI CLOCK

  TX_MOSI VAR PORTC.7               ; OUTPUT P-9 Data Input

  TX_MISO VAR PORTB.4               ; INPUT P-13 Data Output

  TX_IRQ  VAR PORTC.3               ; INPUT P-7 IRQ Interrupt

                                                         ; VARIABLES

        I VAR BYTE                           ; Variable I

        J VAR BYTE                           ; Variable J

    DATA1 VAR BYTE                  ; Variable DATA1

      CMD VAR BYTE                     ; Variable CMD for Commands Sent to Radio

      LED VAR BYTE                      ; Variable for LEDs and Data for Transmitter

   FREQSW var BYTE                     ; Variable for Analog Read of 8 Pos Switch                    

   RFCHAN var byte                       ; Variable for RF CHANNEL

  SWDATA  Var BYTE                  ; Variable for Switch DATA 8 Bytes

  SWA     var word                        ; Variable for Switch A Analog Data

  SWB     var word                        ; Variable for Switch B Analog Data

  SWC     var word                        ; Variable for Switch C Analog Data

  SWD     var word                        ; Variable for Swtich D Analog Data

                                                    ; PRESETS   

    PORTA = %00000000               ; Zero Port A

    PORTB = %00100000               ; Zero Port B

    PORTC = %00001000               ; Zero Port C

PAUSE 1000                          ; Pause For Radio Start Up

PAUSE 1000                          ; Pause For Radio Start Up

CLEAR

SWDATA = 128                        ; This is the data to be sent (0-255) 1byte

RFCHAN = 5                          ; Pre-load RF Channel 5 (0-125)

GOSUB CONFIGURE_TRANSMITTER         ; Go Configure the Transmitter

MAINLOOP:                                          ;  Main Loop Transmitter

GOSUB TRANSMIT_DATA                 ; Jumper off Send Non-Inverted Data

GOTO MAINLOOP                               ; Do it again

                                                          ; This sends out data

TRANSMIT_DATA:                      ; Transmit Data Subroutine

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1  = $7E                        ; CLEAR PREVIOUS INTERUPTS $7E 01111010 W

  CMD  = $27                        ; Load STATUS REGISTER with %001 00111

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

                                             ; PWR_UP = 1 

DATA1 = $3A                         ; CONFIG REG DATA %00111010

CMD = $20                           ; CONFIG REGISTER W CMD %001 00000

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

CMD = $E1                           ; EN_AA REGISTER CLEAR TX FIFO %111 00001

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = SWDATA                      ; Load PAYLOAD %00110100 BYTE 1 (SWDATA)

CMD = $A0                           ; Load CMD with %101 00000

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

DATA1 = SWDATA                      ; Load DATA1 %00111111 MORE DATA! BYTE 2

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

DATA1 = SWDATA                      ; Load DATA1 %00111111 MORE DATA! BYTE 3

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

DATA1 = SWDATA                      ; Load DATA1 %00111111 MORE DATA! BYTE 4

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CE = 1                           ; PULSE CE TO START TRANSMISSION Radio On

PAUSE 10                            ; Pause

TX_CE = 0                           ; Clear TX_CE Chip Enable In Standby

RETURN                              ; Return

CONFIGURE_TRANSMITTER:              ; SETS UP RF-24G FOR SHOCKBURST TRANSMISSION

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CE  = 0                          ; SPI Chip Select Clear Pin 15 In Standby

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $38                         ; PTX, CRC ENABLE, MASK INTS 00111000 TX OFF

CMD = $20                           ; Load CMD with %001 00000

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $00                         ; CONFIG REGISTER AUTO RETRANSMIT OFF

CMD = $24                           ; Load CMD with %001 00100

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $03                         ; SETUP_AW REGISTER ADDRESS WID 5 %00000011

CMD = $23                           ; SETUP_AW REGISTER Load CMD with %001 00011

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $07                         ; RF_SETUP RATE 1MB, PWR 0dBM %00000111

CMD = $26                           ; RF_SETUP REGISTER Load CMD with %001 00110

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = RFCHAN                      ; RF_CH DATA CH 00000010 RF Channel SELECT

CMD = $25                           ; RF_CH RF CHANNEL CMD %001 00101

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $E7                         ; SET ADDRESS E7, ALSO DEFAULT 11100111

CMD = $30                           ; TX_ADDR TRANSMIT ADDRESS Load %001 10000

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

FOR J = 1 TO 5                      ; For J Loop 5 Times

FOR I = 1 TO 8                      ; For I Loop 8 Times DO I LOOP FIRST THEN J

TX_MOSI = DATA1.7                   ; Load Bit 7 of DATA1 into TX_MOSI

TX_SCK = 1                          ; SPI Clock Set

TX_SCK = 0                          ; SPI Clock Clear

DATA1 = DATA1<<1                    ; Shift DATA1 data Left 1 bit

NEXT I                              ; Do it Again

DATA1 = $E7                         ; ReLoad DATA1 with %11100111 FOR 5 LOOP

NEXT J                              ; Do it Again

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

TX_CSN = 0                          ; SPI Chip Select Clear Pin 15 SPI ON

DATA1 = $00                         ; EN_AA DATA DISABLE AUTO ACK 00000000

CMD = $21                           ; EN_AA REGISTER LOAD %001 00001

GOSUB TXMOSICMD                     ; Shift out TXMOSICMD 8 Times

GOSUB TXMOSIDATA1                   ; Shift out TXMOSIDATA1 8 Times

TX_CSN = 1                          ; SPI Chip Select Set Pin 15 SPI OFF

RETURN                              ; Return

                                                     ; Channel Change Subroutine

                                                          ; SUBROUTINE                                    

TXMOSICMD:                          ; Shift Out MOSICMD Subroutine

FOR I = 1 TO 8                      ; For I Loop 8 Times

TX_MOSI = CMD.7                     ; Load TX_MOSI with CMD bit 7

TX_SCK = 1                          ; SPI Clock Set

TX_SCK = 0                          ; SPI Clock Clear

CMD = CMD<<1                        ; Shift CMD data Left 1 bit

NEXT I                              ; Do it Again

RETURN                              ; Return

TXMOSIDATA1:                        ; Shift Out TXMOSIDATA1 Subroutine

FOR I = 1 TO 8                      ; For I Loop 8 Times

TX_MOSI = DATA1.7                   ; Load Bit 7 of DATA1 into TX_MOSI

TX_SCK = 1                          ; SPI Clock Set

TX_SCK = 0                          ; SPI Clock Clear

DATA1 = DATA1<<1                    ; Shift DATA1 data Left 1 bit

NEXT I                              ; Do it Again

RETURN                              ; Return

END                                 ; End

****************************************************************

*  Name    : NRF24L01R.BAS                                                                             *

*  Author  : Don McClatchie                                                                                *

*  Notice  : Copyright (c) 2020                                                                             *

*          : All Rights Reserved                                                                                *

*  Date    : 5/13/2020                                                                                             *

*  Version : 1.0                                                                                                      *

*  Notes   : Receiver for NRF24l01                                                                       *

*  Receiver Data is found in DATA1 Variable                                                                                                   *

****************************************************************

                                                                                                       ; PBP -p16f690

_HS_OSC               ; HS Oscillator INTOSCIO

_WDT_ON               ; Watchdog Timer ON

_PWRT_ON              ; Power Up Timer ON

_MCLR_OFF             ; INPUT PIN

_BOD_ON               ; Brown Out Reset ON

_CP_ON_ALL            ; Code Protect ON

_PROTECT_ON           ; Code Protect ON

include “modedefs.bas”              ; I/O Setup

    TRISA  = %00001000              ; Set All as Output Except RA3 Pin 4

    TRISB  = %00010000              ; Set All Output Except RB4 Pin 13

    TRISC  = %00001000              ; Set All Output Except RC3 Pin 7

    ANSEL  = %00000000              ; All Digital (00000000)

    ANSELH = %00000000              ; All Digital (00000000)

                                                      ; Defines

define OSC 4                        ; set oscillator for 4 MHz 

DEFINE HSER_RCSTA 90H               ; Enable Serial Port & Continuous Receive

DEFINE HSER_TXSTA 24H               ; Enable Transmit, BRGH = 1 USART

DEFINE HSER_BAUD 19200              ; USART BAUD Rate 19,200

HSEROUT [$80]                                  ; USART Setting 128

                                                            ; REGISTERS

  OSCCON   = %01100011              ; 4MhZ,EXTFOSC2.0,HFINTNOT,LFINTYES,FOSC.2.0 

  RX_CE   VAR PORTC.5               ; CE OUT Pin 16 In Standby = 0 On = 1

  RX_CSN  VAR PORTC.4               ; CSN OUT Pin 15 SPI ON = 0 SPI OFF = 1

  RX_SCK  VAR PORTB.6               ; SCK OUT Pin 11 SPI CLOCK

  RX_MOSI VAR PORTC.7               ; MOSI OUT Pin 9 DATA INPUT

  RX_MISO VAR PORTB.4               ; MISO INPUT Pin 13 DATA OUTPUT

  RX_IRQ  VAR PORTC.3               ; IRQ INPUT Pin 19 INTERRUPT

                                                            ; VARIABLES

        I VAR BYTE                  ; Variable I

        J VAR BYTE                  ; Variable J

    DATA1 VAR BYTE                  ; Variable DATA1

      CMD VAR BYTE                  ; Variable CMD for Commands Sent to Radio

  PAYLOAD VAR BYTE                  ; Variable for Received Data

      LED VAR BYTE                  ; Variable for LEDs and Data for Transmitter

    AREAD var WORD                  ; Variable for Analog Read of 8 Pos Switch                    

   RFCHAN var byte                  ; Variable for RF CHANNEL

                                                        ; PRESETS      

    PORTA = %00000000               ; Zero Port A

    PORTB = %00000000               ; Zero Port B

    PORTC = %00001000               ; Zero Port C

    PAYLOAD = 0

PAUSE 1000                          ; Pause For Radio Start Up

PAUSE 3000                          ; Pause For Radio Start Up

CLEAR

RFCHAN = 5                           ; RF Channel (0-125

GOSUB CONFIGURE_RX                   ; Go Configure the Receiver

MAINLOOP:                            ;  Main Loop                       

IF RX_IRQ = 0 THEN                   ; Test for Availible Data on Pin 19

GOSUB RESET_RX                       ; Get the data and reset the FIFO  

ENDIF                                ; ENDIF                             

GOTO MAINLOOP                        ; Do it Again

RESET_RX:                            ; READ RX PAYLOAD

RX_CSN = 1                           ; SPI Chip Select Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Pin 15 = 0

CMD = $61                            ; EN_AA REGISTER CMD Load = %011 00001 $61

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

FOR J = 1 TO 4                       ; For J Loop (PAYLOAD DATA 4 TIMES)

DATA1 = 0                            ; Clear DATA1

FOR I = 1 TO 8                       ; For I Loop

DATA1 = DATA1<<1                     ; Shift DATA1 1 bit Left

RX_SCK = 1                           ; SPI Clock Set

DATA1.0 = RX_MISO                    ; Load RX_MISO into DATA1 bit 0

RX_SCK = 0                           ; SPI Clock Clear

NEXT I                               ; Do it Again

HSEROUT [#DATA1]                     ; SEND DATA1 TO THE HARDWARE SERIAL PORT

NEXT J                               ; Do it Again

HSEROUT [” “]                        ; Send 00000000 DATA to the Serial Port

                                     ; FLUSH RX FIFO

RX_CSN = 1                           ; SPI Chip Select Pin 15 SPI OFF

CMD = $E2                            ; Load CMD %11100010

RX_CSN = 0                           ; SPI Chip Select Pin 15 = 0

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

RX_CSN = 1                           ; SPI Chip Select Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Pin 15 = 0

                                     ; RESET INT

DATA1 = $40                          ; STATUS REGISTER Load DATA1 %01000000

CMD = $27                            ; STATUS REGISTER Load CMD %001 00111

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Pin 15 SPI OFF

RETURN                               ; Return

CONFIGURE_RX:                        ; SET UP FOR SHOCKBURST TRANSMISSION

RX_CSN = 1                           ; SPI Chip Select set Pin 15 SPI OFF

RX_CE  = 0                           ; Chip Enable RX In Standby

RX_CSN = 0                           ; SPI Chip Select                                     

DATA1 = $39                          ; PRX, CRC Enabled, PWR OFF %00111001

CMD = $20                            ; CONFIG REGISTER CMD %001 00000 (MASKED)

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $00                          ; EN_AA REGISTER ACK OFF ALL CH %00000000

CMD = $21                            ; EN_AA REGISTER CMD %001 00001

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $03                          ; ADDRESS WITH 5 BYTES %00000011

CMD = $23                            ; SETUP_AW REGISTER CMD %001 00011

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $07                          ; DATA RATE = 1 MB, PWR 1dBM %00000111

CMD = $26                            ; RF_SETUP REGISTER CMD %001 00110

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $04                          ; FOUR BYTE PAYLOAD %00000100

CMD = $31                            ; RX_PW_PN REGISTERS CMD %001 10001

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = RFCHAN                       ; RF_CH REGISTER CHANNEL %00000010********

CMD = $25                            ; RF_CH REGISTER CMD %00100101

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

GOSUB RXMOSIDATA1                    ; Shift out RXMOSIDATA1 8 Times

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $E7                          ; RX_ADDR_PO DATA 11100111 E7E7E7E7E7

CMD = $30                            ; RX_ADDR_PO CMD %001 10000

GOSUB RXMOSICMD                      ; Shift out RXMOSICMD 8 Times

FOR J = 1 TO 5                       ; For J Loop

FOR I = 1 TO 8                       ; For I Loop

RX_MOSI = DATA1.7                    ; Load Data1 bit 7 into RX_MOSI

RX_SCK = 1                           ; SPI Clock Set

RX_SCK = 0                           ; SPI Clock Clear

DATA1 = DATA1<<1                     ; Shift DATA1 1 bit Left

NEXT I                               ; Do it Again DO I FIRST

DATA1 = $E7                          ; ReLoad DATA1 %11100111 5 TIMES LOOP

NEXT J                               ; Do it Again DO J NEXT 5 TIMES

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CSN = 0                           ; SPI Chip Select Clear

DATA1 = $3B                          ; PWR_UP = 1 DATA %00111011

CMD = $20                            ; PWR_UP CMD %001 00000

FOR I = 1 TO 8                       ; For I Loop

RX_MOSI = CMD.7                      ; load RX_MOSI with bit 7 of CMD

RX_SCK = 1                           ; SPI Clock Set

RX_SCK = 0                           ; SPI Clock Clear

CMD = CMD<<1                         ; Shift CMD 1 bit Left

NEXT I                               ; Do it Again

FOR I = 1 TO 8                       ; For I Loop

RX_MOSI = DATA1.7                    ; Load Data1 bit 7 into RX_MOSI

RX_SCK = 1                           ; SPI Clock Set

RX_SCK = 0                           ; SPI Clock Clear

DATA1 = DATA1<<1                     ; Shift DATA1 1 bit Left

NEXT I                               ; Do it Again

RX_CSN = 1                           ; SPI Chip Select Set Pin 15 SPI OFF

RX_CE = 1                            ; Chip Enable Set Radio On

RETURN                               ; Return

                                     ; SUBROUTINE                                   

RXMOSICMD:                           ; RXMOSI CMD SUBROUTINE

for I = 1 TO 8                       ; For loop

RX_MOSI = CMD.7                      ; load RX_MOSI with bit 7 of CMD

RX_SCK = 1                           ; SPI Clock Set

RX_SCK = 0                           ; SPI Clock Clear

CMD = CMD<<1                         ; Shift CMD 1 bit Left

next I                               ; Do it Again

RETURN                               ; RETURN

RXMOSIDATA1:                         ; Shift Out RXMOSIDATA1 Subroutine

FOR I = 1 TO 8                       ; For I Loop

RX_MOSI = DATA1.7                    ; Load Data1 bit 7 into RX_MOSI

RX_SCK = 1                           ; SPI Clock Set

RX_SCK = 0                           ; SPI Clock Clear

DATA1 = DATA1<<1                     ; Shift DATA1 1 bit Left

NEXT I                               ; Do it Again

RETURN                               ; RETURN

END                                  ; End