Programming RFM radio modules in Basic - Page 2
+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 41 to 78 of 78
  1. #41
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    Regarding the comments on the program, i leave them there for me. Sorry for disturbing your reading by using those comments. Because of i use them for my children project GPS, i try to keep those to remind me what i have done.
    there is a big difference between comments that impart some information and visual white noise that masks the very few bits of data that are crucially different
    and worthy of notation
    This is more entertaining than Free to Air TV

  2. #42

    Default Re: Programming RFM radio modules in Basic

    My knowledge and time not helping my self to quickly develop a simple LED to light from one end of RFM69hcw to the other.

    But i will keep reading and studding all the information needed to achieve my goal.

  3. #43

    Default Re: Programming RFM radio modules in Basic

    Now a small step, in the code is to add the DIO0 pin from RFM69HCW to PIC18F26K22.

    As i read from the net, that pin is the:

    Received data ready interrupt signal from RFM69HCW to microcontroller

    TRIS register must also be configured as input at that pin i guess as the RFM69HCW is the one sending data to PIC.

    That i believe will complete the connections between the PIC and the RFM.

    Code:
    '**********************************************************************
    '*  Name    : 18F26K22.BAS                                            *
    '*  Author  : [Leonardo Bilalis]                                      *
    '*  Notice  : Copyright (c) 2018 [Leonardo Bilalis]                   *
    '*          : All Rights Reserved                                     *
    '*  Date    : 30/Jun/2018                                             *
    '*  Version : 1.0                                                     *
    '*  Notes   : This is a GPS Tracker based on the following components *
    '*          : PIC18F26K22 or PIC18F46K22 @ 64Mhz                      *
    '*          : MKT 3333 or 3339 GPS MODULE                             *
    '*          : 4D Systems ULCD Goldelox or Picasso Graphic Processor   *
    '*          : RFM69HCW the range will be approximatelly 1000 meters   *
    '**********************************************************************     
    
      #CONFIG   ;
         CONFIG FOSC     = HSHP	        ; HS oscillator (high power > 16 MHz)
        CONFIG PLLCFG    = ON	        ;Oscillator multiplied by 4  
        CONFIG PRICLKEN  = ON	        ;Primary clock enabled
        CONFIG FCMEN     = OFF	        ;Fail-Safe Clock Monitor disabled
        CONFIG IESO      = OFF	        ;Oscillator Switchover mode disabled
        CONFIG  BOREN    = SBORDIS      ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
        CONFIG  WDTEN    = ON           ; WDT is always enabled. SWDTEN bit has no effect                     ;|
        CONFIG  WDTPS    = 32768        ; 1:32768 ---> HERE enable the watchdog timer with a 1:32768 postscale;|
        CONFIG  PWRTEN   = ON
        CONFIG  HFOFST   = ON           ; HFINTOSC output and ready status are not delayed by the oscillator stable status
        CONFIG  MCLRE    = EXTMCLR      ; MCLR pin enabled, RE3 input pin disabled
        CONFIG  LVP      = OFF          ; Single-Supply ICSP disabled
        CONFIG  XINST    = OFF          ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        CONFIG  DEBUG    = OFF          ; Disabled  
        CONFIG  CP0 = OFF             ; Block 0 (000800-003FFFh) not code-protected
        CONFIG  CP1 = OFF             ; Block 1 (004000-007FFFh) not code-protected
        CONFIG  CP2 = OFF             ; Block 2 (008000-00BFFFh) not code-protected
        CONFIG  CP3 = OFF             ; Block 3 (00C000-00FFFFh) not code-protected
        CONFIG  CPB = OFF             ; Boot block (000000-0007FFh) not code-protected
        CONFIG  CPD = OFF             ; Data EEPROM not code-protected
        CONFIG  WRT0 = OFF            ; Block 0 (000800-003FFFh) not write-protected
        CONFIG  WRT1 = OFF            ; Block 1 (004000-007FFFh) not write-protected
        CONFIG  WRT2 = OFF            ; Block 2 (008000-00BFFFh) not write-protected
        CONFIG  WRT3 = OFF            ; Block 3 (00C000-00FFFFh) not write-protected
        CONFIG  WRTC = OFF            ; Configuration registers (300000-3000FFh) not write-protected
        CONFIG  WRTB = OFF            ; Boot Block (000000-0007FFh) not write-protected
        CONFIG  WRTD = OFF            ; Data EEPROM not write-protected
        CONFIG  EBTR0 = OFF           ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR1 = OFF           ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR2 = OFF           ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR3 = OFF           ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTRB = OFF           ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
      #ENDCONFIG
      
    define  OSC 64
            
    OSCCON    = %01110000   ; 64Mhz
    OSCTUNE.6 = 1           ; Enable 4x PLL
    while ! osccon2.7 :WEND ; to make sure the pll has stabilised before you run any other code
    
    
    initialize:
    CLEAR                   
    
    TRISA = %11011111 
    TRISC = %11010111  
    
    
    
    SSPCON1 = %00100010 ' in here we se the 5th bit of the SSPCON1 register and the last 4 bits for the clock speed at 64Mhz.
    SSP1STAT = %11000000  ' in here i need a help to understand what bits must be configured
    
    
    
    CS1      VAR           LATA.5  ' chip select (SS) from PIC18F26K22 to RFM69HCW
    DIO0     VAR           PORTC.2 ' Received data ready interrupt signal from RFM69HCW to microcontroller
    SCK1     VAR           PORTC.3 ' clock from PIC18F26K22 to RFM69HCW
    SDI1     VAR           PORTC.4 ' data IN , MISO from PIC18F26K22 to RFM69HCW
    SDO1     VAR           PORTC.5 ' data OUT, MOSI from PIC18F26K22 to RFM69HCW
    
    SSPIF   VAR     PIR1.3          ' SPI interrupt flag
    SMP     VAR     SSP1STAT.7      ' Data input sample phase
    CKE     VAR     SSP1STAT.6      ' Clock Edge Select bit
    SSPEN   VAR     SSP1CON1.5      ' SSP Enable bit
    CKP     VAR     SSP1CON1.4      ' Clock Polarity Select
    
    CS1    = 1
    Last edited by astanapane; - 2nd September 2018 at 20:04.

  4. #44
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    As i read from the net, that pin is the:

    Received data ready interrupt signal from RFM69HCW to microcontroller
    not really, in rx mode its PayloadReady in tx mode its PacketSent



    That i believe will complete the connections between the PIC and the RFM.
    that's 1% of the job done


    cannot see any point to creating these vars , they will never be used
    Code:
    SSPIF   VAR     PIR1.3          ' SPI interrupt flag
    SMP     VAR     SSP1STAT.7      ' Data input sample phase
    CKE     VAR     SSP1STAT.6      ' Clock Edge Select bit
    SSPEN   VAR     SSP1CON1.5      ' SSP Enable bit
    CKP     VAR     SSP1CON1.4      ' Clock Polarity Select
    This is more entertaining than Free to Air TV

  5. #45

    Default Re: Programming RFM radio modules in Basic

    that's 1% of the job done
    That is what i meant

  6. #46

    Default Re: Programming RFM radio modules in Basic

    I will try to help myself and understand how to establish a connection between two RFM69HCW.

    Thanks to all of you trying to help me. I will upload a circuit diagram tomorrow afternoon for all of the people are interested to the same example.

    Here is a code in a really very early stage only trying to understand and configure the hardware ports.

    Code:
    #IF __PROCESSOR__ = "18F26K22" 
      #CONFIG   ;  The PBP configuration for the PIC18F26K22 is:
    ;    CONFIG FOSC     = RCIO6	    ; External RC oscillator
         CONFIG FOSC     = HSHP	        ; HS oscillator (high power > 16 MHz)
         
    
    ;*---------------------------------4x PLL ENABLE--------------------------------------*|
    ;*  4X PLL Enable                                                                     *|
    ;*    CONFIG PLLCFG  = OFF	        ;Oscillator used directly                         *|
        CONFIG PLLCFG    = ON	        ;Oscillator multiplied by 4                       *|
    ;*------------------------------------------------------------------------------------*|
    ;
    ;  Primary clock enable bit
    ;    CONFIG PRICLKEN = OFF	        ;Primary clock can be disabled by software
        CONFIG PRICLKEN  = ON	        ;Primary clock enabled
    ;
    ;  Fail-Safe Clock Monitor Enable bit
        CONFIG FCMEN     = OFF	        ;Fail-Safe Clock Monitor disabled
    ;    CONFIG FCMEN    = ON	        ;Fail-Safe Clock Monitor enabled
    ;
    ;  Internal/External Oscillator Switchover bit
        CONFIG IESO      = OFF	        ;Oscillator Switchover mode disabled
    ;    CONFIG IESO     = ON	        ;Oscillator Switchover mode enabled
        
        CONFIG  BOREN    = SBORDIS      ; Brown-out Reset enabled in hardware only (SBOREN is disabled)
        
    ;*--------------------------------------------------------------------------------------------------------;|
        CONFIG  WDTEN    = ON           ; WDT is always enabled. SWDTEN bit has no effect                     ;|
        CONFIG  WDTPS    = 32768        ; 1:32768 ---> HERE enable the watchdog timer with a 1:32768 postscale;|
    ;*--------------------------------------------------------------------------------------------------------;|
        
        CONFIG  PWRTEN   = ON
        CONFIG  HFOFST   = ON           ; HFINTOSC output and ready status are not delayed by the oscillator stable status
        CONFIG  MCLRE    = EXTMCLR      ; MCLR pin enabled, RE3 input pin disabled
        CONFIG  LVP      = OFF          ; Single-Supply ICSP disabled
        CONFIG  XINST    = OFF          ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        CONFIG  DEBUG    = OFF          ; Disabled
    CONFIG  CP0 = OFF             ; Block 0 (000800-003FFFh) not code-protected
        CONFIG  CP1 = OFF             ; Block 1 (004000-007FFFh) not code-protected
        CONFIG  CP2 = OFF             ; Block 2 (008000-00BFFFh) not code-protected
        CONFIG  CP3 = OFF             ; Block 3 (00C000-00FFFFh) not code-protected
        CONFIG  CPB = OFF             ; Boot block (000000-0007FFh) not code-protected
        CONFIG  CPD = OFF             ; Data EEPROM not code-protected
        CONFIG  WRT0 = OFF            ; Block 0 (000800-003FFFh) not write-protected
        CONFIG  WRT1 = OFF            ; Block 1 (004000-007FFFh) not write-protected
        CONFIG  WRT2 = OFF            ; Block 2 (008000-00BFFFh) not write-protected
        CONFIG  WRT3 = OFF            ; Block 3 (00C000-00FFFFh) not write-protected
        CONFIG  WRTC = OFF            ; Configuration registers (300000-3000FFh) not write-protected
        CONFIG  WRTB = OFF            ; Boot Block (000000-0007FFh) not write-protected
        CONFIG  WRTD = OFF            ; Data EEPROM not write-protected
        CONFIG  EBTR0 = OFF           ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR1 = OFF           ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR2 = OFF           ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTR3 = OFF           ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
        CONFIG  EBTRB = OFF           ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks
    
      #ENDCONFIG
      
    #ELSE
        #MSG "Wrong Processor selected!"
    #ENDIF   
    ;*---------------------------------------------------------------------------------------------------------|
    ;*---------------------------------------------------------------------------------------------------------|
    
    define  OSC 64
    
            INCLUDE "modedefs.bas"
            INCLUDE "ALLDIGITAL.pbp"
            'INCLUDE "DT_INTS-18.bas"        ; Base Interrupt System
            'INCLUDE "ReEnterPBP-18.bas"     ; Include if using PBP interrupts
            
    OSCCON    = %01110000   ; 64Mhz
    OSCTUNE.6 = 1           ; Enable 4x PLL
    
    while ! osccon2.7 :WEND ; to make sure the pll has stabilised before you run any other code
    
    
    '------------------------------------------------------------------------------|
    '                            INITIALIZE RAM                                    |
    '------------------------------------------------------------------------------|
    initialize:
    	CLEAR                   
    
    TRISA = %00000000   'use TRISA to specify which pin is (1 = input) and which (0 = output)  
    TRISB = %00000000   'use TRISB to specify which pin is (1 = input) and which (0 = output)  
    TRISC = %00010000
    
    PORTA = 0            'make low all ports at A range                      |
    PORTB = 0            'make low all ports at B range                      |
    PORTC = 0            'make low all ports at C range                      |
    PORTE = 0            'make low all ports at E range
    
    '------------------------------------------------------------------------|
    '-------------------------- COMPARATORS OFF -----------------------------|
    '------------------------------------------------------------------------|
    CM1CON0.7 = 0 'Disable comparator1                                       |
    CM2CON0.7 = 0 'Disable comparator2                                       |
    '------------------------------------------------------------------------|
    
    SSP1CON1 = %00100010 ' in here we se the 5th bit of the SSPCON1 register and the last 4 bits for the clock speed at 64Mhz.
    
    SSP1STAT = %11000000
    
    '*-----------------------------------------------------------------------|
    '*-----------------------------------------------------------------------|
    
    RFM_CS      VAR     LATA.5      ' chip select (SS) from PIC18F26K22 to RFM69HCW
    RFM_DIO0    var     PORTC.1     ' Received data ready interrupt signal from RFM69HCW G0 to microcontroller pin 12 PORTC.1
    SCK1        VAR     PORTC.3     ' clock from PIC18F26K22 to RFM69HCW
    SDI1        VAR     PORTC.4     ' data IN , MISO from PIC18F26K22 to RFM69HCW
    SDO1        VAR     PORTC.5     ' data OUT, MOSI from PIC18F26K22 to RFM69HCW
    
    RFM_CS = 1
    
    '*************************************************************************
    '                                                                        *
    '                          IMPORTANT SETTINGS                            *
    '                                                                        *
    '*************************************************************************
    
    Define NETWORKID 10         'this must be the same on all nodes that talk to each other  (0 to 255)
    DEFINE SENDER    1          'in here we could have multiple senders (0 to 255)
    Define RECEIVER  2          'unique ID of the gateway/receiver (0 to 254, 255 = broadcast)
    define NODEID    sender     'if this is sender, we define the node
    
    Define FREQUENCY   ...............
    DEFINE ENCRYPTKEY  ...............
    I would like to setup first the basics as you see on the code above. So please let me know if that is ok at the moment.

    The frequency im using is the 433Mhz
    I guess the encrypted key can be anything.

  7. #47
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    i'm not liking what i see already


    #IF __PROCESSOR__ = "18F26K22"
    #CONFIG ; The PBP configuration for the PIC18F26K22 is:
    ; CONFIG FOSC = RCIO6 ; External RC oscillator
    CONFIG FOSC = HSHP ; HS oscillator (high power > 16 MHz) why use a crystal ? it just wastes pins in this case



    ;*---------------------------------4x PLL ENABLE--------------------------------------*|
    ;* 4X PLL Enable *|
    ;* CONFIG PLLCFG = OFF ;Oscillator used directly *|
    CONFIG PLLCFG = ON ;Oscillator multiplied by 4 *|
    ;*------------------------------------------------------------------------------------*|
    ;
    ; Primary clock enable bit
    ; CONFIG PRICLKEN = OFF ;Primary clock can be disabled by software
    CONFIG PRICLKEN = ON ;Primary clock enabled
    ;
    ; Fail-Safe Clock Monitor Enable bit
    CONFIG FCMEN = OFF ;Fail-Safe Clock Monitor disabled
    ; CONFIG FCMEN = ON ;Fail-Safe Clock Monitor enabled
    ;
    ; Internal/External Oscillator Switchover bit
    CONFIG IESO = OFF ;Oscillator Switchover mode disabled
    ; CONFIG IESO = ON ;Oscillator Switchover mode enabled

    CONFIG BOREN = SBORDIS ; Brown-out Reset enabled in hardware only (SBOREN is disabled)

    ;*--------------------------------------------------------------------------------------------------------;|
    CONFIG WDTEN = ON ; WDT is always enabled. SWDTEN bit has no effect ;|
    CONFIG WDTPS = 32768 ; 1:32768 ---> HERE enable the watchdog timer with a 1:32768 postscale;|
    ;*--------------------------------------------------------------------------------------------------------;|

    CONFIG PWRTEN = ON
    CONFIG HFOFST = ON ; HFINTOSC output and ready status are not delayed by the oscillator stable status
    CONFIG MCLRE = EXTMCLR ; MCLR pin enabled, RE3 input pin disabled
    CONFIG LVP = OFF ; Single-Supply ICSP disabled
    CONFIG XINST = OFF ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
    CONFIG DEBUG = OFF ; Disabled
    CONFIG CP0 = OFF ; Block 0 (000800-003FFFh) not code-protected
    CONFIG CP1 = OFF ; Block 1 (004000-007FFFh) not code-protected
    CONFIG CP2 = OFF ; Block 2 (008000-00BFFFh) not code-protected
    CONFIG CP3 = OFF ; Block 3 (00C000-00FFFFh) not code-protected
    CONFIG CPB = OFF ; Boot block (000000-0007FFh) not code-protected
    CONFIG CPD = OFF ; Data EEPROM not code-protected
    CONFIG WRT0 = OFF ; Block 0 (000800-003FFFh) not write-protected
    CONFIG WRT1 = OFF ; Block 1 (004000-007FFFh) not write-protected
    CONFIG WRT2 = OFF ; Block 2 (008000-00BFFFh) not write-protected
    CONFIG WRT3 = OFF ; Block 3 (00C000-00FFFFh) not write-protected
    CONFIG WRTC = OFF ; Configuration registers (300000-3000FFh) not write-protected
    CONFIG WRTB = OFF ; Boot Block (000000-0007FFh) not write-protected
    CONFIG WRTD = OFF ; Data EEPROM not write-protected
    CONFIG EBTR0 = OFF ; Block 0 (000800-003FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR1 = OFF ; Block 1 (004000-007FFFh) not protected from table reads executed in other blocks
    CONFIG EBTR2 = OFF ; Block 2 (008000-00BFFFh) not protected from table reads executed in other blocks
    CONFIG EBTR3 = OFF ; Block 3 (00C000-00FFFFh) not protected from table reads executed in other blocks
    CONFIG EBTRB = OFF ; Boot Block (000000-0007FFh) not protected from table reads executed in other blocks


    #ENDCONFIG

    #ELSE
    #MSG "Wrong Processor selected!"
    #ENDIF
    ;*---------------------------------------------------------------------------------------------------------|
    ;*---------------------------------------------------------------------------------------------------------|


    define OSC 64

    lets not get too complicated to start with leave this out
    INCLUDE "modedefs.bas"
    INCLUDE "ALLDIGITAL.pbp"
    'INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
    'INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts

    OSCCON = %01110000 ; 64Mhz
    OSCTUNE.6 = 1 ; Enable 4x PLL


    while ! osccon2.7 :WEND ; to make sure the pll has stabilised before you run any other code




    '------------------------------------------------------------------------------|
    ' INITIALIZE RAM |
    '------------------------------------------------------------------------------|
    initialize:
    CLEAR
    i fully disagree with making pins outputs unless they will be used as outputs when bread boarding
    TRISA = %00000000 'use TRISA to specify which pin is (1 = input) and which (0 = output)
    TRISB = %00000000 'use TRISB to specify which pin is (1 = input) and which (0 = output)
    portc.1 needs to be an input
    TRISC = %00010010

    lets no do this but set pins that matter in the initialisation code
    PORTA = 0 'make low all ports at A range |
    PORTB = 0 'make low all ports at B range |
    PORTC = 0 'make low all ports at C range |
    PORTE = 0 'make low all ports at E range

    missing entirely set ports digital
    ANSELB=0
    anselc =0
    ANSELa=0



    totally pointless they are already off
    '------------------------------------------------------------------------|
    '-------------------------- COMPARATORS OFF -----------------------------|
    '------------------------------------------------------------------------|
    CM1CON0.7 = 0 'Disable comparator1 |
    CM2CON0.7 = 0 'Disable comparator2 |
    '------------------------------------------------------------------------|


    totally pointless the rfm init code will set up the mssp module
    SSP1CON1 = %00100010 ' in here we se the 5th bit of the SSPCON1 register and the last 4 bits for the clock speed at 64Mhz.


    SSP1STAT = %11000000


    '*-----------------------------------------------------------------------|
    '*-----------------------------------------------------------------------|


    RFM_CS VAR LATA.5 ' chip select (SS) from PIC18F26K22 to RFM69HCW
    RFM_DIO0 var PORTC.1 ' Received data ready interrupt signal from RFM69HCW G0 to microcontroller pin 12 PORTC.1

    no need they will never be used

    SCK1 VAR PORTC.3 ' clock from PIC18F26K22 to RFM69HCW
    SDI1 VAR PORTC.4 ' data IN , MISO from PIC18F26K22 to RFM69HCW
    SDO1 VAR PORTC.5 ' data OUT, MOSI from PIC18F26K22 to RFM69HCW


    RFM_CS = 1


    all these setting are hard coded into the rfm69 init routine and cannot be changed in the code as it stands
    '************************************************* ************************
    ' *
    ' IMPORTANT SETTINGS *
    ' *
    '************************************************* ************************


    Define NETWORKID 10 'this must be the same on all nodes that talk to each other (0 to 255)
    DEFINE SENDER 1 'in here we could have multiple senders (0 to 255)
    Define RECEIVER 2 'unique ID of the gateway/receiver (0 to 254, 255 = broadcast)
    define NODEID sender 'if this is sender, we define the node


    Define FREQUENCY ...............
    DEFINE ENCRYPTKEY ...............
    This is more entertaining than Free to Air TV

  8. #48
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    the basic shell to work with


    Code:
    #CONFIG
      CONFIG  FOSC = INTIO67
      CONFIG  PLLCFG = OFF
      CONFIG  PRICLKEN = ON
      CONFIG  FCMEN = OFF
      CONFIG  IESO = OFF
      CONFIG  PWRTEN = ON
      CONFIG  BOREN = SBORDIS
      CONFIG  BORV = 190
      CONFIG  WDTEN = OFF
      CONFIG  WDTPS = 32768
      CONFIG  CCP2MX = PORTC1
      CONFIG  PBADEN = OFF
      CONFIG  CCP3MX = PORTB5
      CONFIG  T3CMX = PORTC0
      CONFIG  HFOFST = ON
      CONFIG  P2BMX = PORTB5
      CONFIG  MCLRE = EXTMCLR
      CONFIG  STVREN = ON
      CONFIG  LVP = OFF
      CONFIG  XINST = OFF
      CONFIG  DEBUG = OFF
      CONFIG  CP0 = OFF
      CONFIG  CP1 = OFF
      CONFIG  CP2 = OFF
      CONFIG  CP3 = OFF
      CONFIG  CPB = OFF
      CONFIG  CPD = OFF
      CONFIG  WRT0 = OFF
      CONFIG  WRT1 = OFF
      CONFIG  WRT2 = OFF
      CONFIG  WRT3 = OFF
      CONFIG  WRTC = OFF
      CONFIG  WRTB = OFF
      CONFIG  WRTD = OFF
      CONFIG  EBTR0 = OFF
      CONFIG  EBTR1 = OFF
      CONFIG  EBTR2 = OFF
      CONFIG  EBTR3 = OFF
      CONFIG  EBTRB = OFF
    #ENDCONFIG
        
    DEFINE OSC 64
    
    
    
    
    
    
    ;some vars the engine needs
    
    
    sdata  var byte
    tmpa   var word
    tmpb   var word
    tmp    var word
    rxflg  var byte
    i      var byte
    dest   var byte
    rfbuff var byte[17]
    
    
    
    
    rfm_int    var portc.1    ;dio0
    rfm_cs     var lata.5      ;nss
    button     var portc.0
    led          var portc.2
    
    goto overrfm  ; this is the rfm69 engine there is nothing here for users ,make no changes 
    
    
    rfm:
    
    
    asm
     dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0x08c0
     dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0x2e90
     dw 0x2fde,0x30ad,0x3163,0x3734,0x3811,0x3904,0x3a01,0x3C8c
     dw 0x6F30  
    
    
    
    
    GLetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1  
        BANKSEL 0
        endm 
     endasm    
    
    
    
    sendFrame:       ;tx to dest
        tmpb = $0104
        gosub writeReg 
        pauseus 800
        TMPB=$2810
        GOSUB WRITEREG
        TMPB=$2800
        GOSUB WRITEREG  
        TMPB=$2500
        GOSUB WRITEREG 
        RFM_CS=0
        sdata=$80
        gosub xspi
        sdata=dest
        gosub xspi 
        for i = 0 to 15 
            sdata=rfbuff[i]
            gosub xspi   
        next 
        RFM_CS=1
        tmpb = $010c
        GOSUB WRITEREG 
        while  rfm_int == 0  : wend
        tmpb = $0104
        gosub writeReg     
        pauseus 800
        TMPB=$2540
        GOSUB WRITEREG 
    return   
    
    xspi:             ;spi xfer 
        SSP1CON1.7 = 0
        SSP1BUF = sdata
        while(SSP1STAT.0 ==0) :wend
        sdata = SSP1BUF
        return  
    
    writeReg:   
        RFM_CS=0
        sdata=tmpb.highbyte|$80     ;reg
        gosub xspi
        sdata=tmpb                   ;data
        gosub xspi
        RFM_CS=1   
    return  
    
    readReg:   
        RFM_CS=0
        sdata=tmpb.highbyte&$7f    ;reg
        gosub xspi
        sdata=0
        gosub xspi
        RFM_CS=1
        tmpb=sdata             ;reply
    return 
    
    
    r69Init:
        @ GLetAddress _rfm ,_tmpa
        SSPCON1=$21  
        SSPSTAT=$c0
        for tmp=0 to 24  
        READCODE tmpa,tmpb
        tmpa=tmpa+2   ; +1 for pic16 +2 for pic18
        gosub writeReg
        next
        gosub rfm_set_highpower      ; "h" modules only
    return  
    
    rfm_set_highpower:      ; "h" modules only   turns on power amp 
        tmpb=$130F
        gosub writeReg
        tmpb=$1200
        gosub readReg 
        tmpb=tmpb&$1f    
        tmpb=tmpb|$1160
        gosub writeReg
        tmpb=$5a5d
        gosub writeReg
        tmpb=$5c7c
        gosub writeReg
    return    
    overrfm:     
        
    
    
    
    
    ;setup osc
    OSCCON=$70
    OSCTUNE.6=1
    while ! osccon2.7 :WEND    ;wait for pll
    
    ;setup pins
    trisa=%11011111 
    trisc=%11010011 
    ANSELB=0                          
    anselc =0
    ANSELa=0 
    
    
    
    
    
    
    rxflg =0
    
    
    gosub r69Init ;program module
    
    
    tmpb = $0110      ;set listen mode
    gosub writeReg
    pauseus 800
       
    
    
    loopy:
        if rfm_int then     ; poll for pkt recieved
            tmpb = $0104     ;standby
            gosub writeReg 
            pauseus 800 
            tmpb=0
            gosub readreg
            if tmpb = 4 then rxflg =1   ;a pkt for me ?      
            i=0 ;
            while (i<16)
                tmpb=0
                gosub readreg
                rfbuff[i] = tmpb
                i=i+1
            wend        
            tmpb = $0110      ;set listen mode
            gosub writeReg
            pauseus 800
    
    
        endif
        if  rxflg then
        ;insert your code here to parse packet and act on it
         rxflg=0
        endif
       ;insert your code here to run in this loop
    
    
        
    goto loopy
    Last edited by richard; - 17th March 2019 at 22:41.
    This is more entertaining than Free to Air TV

  9. #49

    Default Re: Programming RFM radio modules in Basic

    Hi Richard, just came back from a long day.

    Thanks for the comments on the code.

    You are right, there is no need to use external components and reserve ports. I will use the internal OSC at 64Mhz.

    #IF __PROCESSOR__ = "18F26K22"
    #CONFIG ; The PBP configuration for the PIC18F26K22 is:
    ; CONFIG FOSC = RCIO6 ; External RC oscillator
    CONFIG FOSC = HSHP ; HS oscillator (high power &gt; 16 MHz) why use a crystal ? it just wastes pins in this case
    sure i can leave them aside at the moment.

    lets not get too complicated to start with leave this out
    INCLUDE "modedefs.bas"
    INCLUDE "ALLDIGITAL.pbp"
    'INCLUDE "DT_INTS-18.bas" ; Base Interrupt System
    'INCLUDE "ReEnterPBP-18.bas" ; Include if using PBP interrupts
    Ok, but what should i give as a state if not output? for the PORTC.1 it is clear to me as it will behave as an input.

    i fully disagree with making pins outputs unless they will be used as outputs when bread boarding
    TRISA = %00000000 'use TRISA to specify which pin is (1 = input) and which (0 = output)
    TRISB = %00000000 'use TRISB to specify which pin is (1 = input) and which (0 = output)
    portc.1 needs to be an input
    TRISC = %00010010

    Is there any problem when we set the ports at the very beggining of the program not to funtions at all and set the low? Then in the program we could assign any pin to be low or high

    lets no do this but set pins that matter in the initialisation code
    PORTA = 0 'make low all ports at A range |
    PORTB = 0 'make low all ports at B range |
    PORTC = 0 'make low all ports at C range |
    PORTE = 0 'make low all ports at E range
    That's is why we include at the beggining the: INCLUDE "ALLDIGITAL.pbp"

    but sure as we leave them on a side somehow here we have to tell that all ports are digital thanks.

    missing entirely set ports digital
    ANSELB=0
    anselc =0
    ANSELa=0
    I though that it is not off unless we configure them to be off.

    really didnt know. maybe i need to read better the datasheets.

    totally pointless they are already off
    '------------------------------------------------------------------------|
    '-------------------------- COMPARATORS OFF -----------------------------|
    '------------------------------------------------------------------------|
    CM1CON0.7 = 0 'Disable comparator1 |
    CM2CON0.7 = 0 'Disable comparator2 |
    '------------------------------------------------------------------------|

    OK

    totally pointless the rfm init code will set up the mssp module
    SSP1CON1 = %00100010 ' in here we se the 5th bit of the SSPCON1 register and the last 4 bits for the clock speed at 64Mhz.


    SSP1STAT = %11000000

    I though that we need to set those as somehow we need from those ports to send and receive data.

    no need they will never be used
    SCK1 VAR PORTC.3 ' clock from PIC18F26K22 to RFM69HCW
    SDI1 VAR PORTC.4 ' data IN , MISO from PIC18F26K22 to RFM69HCW
    SDO1 VAR PORTC.5 ' data OUT, MOSI from PIC18F26K22 to RFM69HCW

    I understand. In order to use the following statement someone need to create an include file. Then those configurations can be easily updated.

    all these setting are hard coded into the rfm69 init routine and cannot be changed in the code as it stands
    '************************************************* ************************
    ' *
    ' IMPORTANT SETTINGS *
    ' *
    '************************************************* ************************


    Define NETWORKID 10 'this must be the same on all nodes that talk to each other (0 to 255)
    DEFINE SENDER 1 'in here we could have multiple senders (0 to 255)
    Define RECEIVER 2 'unique ID of the gateway/receiver (0 to 254, 255 = broadcast)
    define NODEID sender 'if this is sender, we define the node


    Define FREQUENCY ...............
    DEFINE ENCRYPTKEY ...............
    As i see some of the ports are included in your code as the button and the LED. Let me fix the breadboard and i will come back with lots of questions based on your code starting with the first

    what is this for?

    Code:
    asm
     dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0x08c0
     dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0x2e90
     dw 0x2fde,0x30ad,0x3163,0x3734,0x3811,0x3904,0x3a01,0x3C8c
     dw 0x6F30
    of course i dont understand the asm you have written so if you could find time to make things easier for all of us, would be really helpfull.

    Will come back soon with lots of questions based on your code.

  10. #50

    Default Re: Programming RFM radio modules in Basic

    I also have plenty of questions regarding some of the Configs.

    not that i understand some of the other configs but those really cant figure out why we set them and what is the operation for each of them.

    CONFIG CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1
    CONFIG PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset
    CONFIG CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5
    CONFIG T3CMX = PORTC0 ; T3CKI is on RC0

  11. #51
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    Ok, but what should i give as a state if not output? for the PORTC.1 it is clear to me as it will behave as an input.
    tris can have only two values for each bit , 0 or 1 . if bit =0 the pin is an output , it its not 0 its a 1 and thefore an input
    you do not give pins a "state " you clear the revejent bit to make apin an output

    That's is why we include at the beggining the: INCLUDE "ALLDIGITAL.pbp"
    since dt died who is keeping it uptodate ?

    I though that we need to set those as somehow we need from those ports to send and receive data.


    no need they will never be used
    SCK1 VAR PORTC.3 ' clock from PIC18F26K22 to RFM69HCW
    SDI1 VAR PORTC.4 ' data IN , MISO from PIC18F26K22 to RFM69HCW
    SDO1 VAR PORTC.5 ' data OUT, MOSI from PIC18F26K22 to RFM69HCW

    we never drive any of these pins directly , the mssp module is in charge of them . we use control and use the mssp module



    I understand. In order to use the following statement someone need to create an include file. Then those configurations can be easily updated.

    good luck with that , as i stated all these setting are hard coded into the rfm69 init routine and cannot be changed in the code as it stands


    what is this for?


    Code:
    asm
    dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0 x08c0
    dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0 x2e90
    dw 0x2fde,0x30ad,0x3163,0x3734,0x3811,0x3904,0x3a01,0 x3C8c
    dw 0x6F30
    that is the data to load into the rfm module's registes to make it behave in the manner we need

    these set the alternative pin options for the indicated module outputs [whether we use them or not a choice must be made]
    CONFIG CCP2MX = PORTC1 ; CCP2 input/output is multiplexed with RC1
    CONFIG CCP3MX = PORTB5 ; P3A/CCP3 input/output is multiplexed with RB5
    CONFIG T3CMX = PORTC0 ; T3CKI is on RC0
    this set portb digital at boot up [technically anselb=0 is not required when this option used]
    CONFIG PBADEN = OFF ; PORTB<5:0> pins are configured as digital I/O on Reset
    This is more entertaining than Free to Air TV

  12. #52

    Default Re: Programming RFM radio modules in Basic

    I'm trying to figure out a way to understand this code. I guess all those coming from the datasheet?

    Code:
    asm
    dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0 x08c0
    dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0 x2e90
    dw 0x2fde,0x30ad,0x3163,0x3734,0x3811,0x3904,0x3a01,0 x3C8c
    dw 0x6F30
    So the first marked with blue is the register conrresponds to the following?

    0x01 RegOpMode 0x04 Operating modes of the transceiver

    Then i will try to make notes for each of these registers. Richard it is the only way i could understand things and then to help my self in order not to waste your time.

  13. #53
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    i'm not prepared to support the code to that level of detail yet , remember the car analogy you are wanting to discuss engine fine tuning when it is yet to be proven that you can even drive it or even get it started . small steps . those settings are the result years of experience not to mention many months of trial and effort, not forgetting many hours studying the hope rf docs and sample code . don't lose sight that this a pbp forum not a hope rf forum . you are yet to in any way indicate how you expect to use the module ,what data you will send or anything . i have grave reservations that you have any idea how to use a simplex packet radio system for data transmission at all. a simple no frills lib was asked for i cannot make it any simpler.
    usage is quite simple , after the module is initialised it has two modes listen or standby ,when listening you need to monitor the rfm_int pin to see if a packet has been received , if it has then there is example code to demonstrate how to extract the data packet, at any time you can load up the data buffer and transmit a packet . thats it . [thats how these thing work]
    you keep quibbling around the edges, to me there is no point discussing the fine detail until you can prove that you can actually get somewhere with it.
    This is more entertaining than Free to Air TV

  14. #54

    Default Re: Programming RFM radio modules in Basic

    Hi Richard,

    thanks for the comments. Everything you said is totally rihgt, I know i have a long road until i fully understand how to use this module.

  15. #55
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    Contrary to my better judgement i will have one final try. all the technical confusing stuff that is of no concern is safely hidden from sight and tucked away in an include file ,its a black box . the user interface has been neatened up a bit with some usercmds and a few gosubs for frequently used sequences .
    two demos are included one is master the other slave , the master will send data to toggle the led on the slave ,the slave will reply with the leds new status , the master will set its led to match the slaves led. master and slave are identical schematically.
    miso=sdi1 mosi =sdo1 sck=sck1 led=portc.2 r69_cs=porta.5 r69_int=portc.1
    it this is beyond your comprehension then i will give up
    Attached Files Attached Files
    This is more entertaining than Free to Air TV

  16. #56

    Default Re: Programming RFM radio modules in Basic

    Hi Richard,

    i havent replied because i was studing the previous code. Now i believe you made it much easier. So please let me study and try this one and i will come back with questions or good news.

  17. #57

    Default Re: Programming RFM radio modules in Basic

    Thats the schematic, thanks a lot for the detailed info. I had placed opposite the SDI and SDO from the PIC to the radio module. Hope i didnt burn anything. Always the VDD is at 3.3V

    I hace saved the include file as .bas to a specific folder and just compiled the master and slave files. Havent looked at those in detail yet.
    Attached Images Attached Images  

  18. #58
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    vdd needs to be 5v, i see no current limiting resistors on the leds.
    This is more entertaining than Free to Air TV

  19. #59
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    an actual schematic
    Attached Images Attached Images
    This is more entertaining than Free to Air TV

  20. #60

    Default Re: Programming RFM radio modules in Basic

    Hi Richard,

    i have updated the schematic, with a resistor on the leds and one 100n capacitor on the Vdd to GND at the radio module.

    Just for a test i passed the code to the chips and tried to see if there is anything i could see or if the LEDs will indicate anything but nothing happended.

    the only indication from the leds is the following code

    Code:
    ;proof of life
    led = 1
    pause 500
    led = 0
    Just for my reference and maybe for others interest i tried to check in the manual each of the registers.

    Sorry for not following your instructions. The following is the inc file from your side. I added some comments for my reference only.

    Code:
    '****************************************************************
    '*  Name    : R69.BAS                                           *
    '*  Author  : RICHARD                                           *
    '*  Notice  : Copyright (c) 2019                                *
    '*          : THIS CODE IS NOT CLAIMED TO BE IN ANY WAY         *
    '*          : COMPLIANT WITH RF EMISSION REGULATIONS ANYWHERE   *
    '*          : ON THIS PLANET OR TO BE FIT FOR ANY PURPOSE       *
    '*  Date    : 3/23/2019                                         *
    '*  Version : 1.0                                               *
    '*  Notes   : SIMPLE RFM69 FIXED NODE/PAYLOAD LEN               *
    '*          : NODE=4 BCAST=1    434MHZ                          *
    '****************************************************************
     listen   con $10
     standby  con 4
     BCAST    CON 1
     NODE     CON 4
    ;vars the engine needs
    r69_sdata  var byte  ;BYTE DATA
    r69_tmpa   var word  ;TEMPORARY STORE
    r69_tmpb   var word  ;CMD
    r69_mode   var byte
    r69_rxflg  var byte  ; >0 THEN MESSAGE OR BCAST MESSAGE
    r69_i      var byte  ;INDEX
    r69_dest   var byte  ;DEST
    r69_buff   var byte[17]  ;BUFFER
    
    ';the r69 pins that we use along with sdi,sdo,sck
    ';sdi=miso sdo=mosi 
    'r69_int    var portc.1    ;dio0
    'r69_cs     var lata.5     ;nss
    USERCOMMAND "SETMODE"     ;LISTEN OR STANDBY
    ;USERCOMMAND "SETPOWER"    ;PWR 0-31
    ;USERCOMMAND "SETDEST"    ;NODE OR BCAST
    
    
    
    goto overrfm  ; this is the rfm69 engine there is nothing here for users EXCEPT :-
    ;SEE COMMENTS WHERE NOTED FOR PIC16 USE AND NON H TYPE MODULES
    ;IF YOUR CHIP CANNOT READ ITS FLASH MEMORY OR HAS NO MSSP MODULE TOO BAD
    ;IF YOUR CHIP HAS MULTIPLE MSSP MODULES YOU MAY NEED TO MAKE A FEW TWEAKS RE MSSP REGISTER NAMES
    rfm:
    asm
     dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0x0880
     dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0x2e90  
     dw 0x2fde,0x30ad,0x3166,0x3734,0x3811,0x3904,0x3a01,0x3C8c
     dw 0x6F30 ;NOT FOR PIC16   REM OUT  THIS LINE
    
    GLetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1  
        BANKSEL 0
        endm 
    SETMODE?C  macro MODE
        MOVE?CB  MODE ,_r69_mode     
        L?CALL _r69SetMode   
      endm  
        
     endasm    
    
    r69SendFrame:       ;tx to r69_dest
        r69_tmpb = $0104    ;standby mode
        gosub  r69WriteReg 
        pauseus 800
        r69_tmpb = $2810    ;RegIrqFlags2 0x28 (FifoOverrun) 00010000 = 0x10
                            ;Set when FIFO overrun occurs. (except in Sleep mode)
                            ;Flag(s) and FIFO are cleared when this bit is set. The
                            ;FIFO then becomes immediately available for the next
                            ;transmission / reception.
        GOSUB  r69WriteReg
        r69_tmpb = $2800    ;Status register: FIFO handling flags...
        GOSUB  r69WriteReg  
        r69_tmpb = $2500    ;Mapping of pins DIO0 to DIO3
        GOSUB  r69WriteReg 
        R69_CS = 0
        r69_sdata = $80
        gosub xspi
        r69_sdata=r69_dest
        gosub xspi 
        for r69_i = 0 to 15 
            r69_sdata = r69_buff[r69_i]
            gosub xspi   
        next 
        R69_CS = 1
        r69_tmpb = $010c   ;011 bits 4-2 Transmitter mode (TX)
        GOSUB  r69WriteReg 
        while   !r69_int  : wend
        r69_tmpb = $0104        ;leave module in standbye
        gosub  r69WriteReg     
        pauseus 800
        r69_tmpb = $2540   ;Mapping of pins DIO0 to DIO3
        GOSUB  r69WriteReg 
    return   
    
    xspi: ;spi xfer 
        SSP1CON1.7 = 0
        SSP1BUF = r69_sdata
        while(!SSP1STAT.0) :wend
        r69_sdata = SSP1BUF
        return  
    
    r69WriteReg:   
        R69_CS = 0
        r69_sdata = r69_tmpb.highbyte|$80     ;reg
        gosub xspi
        r69_sdata = r69_tmpb                  ;data
        gosub xspi
        R69_CS = 1   
    return  
    
    r69ReadReg:   
        R69_CS = 0
        r69_sdata = r69_tmpb.highbyte&$7f     ;reg
        gosub xspi
        r69_sdata = 0
        gosub xspi
        R69_CS = 1
        r69_tmpb = r69_sdata                  ;reply
    return 
    
    r69Init:
        @ GLetAddress _rfm ,_r69_tmpa
        R69_CS  = 1 
        SSPCON1 = $21             ;Please place this number back 
        SSPSTAT = $40             ;Please place this number back
        for r69_i = 0 to 24       ; 23 with pic16  24 for pic18
        READCODE r69_tmpa, r69_tmpb
        r69_tmpa = r69_tmpa + 2   ; +1 for pic16 +2 for pic18
        gosub  r69WriteReg
        next
        ;UNCOMMENT FOR  PIC16  ONLY
    '    tmpb = $6F30
    '    gosub writeReg
        gosub r69SetHighpower      ; "H" modules only REM OUT OTHERWISE
        r69_dest  = NODE 
        r69_rxflg = 0
        r69_mode  = standby 
    return  
    
    r69SetHighpower:      ; "H" modules only turns on power amp 
        r69_tmpb = $130F  ;overload current protection 00001111 
        gosub  r69WriteReg
        r69_tmpb = $1200  ;RegPaRamp 00000000 3.4ms
        gosub  r69ReadReg 
        r69_tmpb = r69_tmpb&$1f   ;MSB of the AfcValue, 2ís complement format 
        r69_tmpb = r69_tmpb|$1160 ;RegPaLevel 01100000 Enables PA1, on PA_BOOST pin and Enables PA2, on PA_BOOST pin 
        gosub  r69WriteReg
        r69_tmpb = $5a5d      ;0x5d  +20 dBm mode (high output)
        gosub  r69WriteReg
        r69_tmpb = $5c7c      ;0x7C  +20 dBm mode (high output)
        gosub  r69WriteReg
    return   
    
    r69SetMode:
    r69_tmpb  = $0100|r69_mode       ;set  mode ??? sleep mode?????
    gosub r69writeReg
    pauseus 800    ;rather than interrogate module to see if mode ready  we just give it some time
    return 
    
    r69ReadBuff:
            IF r69_rxflg THEN return
            r69_mode  = standby        
            gosub r69setmode       
            r69_tmpb  = 0
            gosub r69readreg
            r69_rxflg = r69_tmpb
            IF  r69_rxflg THEN             
            r69_i = 0 ;
            while (r69_i<16)
                r69_tmpb = 0
                gosub r69readreg
                r69_buff[r69_i] = r69_tmpb
                r69_i = r69_i+1
            wend 
            endif
            r69_mode = listen       
            gosub r69setmode 
    return       
    ;rfm_setPower:
    ;    tmpb = $1100
    ;    gosub readReg 
    ;    tmpb=tmpb&$e0     
    ;    tmpb = tmpb|pwr     
    ;    tmpb = tmpb|$1100
    ;    dbg =tmpb
    ;    gosub writeReg 
    ;return            
    overrfm:
    Code:
    asm
     dw 0x0104,0x0200,0x0306,0x0483,0x0503,0x06d7,0x076c,0x0840
     dw 0x0900,0x131a,0x1942,0x2540,0x29dc,0x2c00,0x2d05,0x2e90
     dw 0x2fde,0x30ad,0x3163,0x3734,0x3811,0x3904,0x3a01,0x3C8f
     dw 0x6F30  
    ;_____________________________________________________________________________________________________________________
    ;___________________________________ _________________________________________________________________________________|
    ;        |       |                  |       |                                              |                          |   
    ;  dw    |ADDRESS|    Reg Name      | Value |                 Description                  |        Notes             |
    ;________|_______|_________________ |_______|______________________________________________|__________________________|
    ;0x0104 :  0x01  |   RegOpMode      | 0x04  |  Operating modes of the transceiver          |  (Standby mode (STDBY)   |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0200 :  0x02  |   RegDataModul   | 0x00  |  Data operation mode and Modulation settings |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0306 :  0x03  |   RegBitrateMsb  | 0x06  |  Bit Rate setting, Most Significant Bits     |  BitRate (15:8) 19.2kbps |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0483 :  0x04  |   RegBitrateLsb  | 0x83  |  Bit Rate setting, Least Significant Bits    |  BitRate (7:0)  19.2kbps |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0503 :  0x05  |   RegFdevMsb     | 0x03  |  FreqDeviation setting Most Significant Bits |    0x03   60000 (Hz)     |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x06d7 :  0x06  |   RegFdevLsb     | 0xD7  |  FreDeviation setting Least Significant Bits |    0xD7   60000 (Hz)     |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x076c :  0x07  |   RegFrfMsb      | 0x6C  |  RF Carrier Frequency, Most Significant Bits |    0x6C   433   (Mhz)    |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0840 :  0x08  |   RegFrfMid      | 0x40  |  RF Carrier Frequency, Intermediate Bits     |    0x40   433   (Mhz)    |
    ;_____________________________________________________________________________________________________________________|
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x0900 :  0x09  |   RegFrfLsb      | 0x00  |  RF Carrier Frequency Least Significant Bits |    0x00  433   (Mhz)     |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x131a :  0x13  |   RegOcp         | 0x1A  |  Over Current Protection control             |    0x1A RegOCP is ON     |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x1942 :  0x19  |   RegRxBw       |0x86 0x55| Channel Filter BW Control                   |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x2540 :  0x25  | RegDioMapping1   | 0x00  |  Mapping of pins DIO0 to DIO3                |  DIO0 state is TxReady   |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x29dc :  0x29  | RegRssiThresh   |0xFF 0xE4| RSSI Threshold control                      |      Default is E4       |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x2c00 :  0x2C  | RegPreambleMsb   | 0x00  |  Preamble length, MSB                        |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x2d05 :  0x2D  | RegPreambleLsb   | 0x03  |  Preamble length, LSB                        |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x2e90 :  0x2E  | RegSyncConfig    | 0x98  |  Sync Word Recognition control               |                          |
    ;_____________________________________________________________________________________________________________________|
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x2fde :  0x2F  | SyncValue(63:56) | 0x01  |  1st byte of Sync word. (MSB byte)           |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x30ad :  0x30  | SyncValue(55:48) | 0x01  |  2nd byte of Sync word                       |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3163 :  0x31  | SyncValue(47:40) | 0x01  |  3rd byte of Sync word.                      |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3734 :  0x37  | RegPacketConf1   | 0x10  |  Packet mode settings                        |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3811 :  0x38  | RegPayloadLength | 0x40  |  Payload length setting                      |                          |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3904 :  0x39  | RegNodeAdrs      | 0x00  |  Node address                                |    Node : 4              |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3a01 :  0x3A  | RegBroadcastAdrs | 0x00  |  Broadcast address                           |    Boradcast : 1         |
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x3C8f :  0x3C  | RegFifoThresh   |0x0F 0x8F| Fifo threshold, Tx start condition          |                          |
    ;_____________________________________________________________________________________________________________________|
    ;---------------------------------------------------------------------------------------------------------------------|
    ;0x6F30 :  0x6F  | RegTestDagc     |0x00 0x30|  Fading Margin Improvement                  |0x30 use if AfcLowBetaOn=0|
    ;---------------------------------------------------------------------------------------------------------------------|
    
    GLetAddress macro Label, Wout
        CHK?RP Wout
        movlw low Label          ; get low byte
        movwf Wout
        movlw High Label         ; get high byte
        movwf Wout + 1  
        BANKSEL 0
        endm 
     endasm

  21. #61
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,828

    Default Re: Programming RFM radio modules in Basic

    You do have 5 volts Vdd, right?

    Ioannis

  22. #62

    Default Re: Programming RFM radio modules in Basic

    Quote Originally Posted by Ioannis View Post
    You do have 5 volts Vdd, right?

    Ioannis
    Yes i increased from 3.3v to 5.0v.

    I supply the boards with a power supply that has 2 regulated outputs. So i set both at 5.0v.

  23. #63
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,828

    Default Re: Programming RFM radio modules in Basic

    And you programmed both PIC with the firmware Richard posted on #55?

    Ioannis

  24. #64

    Default Re: Programming RFM radio modules in Basic

    Quote Originally Posted by Ioannis View Post
    And you programmed both PIC with the firmware Richard posted on #55?

    Ioannis
    yep the master and the slave. I saved at first the inc file as .bas and compiled succesfully the master and slave.

    I hope didnt burn the radio modules. The only way to find out is to buy two more and try them.

  25. #65
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,828

    Default Re: Programming RFM radio modules in Basic

    Post #59 has the circuit Richard used for the firmware. Double check if it is exactly as yours. Maybe you have mixed MOSI/MISO lines.

    Ioannis

  26. #66

    Default Re: Programming RFM radio modules in Basic

    Quote Originally Posted by Ioannis View Post
    Post #59 has the circuit Richard used for the firmware. Double check if it is exactly as yours. Maybe you have mixed MOSI/MISO lines.

    Ioannis
    in the very beginning i had the SDI to MOSI and SDO to MISO which is wrong. But at that time i have powered up the circuit.

    then i looked more careful the connections and placed them in the right position. SDI to MISO and SDO to MOSI.

    The only indication i have is the test LEDs on both at powr up when they flash once.

    I'll check it out again tomorrow afternoon, and i might but a pair in case those are not working.

  27. #67
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    make sure the rf modules are rfm69hw or hcw , adafruit make a lora rf module on the same pcb but lora needs a vastly different approach
    This is more entertaining than Free to Air TV

  28. #68

    Default Re: Programming RFM radio modules in Basic

    Quote Originally Posted by richard View Post
    make sure the rf modules are rfm69hw or hcw , adafruit make a lora rf module on the same pcb but lora needs a vastly different approach
    Hi Richard i will try once again tonight, if it wont work then i will place an order for one more pair from adafruit and one from sparkfun.

    This is the one i'm using https://www.adafruit.com/product/3071

    The lora version i think is only for the RFM96w as they marked it on the following page. https://www.adafruit.com/product/3073

  29. #69
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    that looks ok

    i prefer to buy them like this and add the footprint to my pcb design, much cheaper
    https://www.ebay.com.au/itm/RFM69HW-...frcectupt=true
    only setback is postal delay from china [2-5 weeks here]
    they are very robust i have not managed to destroy one or have one fail in several years so far.
    its pretty easy to make your own dev board for breadboarding i have several , 3v ones 5v ones , clickboard ones , arduino ones ....

    one more tip, sometimes the modules lockup when you are changing their configs when you reprogram the pic , they need a power cycle to unlock . catches me out sometimes
    This is more entertaining than Free to Air TV

  30. #70

    Default Re: Programming RFM radio modules in Basic

    Hi Richard,

    regarging the power cycle. At the moment i always program the pic on the testboard without using any power supply. Only the power during programming from PICkit2.

    Then i plug the power regulated at 5V. Do i need to restart the module by shorting the Reset pin to ground?

  31. #71

    Default Re: Programming RFM radio modules in Basic

    Somethin i've noticed on the following page https://learn.adafruit.com/adafruit-...akouts/pinouts

    It is not clear to me if all the GIO pins or the rest apart from the GIO0 are not with level shifting.

    In case GIO0 is also with no level shifting then i have connected it from pic's pin with 5V.

    EDITED: ok it is clear the GIO0 it is logic level.

    Name:  rfm69hcwlogiclevel.png
Views: 10
Size:  847.5 KB

  32. #72
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    2,828

    Default Re: Programming RFM radio modules in Basic

    If you did connected them to 5V I am pretty sure it is heading to the recycle bin...

    Ioannis

  33. #73
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    EDITED: ok it is clear the GIO0 it is logic level.
    not according to their schematic , its straight out out the chip. no dio pins are level shifted neither is miso

    dio0 [g0] should only ever be connected to an input pin / the pic is quite happy with a 3.3v logic input.
    this is why i insist that setting pic pins to outputs unless necessary when breadboarding is a bad idea
    Last edited by richard; Today at 11:57.
    This is more entertaining than Free to Air TV

  34. #74

    Default Re: Programming RFM radio modules in Basic

    Based on the following statement the SPI logic pins can be connected either to 3-5V. Is that right? I havent connected anything to the rest of the GIO pins. The only connection is at the GIO0 from GIO pins.

    Name:  rfm69SPI.png
Views: 9
Size:  857.9 KB

  35. #75
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    none of the modules o/p pins are buffered or protected in any way, connect to 5 v outputs at your peril , as the text says pins going into not out of.
    look at the schematic
    https://cdn-learn.adafruit.com/asset...png?1460752861


    while i'm at it. beware of the reset pin . its not what it seems
    7.2.2. Manual Reset
    A manual reset of the RFM69HCW is possible even for applications in which VDD cannot be physically disconnected.
    Pin RESET should be pulled high for a hundred microseconds, and then released. The user should then wait for 5 ms
    before using the module.

    Note whilst pin RESET is driven high, an over current consumption of up to ten milliamps can be seen on VDD.
    Last edited by richard; Today at 12:39.
    This is more entertaining than Free to Air TV

  36. #76

    Default Re: Programming RFM radio modules in Basic

    Regarding the Reset pin i could pull it high via software for 100ms, then pause for 5ms or more and continue.

    Now in order to be on a safe side, i might supply 3.3V the test board, both PIC and radio module.

    I think i will place an order for couple RFM69HCW. At that stage it will be the only way to see whether the ones i have are dead or not.

  37. #77
    Join Date
    May 2013
    Location
    australia
    Posts
    1,611

    Default Re: Programming RFM radio modules in Basic

    Regarding the Reset pin i could pull it high via software for 100ms, then pause for 5ms or more and continue.
    thats 100uS
    This is more entertaining than Free to Air TV

  38. #78

    Default Re: Programming RFM radio modules in Basic

    for waiting there is a command

    Code:
    Pauseus
    ok i'll use that.
    Last edited by astanapane; Today at 13:26.

Similar Threads

  1. basic pic programming
    By sshanmugapriya in forum mel PIC BASIC
    Replies: 0
    Last Post: - 25th February 2010, 06:02
  2. Car radio (Car radio and electronics support forum)
    By freewillover in forum Forum Requests
    Replies: 1
    Last Post: - 1st July 2009, 19:41
  3. Smart Radio RF620A and RF620RA modules
    By Colin612 in forum Serial
    Replies: 0
    Last Post: - 8th May 2008, 15:47
  4. LPRS/miniature radio modules
    By fowardbias in forum Off Topic
    Replies: 1
    Last Post: - 20th September 2005, 01:03
  5. Help With Easy Radio Modules
    By hughgoodbody in forum General
    Replies: 5
    Last Post: - 25th May 2005, 09:14

Members who have read this thread : 36

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts