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

    Thanks for the continued interest - I will share code with all when the darn thing works <grin>.
    the IO assignments below:
    Code:
            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
    I have the time to work on this now (at home) so I will try just readinga register back - no loops.
    "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

    OK, I have added the base read-back as you suggested, 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            
                MRFaddr=$40
                MRFConfigSel=0                                                      'Select the chip 
                SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read  
                SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                MRFConfigSel=1                                                      'Deselect the chip
    debug "MRF Config data:  Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                pause 50
                MRFaddr=$41
                MRFConfigSel=0                                                      'Select the chip 
                SHIFTOUT SDO, SCLK, 1,[MRFaddr]                                'Address to read  
                SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                              'Get data from reg
                MRFConfigSel=1                                                      'Deselect the chip
    debug "MRF Config data:  Register ", bin8 MRFaddr, "   Data=", hex2 MRFSPIdata,13
    Still doesn't read back. Debug data below:
    Code:
    @ MRF init
    Addr=00000000  Value=28
    Addr=00000010  Value=8C
    Addr=00000100  Value=01
    Addr=00000110  Value=63
    Addr=00001000  Value=0C
    Addr=00001010  Value=03
    Addr=00001100  Value=77
    Addr=00001110  Value=64
    Addr=00010000  Value=32
    Addr=00010010  Value=74
    Addr=00010100  Value=62
    Addr=00010110  Value=32
    Addr=00011000  Value=38
    Addr=00011010  Value=00
    Addr=00011100  Value=19
    Addr=00011110  Value=00
    Addr=00100000  Value=A3
    Addr=00100010  Value=38
    Addr=00100100  Value=30
    Addr=00100110  Value=00
    Addr=00101000  Value=00
    Addr=00101010  Value=00
    Addr=00101100  Value=53
    Addr=00101110  Value=59
    Addr=00110000  Value=44
    Addr=00110010  Value=00
    Addr=00110100  Value=70
    Addr=00110110  Value=BC
    Addr=00111000  Value=02
    Addr=00111010  Value=01
    Addr=00111100  Value=5E
    Addr=00111110  Value=00
    MRF Config data:  Register 01000000   Data=00
    
    MRF Config data:  Register 01000001   Data=00
    Still getting all zeros......... what am I missing?
    BTW, where in Texas are you?
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I do have a question, in the timing diagram below:

    Name:  MRF90XAM9A SPI timing.png
