MRF90XAM9A interfacing help


Closed Thread
Results 1 to 40 of 64

Hybrid View

  1. #1
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    OK, TABSoft -
    I'm having trouble either sending or receiving data.... Thought I had this puppy trained.
    Registers are:
    Code:
    '     RF_Init_Values[0] = $28                                                   'Standby mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[0] = $68                                                   'RECEIVE mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[1] = $8C                                                   'FSK, max IF gain, Packet Mode
         RF_Init_Values[2] = $01                                                   '200KHz Freq Dev
         RF_Init_Values[3] = $63                                                   '2KBps
         RF_Init_Values[4] = $0C                                                   'for OOK mode, not apliable
         RF_Init_Values[5] = $03                                                   '16Bytes FIFO, 3 Bytes threshold FIFO transmit interrupt
         RF_Init_Values[6] = $77                                                   '915MHz R1 Reg
         RF_Init_Values[7] = $64                                                   '915MHz P1 Reg
         RF_Init_Values[8] = $32                                                   '915MHz S1 Reg
         RF_Init_Values[9] = $74                                                   '920MHz R2 Reg
         RF_Init_Values[10] = $62                                                  '920MHz P2 Reg
         RF_Init_Values[11] = $32                                                  '920MHz S2 Reg
         RF_Init_Values[12] = $38                                                  'config mode for OOK, not apliable
         RF_Init_Values[13] = $0D                                                  'RCV:IRQ0=payload ready + IRQ1=CRC OK
                                                                                   'TX: mostly normal
         RF_Init_Values[14] = $19                                                  '00011001
         RF_Init_Values[15] = $00                                                  '
         RF_Init_Values[16] = $A3                                                  'default filters config
         RF_Init_Values[17] = $38                                                  'default filters config
         RF_Init_Values[18] = $30                                                  'sync word ON, 24bits, 0 errors tolerance
         RF_Init_Values[19] = $00                                                  'reserved reg
         RF_Init_Values[20] = $00                                                  'RSII status read register, 0.5dB / bit
         RF_Init_Values[21] = $00                                                  'OOK config reg
         RF_Init_Values[22] = $53                                                  '"S" 1st byte of sync word
         RF_Init_Values[23] = $43                                                  '"C" 2nd byte of sync word
         RF_Init_Values[24] = $53                                                  '"S" 3rd byte of sync word  - my initials!
         RF_Init_Values[25] = $00                                                  '
         RF_Init_Values[26] = $70                                                  'utoff fcy = 200KHz, output power = 13dBm 0b000
         RF_Init_Values[27] = $BC                                                  'clk out by default 427KHz
         RF_Init_Values[28] = $02                                                  '3 bytes payload
         RF_Init_Values[29] = $01                                                  'initial MAC ADDRESS, only for test
         RF_Init_Values[30] = $5E                                                  'Fix Packet Lenght, 3 bytes preamble, whitening ON, CRC ON, Node ADDR|0x00|0xFF filtering
         RF_Init_Values[31] = $00                                                  'FIFO autocreal enable if CRC fails, Write to FIFO in stby mode     for (i = 0; i < 32; i++)
    And test code is:
    Code:
    'MRF initialization here
    debug "@ MRF init", 10
                MRFConfigSel=0                                                      'Select the chip       
    'Going to try using shiftout before using hardware SPI
                for i=0 to 31                                                       'Sets up the index var for data
                    MRFaddr=(i << 1)                                                'Shifts address 1 bit to left, automatically gets start,write, and stop bits      
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)]               'send data to register
    debug "Addr=",bin8 MRFaddr,"  Value=",hex2 RF_Init_Values[i],13
                next i    
                MRFConfigSel=1                                                      'Deselect the chip
    
    'Try to read back some registers as a test to see if they were written correctly            
                MRFConfigSel=0                                                      'Select the chip 
                for i = 0 to 7                                                      'Sets up address to read
                    MRFaddr=((i << 1) | $40)                                       'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read
                    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                    debug "MRF Config data: i=", dec1 i, "   Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                next i
    
    'Try sending something
    debug "Try sending 3 bytes",13
    XMIT_EN:   i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$88]                                 'send data, TRANSMIT, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    XMIT:      MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$A1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$B1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$C1]
               MRFDataSel=1
               
    RCV:       i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$68]                                 'send data, RECEIVE, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    Wait4Pkt:  If MRFIrq0=1 and MRFIrq1=1 then
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data3,data2,data1]                              'Get data from reg   
    debug "MRF payload:  Data3=",hex2 data3,"   Data2=",hex2 data2,"   Data1=",hex2 data1,13
               endif
               goto Wait4Pkt
    But after init and the confirming of the 1st few registers as before - it just sits there like a plum.

    I seem to have the config registers working, but now the FIFO seems to be playing hard.
    My interrupts aren't being set either due to not transmitting or receiving correctly.
    My payload is only 3 bytes, and the smallest the FIFO can be is 16 bytes.
    Not much for me to scope on this...... MC's DS is not too clear but you honed in on a failure I had, do you see anything wrong?
    This is my 1st RF project so I may have the registers all screwed up in order to work.... not too much out there as a guide.
    Regards.
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  2. #2
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Sorry, I had posted an older piece of code. Newest code below:
    Code:
    'MRF initialization here
    debug "@ MRF init", 10
                MRFConfigSel=0                                                      'Select the chip       
    'Going to try using shiftout before using hardware SPI
                for i=0 to 31                                                       'Sets up the index var for data
                    MRFaddr=(i << 1)                                                'Shifts address 1 bit to left, automatically gets start,write, and stop bits      
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)]               'send data to register
    debug "Addr=",bin8 MRFaddr,"  Value=",hex2 RF_Init_Values[i],13
                next i    
                MRFConfigSel=1                                                      'Deselect the chip
    
    'Try to read back some registers as a test to see if they were written correctly            
                MRFConfigSel=0                                                      'Select the chip 
                for i = 0 to 7                                                      'Sets up address to read
                    MRFaddr=((i << 1) | $40)                                       'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read
                    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                    debug "MRF Config data: i=", dec1 i, "   Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                next i
    
    'Try sending something
    debug "Try sending 3 bytes",13
    XMIT_EN:   i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$88]                                 'send data, TRANSMIT, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    XMIT:      MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$A1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$B1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$C1]
               MRFDataSel=1
               
    RCV:       i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$68]                                 'send data, RECEIVE, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    Wait4Pkt:  If MRFIrq0=1 and MRFIrq1=1 then
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data3]                                     'Get data from reg   
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data2]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data1]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
    debug "MRF payload:  Data3=",hex2 data3,"   Data2=",hex2 data2,"   Data1=",hex2 data1,13
               endif
               goto Wait4Pkt
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  3. #3
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Can you help me with your setup and test bed, a pic or drawing?
    Do you have 2 of these transceivers with 2 pics trying to talk to one another?

    I would like to get my head wrapped around that 1st.
    Regards,
    TABSoft

  4. #4
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Thanks TABSoft-
    The setup is I have 2 units which should be the same (I have checked pinouts on PCB but I have made many cut and re-eoutes). Both units are running same code as shown earlier;
    1. Units powerup - sets registers and programming fuses
    Code:
    'RF Section:
    'Transmit is by fixed packet length of 3 bytes; Adress byte (2) and a Message byte.
    'Packet looks like: 3-byte preamble       -      3-byte Sync Word - 2-byte Address  - 1-byte Message -        2-byte CRC
    '                  |(added by pkt handler)|          'SCS'        |       (provided by code)         | (added by pkt handler)
    'Everything but the 3-byte payload is processed on receive and removed........
    
    'PIC is PIC18F66J11
    'Using PBP3 GOLD 3.0.7.0
    'Microcode Studio Plus 5.0.0.5
    #CONFIG
        CONFIG  WDTEN = OFF           ; WDT NOT enabled
        CONFIG  STVREN = ON           ; Reset on stack overflow/underflow enabled
        CONFIG  XINST = OFF           ; Instruction set extension and Indexed Addressing mode disabled (Legacy mode)
        CONFIG  DEBUG = OFF           ; Background debugger disabled; RB6 and RB7 configured as general purpose I/O pins
        CONFIG  CP0 = OFF             ; Program memory is not code-protected
        CONFIG  FOSC = INTOSC	  ; Internal oscillator, port function on RA6 and RA7 
    ;    CONFIG  FOSC = INTOSCPLL	  ; INTOSC with PLL enabled, port function on RA6 and RA7
        CONFIG  FCMEN = OFF           ; Fail-Safe Clock Monitor disabled
        CONFIG  IESO = OFF            ; Two-Speed Start-up disabled
        CONFIG  WDTPS = 512           ; 1:512
        CONFIG  CCP2MX = DEFAULT      ; ECCP2/P2A is multiplexed with RC1
        CONFIG  MSSPMSK = MSK7        ; 7-Bit Address Masking mode enable
    #ENDCONFIG
    Asm
        ERRORLEVEL -306
    Endasm
    '---------------------------------------------------------------------------------------
    'Define the oscillator, INCLUDE files, A2D setup
        DEFINE  OSC 8					'8 MHz oscillator, internal x 4 via PLL = 32MHz  
        include "modedefs.bas"
        INCLUDE "DT_INTS-18.bas"                                                    'Base Interrupt System
        INCLUDE "ReEnterPBP-18.bas"                                                 'Include if using PBP interrupts
    '    DEFINE RX2_INT PIR4,RC2IF,PIE4,RC2IE                'Used to ADD the 2nd serial port to the interrupt scheme
    
    '---------------------------------------------------------------------------------------
    'OKAY, Lets set up the registers.....
        OSCCON=%01110000                                                            'Sleep mode when sleep instr, 8MHz, System clock is via CONFIG BITS
    '    OSCTUNE.6=1                                         'PLL ENABLED
    '---------------------------------------------------------------------------------------
    'Direction registers
        TRISA = %00001001                                                           'Set PORTA for mixed
        TRISB = %11011111                                                           'PORTB is INPUT, except for RB5 
        TRISC = %10010011                                                           'Mixed 
        TRISD = %00101110                                                           'Mixed
        TRISE = %00000000                                                           'Set PORTE for all OUTPUTS
        TRISF = %11111000                                                           'Set PORTF for use with comparitor direction  
        TRISG = %10000000                                                           'Set PORTG for all OUTPUTS, PORTD pullups ENABLED   
    '----------------------------------------------------------------------------------------
    2. Setup debug stuff
    Code:
        DEFINE DEBUG_REG    PORTC
        DEFINE DEBUG_BIT    6
        DEFINE DEBUG_BAUD   38400
        DEFINE DEBUG_MODE   0
    3. Setup I/O, aliases, vars, and constants
    Code:
            SDO             var PORTC.5
            SDI             var PORTC.4
            SCLK            var PORTC.3
            Active          var PORTD.0                                             'Active LED, Active LOW
            MRFReset        var PORTA.1                                             'MRF module reset
            MRFDataSel      var PORTA.4                                             'MRF module serial interface data chip select, active LOW
            MRFConfigSel    var PORTA.5                                             'MRF module serial interface configure chip select, active LOW
            MRFIrq0         var PORTB.0                                             'MRF module interupt 0
            MRFIrq1         var PORTC.2                                             'MRF module interupt 1
    'Variable List
            i               var byte  
            RF_Init_Values  var byte[32]                                            'An array to initialize the RF unit
            MRFSPIdata      var byte                                                'Data to/from MRF module
            MRFregister     var byte                                                'MRF register we want to read/write
            MRFaddr         var byte                                                'MRF address which is 5 bytes
            I2CData         var byte                                                'Data byte to/from I2C buffer
            junk            var byte                                                'Hold dummy data from MRF
            data1           var byte                                                '1st byte from MRF payload
            data2           var byte                                                '2nd byte from MRF payload
            data3           var byte                                                '3rd byte from MRF payload
    '------------------------------------------------------------------------------------------
    'Constants here
    '     RF_Init_Values[0] = $28                                                   'Standby mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[0] = $68                                                   'RECEIVE mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[1] = $8C                                                   'FSK, max IF gain, Packet Mode
         RF_Init_Values[2] = $01                                                   '200KHz Freq Dev
         RF_Init_Values[3] = $63                                                   '2KBps
         RF_Init_Values[4] = $0C                                                   'for OOK mode, not apliable
         RF_Init_Values[5] = $03                                                   '16Bytes FIFO, 3 Bytes threshold FIFO transmit interrupt
         RF_Init_Values[6] = $77                                                   '915MHz R1 Reg
         RF_Init_Values[7] = $64                                                   '915MHz P1 Reg
         RF_Init_Values[8] = $32                                                   '915MHz S1 Reg
         RF_Init_Values[9] = $74                                                   '920MHz R2 Reg
         RF_Init_Values[10] = $62                                                  '920MHz P2 Reg
         RF_Init_Values[11] = $32                                                  '920MHz S2 Reg
         RF_Init_Values[12] = $38                                                  'config mode for OOK, not apliable
         RF_Init_Values[13] = $0D                                                  'RCV:IRQ0=payload ready + IRQ1=CRC OK
                                                                                   'TX: mostly normal
         RF_Init_Values[14] = $39                                                  '00111001
         RF_Init_Values[15] = $00                                                  '
         RF_Init_Values[16] = $A3                                                  'default filters config
         RF_Init_Values[17] = $38                                                  'default filters config
         RF_Init_Values[18] = $30                                                  'sync word ON, 24bits, 0 errors tolerance
         RF_Init_Values[19] = $00                                                  'reserved reg
         RF_Init_Values[20] = $00                                                  'RSII status read register, 0.5dB / bit
         RF_Init_Values[21] = $00                                                  'OOK config reg
         RF_Init_Values[22] = $53                                                  '"S" 1st byte of sync word
         RF_Init_Values[23] = $43                                                  '"C" 2nd byte of sync word
         RF_Init_Values[24] = $53                                                  '"S" 3rd byte of sync word  - my initials!
         RF_Init_Values[25] = $00                                                  '
         RF_Init_Values[26] = $70                                                  'utoff fcy = 200KHz, output power = 13dBm 0b000
         RF_Init_Values[27] = $BC                                                  'clk out by default 427KHz
         RF_Init_Values[28] = $02                                                  '3 bytes payload
         RF_Init_Values[29] = $01                                                  'initial MAC ADDRESS, only for test
         RF_Init_Values[30] = $5E                                                  'Fix Packet Lenght, 3 bytes preamble, whitening ON, CRC ON, Node ADDR|0x00|0xFF filtering
         RF_Init_Values[31] = $00                                                  'FIFO autocreal enable if CRC fails, Write to FIFO in stby mode     for (i = 0; i < 32; i++)
    4. MRF initialization
    Code:
    'MRF initialization here
    debug "@ MRF init", 10
                MRFConfigSel=0                                                      'Select the chip       
    'Going to try using shiftout before using hardware SPI
                for i=0 to 31                                                       'Sets up the index var for data
                    MRFaddr=(i << 1)                                                'Shifts address 1 bit to left, automatically gets start,write, and stop bits      
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)]               'send data to register
    debug "Addr=",bin8 MRFaddr,"  Value=",hex2 RF_Init_Values[i],13
                next i    
                MRFConfigSel=1                                                      'Deselect the chip
    
    'Try to read back some registers as a test to see if they were written correctly            
                MRFConfigSel=0                                                      'Select the chip 
                for i = 0 to 7                                                      'Sets up address to read
                    MRFaddr=((i << 1) | $40)                                       'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read
                    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                    debug "MRF Config data: i=", dec1 i, "   Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                next i
    5. Then I try to send something via MRF
    Code:
    'Try sending something
    debug "Try sending 3 bytes",13
    XMIT_EN:   i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$88]                                 'send data, TRANSMIT, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    XMIT:      MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$A1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$B1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$C1]
               MRFDataSel=1
    6. Then MRF switches to receive to try to receive the 3 bytes (from the other unit of course).
    Code:
    RCV:       i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$68]                                 'send data, RECEIVE, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    Wait4Pkt:  If MRFIrq0=1 and MRFIrq1=1 then
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data3]                                     'Get data from reg   
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data2]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data1]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
    debug "MRF payload:  Data3=",hex2 data3,"   Data2=",hex2 data2,"   Data1=",hex2 data1,13
               endif
               goto Wait4Pkt
    My method is this:
    I turn on both units and watch for debug information.
    At this time both units should be in receive mode - not very helpful.
    So then I reset one of the units which will make it go through everything again including transmit the 3 bytes.
    Nothing comes up on the debug window.
    No interrupt gets set
    I do see IRQ1 (I think - from memory) go high briefly on the transmitting unit which should be transmission done.

    I think its in my NOT understanding the transmission/reception registers - I'm more of a digi-head with some analog.
    The DS is not too helpful and the Microchip boards and forum are also not very helpful.
    Most of the work seems to be using the 2.4 GHz unit but I wanted to use the sub-ghz unit due to my desire to go throughout the house.

    You can PM instead of taking up forum space, I will post my final code using hardware SPI and working code for the MRF - as I am certain there HAS to be others struggling!

    Regards.
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  5. #5
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I have a few ideas but let me have a day or two to noodle through it.
    Regards,
    TABSoft

  6. #6
    Join Date
    Sep 2007
    Location
    Waco, Texas
    Posts
    151


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I changed some of the register settings after re-reading the DS for a gazillion-ith time still no luck. I do get an IRQ0 pulse now, but I don't think I set it??
    Slightly modified code for continuous xmit and receive (different code for the 2 units).
    Code and registers below:
    Code:
    'Constants here
    '     RF_Init_Values[0] = $28                                                   'Standby mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[0] = $68                                                   'RECEIVE mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[1] = $8C                                                   'FSK, max IF gain, Packet Mode
         RF_Init_Values[2] = $03                                                   '100KHz Freq Dev
         RF_Init_Values[3] = $07                                                   '25 KBps
         RF_Init_Values[4] = $0C                                                   'for OOK mode, not apliable
         RF_Init_Values[5] = $0F                                                   '16Bytes FIFO, 
         RF_Init_Values[6] = $77                                                   '915MHz R1 Reg
         RF_Init_Values[7] = $64                                                   '915MHz P1 Reg
         RF_Init_Values[8] = $32                                                   '915MHz S1 Reg
         RF_Init_Values[9] = $74                                                   '920MHz R2 Reg
         RF_Init_Values[10] = $62                                                  '920MHz P2 Reg
         RF_Init_Values[11] = $32                                                  '920MHz S2 Reg
         RF_Init_Values[12] = $38                                                  'config mode for OOK, not apliable
         RF_Init_Values[13] = $08                                                  'RCV:IRQ0=payload ready + IRQ1=CRC OK
                                                                                   'TX: IRQ1=TXdone
         RF_Init_Values[14] = $35                                                  'FIFO starts filling when SYNC detected,TXDONE goes hi when done,
                                                                                   'RSSI IRQ when is above level set, enable PLL lock
         RF_Init_Values[15] = $00                                                  'RSSI interupt level zero - minimum
         RF_Init_Values[16] = $A3                                                  'default filters config
         RF_Init_Values[17] = $38                                                  'default filters config
         RF_Init_Values[18] = $30                                                  'sync word ON, 24bits, 0 errors tolerance
         RF_Init_Values[19] = $07                                                  'reserved reg
         RF_Init_Values[20] = $00                                                  'RSII status read register, 0.5dB / bit
         RF_Init_Values[21] = $00                                                  'OOK config reg
         RF_Init_Values[22] = $53                                                  '"S" 1st byte of sync word
         RF_Init_Values[23] = $43                                                  '"C" 2nd byte of sync word
         RF_Init_Values[24] = $53                                                  '"S" 3rd byte of sync word  - my initials!
         RF_Init_Values[25] = $00                                                  '
         RF_Init_Values[26] = $70                                                  'Cutoff fcy = 200KHz, output power = 13dBm 0b000
         RF_Init_Values[27] = $BC                                                  'clk out by default 427KHz
         RF_Init_Values[28] = $03                                                  '3 bytes payload
         RF_Init_Values[29] = $01                                                  'initial MAC ADDRESS, only for test
         RF_Init_Values[30] = $5E                                                  'Fix Packet Lenght, 3 bytes preamble, whitening ON, CRC ON, Node ADDR|0x00|0xFF filtering
         RF_Init_Values[31] = $80                                                  'FIFO autocreal enable if CRC fails, Write to FIFO in stby mode 
    
    'MRF initialization here
    debug "@ MRF init", 10
                MRFConfigSel=0                                                      'Select the chip       
    'Going to try using shiftout before using hardware SPI
                for i=0 to 31                                                       'Sets up the index var for data
                    MRFaddr=(i << 1)                                                'Shifts address 1 bit to left, automatically gets start,write, and stop bits      
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)]               'send data to register
    debug "Addr=",bin8 MRFaddr,"  Value=",hex2 RF_Init_Values[i],13
                next i    
                MRFConfigSel=1                                                      'Deselect the chip
    
    'Try to read back some registers as a test to see if they were written correctly            
                MRFConfigSel=0                                                      'Select the chip 
                for i = 0 to 7                                                      'Sets up address to read
                    MRFaddr=((i << 1) | $40)                                       'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read
                    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                    debug "MRF Config data: i=", dec1 i, "   Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                next i
    
    'Try sending something
    debug "Try sending 3 bytes",13
    XMIT_EN:   i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$88]                                 'send data, TRANSMIT, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    XMIT:      MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$A1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$B1]
               MRFDataSel=1
               MRFDataSel=0
               SHIFTOUT SDO, SCLK, 1,[$C1]
               MRFDataSel=1
               
               i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$28]                                 'STANDBY, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
    
    '           goto XMIT_EN                                                        'Remark this line to be receive all the time, otherwise its xmitting all the time
    
    RCV:       i=0                                                                 'Register of interest
               MRFaddr=(i<<1)                                                      'Gets register address format
               MRFConfigSel=0                                                      'Select the chip
               SHIFTOUT SDO, SCLK, 1,[MRFaddr,$68]                                 'send data, RECEIVE, 915-928, Vtune by tank caps, Enable R1 P1 S1
               MRFConfigSel=1                                                      'Deselect the chip
               
    Wait4Pkt:  If MRFIrq0=1 and MRFIrq1=1 then
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data3]                                     'Get data from reg   
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data2]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
                  MRFDataSel=0                                                     'Select chip cuz we have a packet ready and CRC is good
                  SHIFTIN SDI, SCLK, 0,[data1]                                     'Get data from reg  
                  MRFDataSel=1                                                     'De-Select chip
    debug "MRF payload:  Data3=",hex2 data3,"   Data2=",hex2 data2,"   Data1=",hex2 data1,13
               endif
               goto Wait4Pkt
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

  7. #7
    Join Date
    Jan 2013
    Location
    Texas USA
    Posts
    229


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I went through the datasheet again, and again.
    I also went through Microchips MRF Radiodriver software source code, link here.

    Here is what I put together, see if this helps at all.......

    Code:
         RF_Init_Values[0] = $28                                                   'Standby mode, 915-928 MHz, VTune by inductors, ENABLE R1/P1/S1
         RF_Init_Values[1] = $8C                                                   'FSK, max IF gain, Packet Mode
         RF_Init_Values[2] = $0B                                                   'Change from 200KHz Freq Dev to 33KHz Dev
         RF_Init_Values[3] = $63                                                   '2KBps
         RF_Init_Values[4] = $0C                                                   'for OOK mode, not apliable
         RF_Init_Values[5] = $03                                                   '16Bytes FIFO, 3 Bytes threshold FIFO transmit interrupt
         RF_Init_Values[6] = $77                                                   '915MHz R1 Reg
         RF_Init_Values[7] = $64                                                   '915MHz P1 Reg
         RF_Init_Values[8] = $32                                                   '915MHz S1 Reg
         RF_Init_Values[9] = $74                                                   '920MHz R2 Reg
         RF_Init_Values[10] = $62                                                  '920MHz P2 Reg
         RF_Init_Values[11] = $32                                                  '920MHz S2 Reg
         RF_Init_Values[12] = $38                                                  'config mode for OOK, not apliable
         RF_Init_Values[13] = $08                                                  'PLREADY, CRCOK, TXDONE, FIFO Not Full, FIFO Empty, No FIFO Overrun
                                                                                   'TX: mostly normal
         RF_Init_Values[14] = $0B                                                  '00111001
         RF_Init_Values[15] = $00                                                  '
         RF_Init_Values[16] = $41                                                  'default filters config
         RF_Init_Values[17] = $38                                                  'default filters config
         RF_Init_Values[18] = $30                                                  'sync word ON, 24bits, 0 errors tolerance
         RF_Init_Values[19] = $07                                                  'reserved reg
         RF_Init_Values[20] = $00                                                  'RSII status read register, 0.5dB / bit
         RF_Init_Values[21] = $00                                                  'OOK config reg
         RF_Init_Values[22] = $53                                                  '"S" 1st byte of sync word
         RF_Init_Values[23] = $43                                                  '"C" 2nd byte of sync word
         RF_Init_Values[24] = $53                                                  '"S" 3rd byte of sync word  - my initials!
         RF_Init_Values[25] = $00                                                  '
         RF_Init_Values[26] = $F0                                                  'utoff fcy = 200KHz, output power = 13dBm 0b000
         RF_Init_Values[27] = $80                                                  'clk out by default 427KHz
         RF_Init_Values[28] = $03                                                  '3 bytes payload
         RF_Init_Values[29] = $01                                                  'initial MAC ADDRESS, only for test
         RF_Init_Values[30] = $4E                                                  'Fix Packet Lenght, 3 bytes preamble, whitening ON, CRC ON, Node ADDR|0x00|0xFF filtering
         RF_Init_Values[31] = $00                                                  'FIFO autocreal enable if CRC fails, Write to FIFO in stby mode     for (i = 0; i < 32; i++)
        
    RF_STANDBY     con $20      'Standby RF Mode     
    RF_SYNTHESIZER con $40      'Synthesizer Mode (Test if RF Module is on and PLL Locked and working)
    RF_RECEIVER    con $60      'Receive Mode
    RF_TRANSMITTER con $80      'Transmit Mode
    
    TxPacket var byte[16]   'Packet Buffer
    bRF_Mode var byte       'Used to set RF Mode
    RF_Mode var byte
    wr_FIFO_Val var byte    'byte to load into RF FIFO
    bReg_Address var byte   'byte for which register to set/read
    bReg_Value var byte     'Value of register to set/read
    TxPacketLen var byte    'Number of bytes to send
    i var byte    
    PLL_LOCK var bit        'Bit to read PLL Lock Flag
    
    
    TestMe:
        gosub MRFInint
        TxPacket[0] = $A1
        TxPacket[1] = $B1
        TxPacket[2] = $C1
        TxPacketLen = 3
        gosub Send_Packet
        bRF_Mode = RF_STANDBY
        gosub SetRFMode
    
        goto RCV    'This is a jump to your receive routine
        
    MRFInit:
    'Initialize the MRF Module
        'Intial setup
        for i = 0 to 31
            bReg_Address = i
            bReg_Value = RF_Init_Values(i)
            gosub RegisterSet    
        next i
    
        'Test the module setup
        'Clear the PLL Lock flag by setting LSTLPLL to 1
        bReg_Address = $0E  'FTPRIREG
        gosub RegisterRead
        bReg_Value = bReg_Value | $02   'Set LSTLPLL to 1
        gosub RegisterSet   'Clear the flag
        
        'Enable Synthesizer mode and test LSTSPLL stays at 1 (PLL Locked)
        bRF_Mode = RF_SYNTHESIZER
        gosub SetRFMode
    
        'Verify PLL Lock Flag
        bReg_Address = $0E  'FTPRIREG
        gosub RegisterRead
        PLL_LOCK = 0
        PLL_LOCK = bReg_Value.1
        'You can test this bit to see if PLL Is Locked
        
        'Change to Standby  
        bRF_Mode = RF_STANDBY
        gosub SetRFMode
        
        return
    
    Send_Packet:
        
        'Set Standby mode
        bRF_Mode = RF_STANDBY
        gosub SetRFMode
        
        'Enable FIFO access in Standby mode
        bReg_Address = $1F  'Register 31
        bReg_Value = (RF_Init_Values(bReg_Address) & $BF) | $00
        gosub RegisterSet
        
        'Clear FIFO Overrun
        bReg_Address = $0D  'Register 13
        bReg_Value = (RF_Init_Values(bReg_Address) | $01)
        gosub RegisterSet
        
        'Set PLL Locked
        bReg_Address = $0E  'Register 13
        bReg_Value = (RF_Init_Values(bReg_Address) | $02)
        gosub RegisterSet
        
        For i = 0 to (TxPacketLen-1)
            'Wite the Packets to the FIFO
            wr_FIFO_Val = TxPacket[i]
            gosub WriteFIFO
        Next i 
       
        'Set RFMode to Transmit
        bRF_Mode = RF_TRANSMITTER
        gosub SetRFMode
        pause 5 'Pause 5ms
        
        return
            
    WriteFIFO:
    'Inputs: wr_FIFO_Val
        
        MRFDataSel=0                
        SHIFTOUT SDO, SCLK, 1,[wr_FIFO_Val] 
        MRFDataSel=1                
    
        return
        
    SetRFMode:
    ' Inputs bRF_Mode
        'SetRFMode(RF_STANDBY); (mcparam0_read & 0x1F) | RF_STANDBY) = (6E & 1F) | 20 = 2E
        bReg_Address = $00  'MCPARAM0
        gosub RegisterRead
        mcparam0_read = bReg_Value
        bReg_Value = (bReg_Value & $1F) | bRF_Mode
        bReg_Address = $00
        gosub RegisterSet
        RF_Mode = bRF_Mode
    
    
        return
        
        
        
    RegisterSet:
    'Inputs: bReg_Address, bReg_Value
        MRFaddr=(bReg_Address<<1)                                           'Gets register address format
        MRFConfigSel=0                                                      'Select the chip
        SHIFTOUT SDO, SCLK, 1,[MRFaddr,bReg_Value]                          'Set the register
        MRFConfigSel=1                                                      'Deselect the chip
     
        
        return
        
    RegisterRead:
    'Inputs: bReg_Address
    'Outputs: bReg_Value
        
        MRFaddr = ((bReg_Address << 1) | $40)               'Shifts left 1 bit, sets $40 bit, automatically gets start, READ, and stop bits         
        MRFConfigSel = 0                                    'Select the chip
        SHIFTOUT SDO, SCLK, 1,[MRFaddr]                     'Address to read
        SHIFTIN SDI, SCLK, 0,[bReg_Value]                   'Get data from reg
        MRFConfigSel = 1                                    'DeSelect the chip
        
        return
    Regards,
    TABSoft

Similar Threads

  1. Interfacing LC75854
    By MR2010 in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 18th July 2010, 02:42
  2. Keypad Interfacing
    By uaf5000 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th June 2010, 02:35
  3. Interfacing with the ISD4003
    By lerameur in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd June 2008, 15:25
  4. SPI Interfacing
    By toofastdave in forum Serial
    Replies: 8
    Last Post: - 18th November 2007, 11:15
  5. interfacing LCD
    By husakhalid in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 22:53

Members who have read this thread : 0

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