MRF90XAM9A interfacing help


Closed Thread
Results 1 to 40 of 64

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    Give this a shot.

    Code:
    [B]'MRF initialization here
    debug "@ MRF init", 10,13
    '            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      
                    MRFConfigSel=0                                                      'Select the chip       
    '                SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values[i]]               'send data to register
                    SHIFTOUT SDO, SCLK, 1,[MRFaddr,RF_Init_Values(i)]               'send data to register
                    MRFConfigSel=1
                next i    
    '            MRFConfigSel=1                                                      'Deselect the chip
                
    '            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
                    MRFaddr=((i << 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
    '                MRFConfigSel=1                                                  'Deselect the chip
    '                MRFConfigSel=0                                                  'Select the chip
                    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]                               'Get data from reg
                    MRFConfigSel=1    
                    debug "MRF Config data: Register ", hex2 MRFaddr, "   Data=", hex2 MRFSPIdata,13
                next i
    Regards,
    TABSoft

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


    Did you find this post helpful? Yes | No

    Default Re: MRF90XAM9A interfacing help

    I did find the double 'OR' but it didn't seem to help.
    I also remarked the chip selects and deselects - no help either.
    Thanks though for trying!

    The code in the next post is where I am now, but, its confusing when you can't read the register to know if its set, then, transmission to a ZENA
    sniffer I found on another board said that it is useless if you are not using MiWi......
    Ugh!
    "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 think, with no certainty, that reading the part has to be done using hardware SPI in full-duplex mode. I don't see any way to SHIFTIN to send the address, and then SHIFTOUT to get the data accurately.
    I used hardware SPI (simplex) on a different project and it worked great, but I wasn't trying to write and read simultaneously.

    Has anyone had any luck using hardware SPI in a full-duplex project?
    If so, any help would be appreciated - maybe that is what I need to do?

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

    Perhaps you need to strip this back to the basics?
    Forget trying to configure the MRF registers.
    Just try to read them after a POR.
    Also, what is your physical connectivity between the PIC and the MRF (Pinouts/Schematic)?
    Can you show us your aliases for MRFConfigSel, SCLK, SDO and SDI?
    I can't think of any reason why you shouldn't be able to read the config registers.
    Using Shiftin/Shiftout for SPI has not been a problem thus far.


    Create just a skeleton program to configure the PIC for the connectivity you need to the MRF and Serial port for debug.
    Then with the skeleton, just wait for the appropriate amount of time and try to read regs 00 - 07, but do not do this in a For/Next loop. Read each register in a serial fashion.

    E.g.
    MRFaddr = $40
    MRFConfigSel = 0
    SHIFTOUT SDO, SCLK, 1,[MRFaddr]
    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]
    MRFConfigSel = 1
    debug "MRF Config data:Register ", bin8 MRFaddr, " Data=", hex2 MRFSPIdata,13
    pause 50
    MRFaddr = $41
    MRFConfigSel = 0
    SHIFTOUT SDO, SCLK, 1,[MRFaddr]
    SHIFTIN SDI, SCLK, 0,[MRFSPIdata]
    MRFConfigSel = 1
    debug "MRF Config data:Register ", bin8 MRFaddr, " Data=", hex2 MRFSPIdata,13
    pause 50

    etc...
    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

    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

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

  7. #7
    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: 4892
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

  8. #8
    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, 03:42
  2. Keypad Interfacing
    By uaf5000 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 15th June 2010, 03:35
  3. Interfacing with the ISD4003
    By lerameur in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 2nd June 2008, 16:25
  4. SPI Interfacing
    By toofastdave in forum Serial
    Replies: 8
    Last Post: - 18th November 2007, 12:15
  5. interfacing LCD
    By husakhalid in forum mel PIC BASIC
    Replies: 3
    Last Post: - 30th May 2006, 23: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