Views: 4764
Size:  149.8 KB

    It looks to me as if there is a dummy byte before the real data, am I confusing myself?
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I guess I don't see what you're referring to "dummy byte before the real data".
    Where specifically are you speaking of?
    Regards,
    TABSoft

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I've got it. And I am dumb guy. In my design for a wireless sensor for the house, I have the 3.3 rail turned OFF when it is charging - I thought it might be a good idea not to turn on the transmitter while I was re-charging it........
    Well, while I am building/designing this, I ALWAYS HAD THE POWER SUPPLY ON, thus, turning OFF the B+ to the MRF - Dumb, Dumb, Dumb.
    OK, with code being the same, what I get is

    Code:
    @ MRF init
    Addr=00000000  Value=28
    Addr=00000010  Value=8C
    Addr=00000100  Value=01
    Addr=00000110  Value=63
    Addr=00001000  Value=0C
    Addr=00001010  Value=03
    Addr=00001100  Value=77
    Addr=00001110  Value=64
    Addr=00010000  Value=32
    Addr=00010010  Value=74
    Addr=00010100  Value=62
    Addr=00010110  Value=32
    Addr=00011000  Value=38
    Addr=00011010  Value=00
    Addr=00011100  Value=19
    Addr=00011110  Value=00
    Addr=00100000  Value=A3
    Addr=00100010  Value=38
    Addr=00100100  Value=30
    Addr=00100110  Value=00
    Addr=00101000  Value=00
    Addr=00101010  Value=00
    Addr=00101100  Value=53
    Addr=00101110  Value=59
    Addr=00110000  Value=44
    Addr=00110010  Value=00
    Addr=00110100  Value=70
    Addr=00110110  Value=BC
    Addr=00111000  Value=02
    Addr=00111010  Value=01
    Addr=00111100  Value=5E
    Addr=00111110  Value=00
    MRF Config data:  Register 01000000   Data=28
    
    MRF Config data:  Register 01000001   Data=28
    Which looks like the same date being read from Register zero.......
    Now armed with this knowledge, moving forward??
    "If we knew what we were doing, it wouldn't be called research"
    - Albert Einstein

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Back to cooking with gas........
    Code as was before:
    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
    And the debug output:
    Code:
    @ MRF init
    Addr=00000000  Value=28
    Addr=00000010  Value=8C
    Addr=00000100  Value=01
    Addr=00000110  Value=63
    Addr=00001000  Value=0C
    Addr=00001010  Value=03
    Addr=00001100  Value=77
    Addr=00001110  Value=64
    Addr=00010000  Value=32
    Addr=00010010  Value=74
    Addr=00010100  Value=62
    Addr=00010110  Value=32
    Addr=00011000  Value=38
    Addr=00011010  Value=00
    Addr=00011100  Value=19
    Addr=00011110  Value=00
    Addr=00100000  Value=A3
    Addr=00100010  Value=38
    Addr=00100100  Value=30
    Addr=00100110  Value=00
    Addr=00101000  Value=00
    Addr=00101010  Value=00
    Addr=00101100  Value=53
    Addr=00101110  Value=59
    Addr=00110000  Value=44
    Addr=00110010  Value=00
    Addr=00110100  Value=70
    Addr=00110110  Value=BC
    Addr=00111000  Value=02
    Addr=00111010  Value=01
    Addr=00111100  Value=5E
    Addr=00111110  Value=00
    MRF Config data: i=0   Register 01000000   Data=28
    MRF Config data: i=1   Register 01000010   Data=8C
    MRF Config data: i=2   Register 01000100   Data=01
    MRF Config data: i=3   Register 01000110   Data=63
    MRF Config data: i=4   Register 01001000   Data=0C
    MRF Config data: i=5   Register 01001010   Data=03
    MRF Config data: i=6   Register 01001100   Data=77
    MRF Config data: i=7   Register 01001110   Data=64
    Which matches perfectly.

    I did scope the data in, out and noticed the pulses were not right at all.
    Then double-check the schematic and board to the datasheets - cuz, you know sometimes there is a mistake.........
    I appreciate your help, your going back to basics post was done after I had done it so we think alike - I am just DUMB!

    Your help in finding the correct way to address the registers was of immense help, I just missed that one completely.
    I'm off to the races, well, off to get the code for a wireless smart sensor system for the house.......
    When working, will post code to help others.

    Regards.
    "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

    Okay! Now you're starting to cook.

    Stick with just reading the 1st two config registers 00-01($40/$41), but reset your MRFSPIdata to a known value between the two reads.
    Read register 00
    display data out to debug port.
    MRFSPIdata = $BE (or some other value besides $28, $FF, $00, etc)
    Read register 01
    display data out to debug port.
    Regards,
    TABSoft

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Looks like we cross-posted.

    Glad you moving forward now.
    Hope to see your final version when you have it working.
    Regards,
    TABSoft

  9. #9
    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

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I'm in the Houston Area.

    I'm not sure, but it looks like from your posting this is still part of a larger program.
    When I am faced with this kind of issue, I go back to square 1.
    Create a new program with only the absolute minimum in it.

    MCU Config Fuses
    Only the VARS needed for this operation (Reading the MRF registers and printing out to the Debug serial port).
    TRIS, ADCON, etc for only the pins for the above operation.
    Disable the PIC modules correctly.
    Aliases only for the SPI pins and the debug pins.
    NO Interrupt handling at all. If you are using DT Interrupts, don't do it now.

    Do not try to write to the MRF Config registers, only try to read from them after POR + 10ms minimum.

    I mean BASIC functionality only.
    No ADC, No Interrupts, no nothing.

    You are having a fundamental issue just trying to read from the device.

    Do you have a logic probe or OScope?
    If so, monitor the CSCON line and make sure it is going low as it should.
    Monitor the SCK and SDI (on the MRF) to make sure it is being pulsed by the PIC.

    Also, and I am not trying to insult you, but how about your wiring between the PIC and MRF for the SPI interface?
    PIC MRF Module
    MRFReset (PORTA.1) ----- RESET (Pin 2) for MRF89xAM9A (Leave this disconnected for these tests)
    MRFConfigSel (PORTA.5) ----- CSCON (Pin 3) for MRF89XAM9A
    MRFDataSel (PORTA.4) ----- CSDATA (Pin 8) for MRF89XAM9A (Should be High for all of these tests)
    SCLK (PORTx.y) ----- SCK (Pin 6) for MRF89XAM9A
    SDO (PORTx.y) ----- SDI (Pin 5) for MRF89XAM9A
    SDI (PORTx.y) ----- SDO (Pin 7) for MRF89XAM9A

    I didn't see your aliases for SCLK, SDO and SDI.

    I know all this probably sounds elementary, but that is what I would do.
    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