4
\$\begingroup\$

Does anyone have any experience with the Microchip MRF49XA sub 1GHz transceiver? I have been trying to get one of these to talk to a pic16f886 over the last week or so over SPI and having no luck getting a response out of it. I have followed the data sheet on the required connections correctly as far as I can tell and I able to send data out on the SDO, but when I pull chip select low and write 0x00 to the SPI output (which should get a response from the MRF49XA status register) the SDI line stays low. I have tried writing all my own code using the data sheet as my source and when that didn't work I downloaded the Sample Demo Application and ripped out the relevant parts from, still no luck.

I have attached a screen shot of a sample of an SPI write cycle, Ch. 1 is the SDO, Ch.2 the chip select line and Ch. 3 the SCK.

SPI logic signals

Suffice to say that when executing the SPI read the SDO is low, the SDI is low (sadly) the chip select (CS) is low and the clock pulses correctly. The MRF49XA uses Word writes so that is why the clock line pulses 16 times with a gap in between where the CS remains low.

If anyone has had any experience with this chip help would be great, some of the articles I have found online have hinted that is can be a pain but nothing has really helped so far.

I am using a PIC16F886 to talk to this thing, running off 3.3V and here are the SPI setup and commands:

 
.
.
.
.

//set up SPI
    SSPCON = 0b00100000;
    SSPSTAT = 0b11000000;
}
void spiWrite(BYTE data)
{
    BYTE i;
    PIR1bits.SSPIF = 0;
    i = SSPBUF;
    SSPBUF = data;
    while(PIR1bits.SSPIF == 0){}
} 
BYTE spiRead(void){
    spiWrite(0x00);
    return SSPBUF;
}   

void RegisterSet(WORD setting)
{
    nCS = 0;
    spiWrite(setting >> 8);
    spiWrite(setting);
    nCS = 1;
}
\$\endgroup\$
3
  • \$\begingroup\$ Just to check - you are connecting the output from the master to the input on the slave - MO to SI? \$\endgroup\$ – Toby Jaffey Jun 1 '11 at 21:42
  • \$\begingroup\$ Have you checked your SPI phase and polarity settings? There's a bit banging sample driver here to compare with akolman.info/schoolstuf/EECS_542/files/final%20project/… \$\endgroup\$ – Toby Jaffey Jun 1 '11 at 21:49
  • \$\begingroup\$ Sadly the chips are connected correctly (would have been a nice simple solution) I swapped them anyway just to check and still nothing. Thanks for the link, I will have a proper dig through the code tomorrow, looks great on the surface though. What do you mean by the SPI phase? Is that related to when the data changes related to the clock pulse? I notice the timing diagrams in the MRF49XA data sheet show the data changes when the clock is low. On my measured timing diagrams data and clock seem to change at the same time, I can't find a register to control this delay on the pic though.Cheers \$\endgroup\$ – SimonBarker Jun 1 '11 at 22:15
2
\$\begingroup\$

The demo code is for a PIC18F87J11 and the C18 compiler, whereas you are using a PIC16F886 and some other, probably incompatible, compiler.

You will probably have more success if you use a PIC18 instead of the PIC16F886, with the C18 compiler. I downloaded the code, and apart from having to fix the include file location, the application built without any problems. You are also more likely to get assistance if you use the correct chip and compiler, either from people here, or on the Microchip forum.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ Hi Leon thanks for the help, compiling the code isn't the issue and the MRF49XA chips are compatible with 8-bit PICs from what I have seen elsewhere online - have you found them not to be? Also, I did not build the demo project but instead went through the demo code copying out the relevant bits and then changing aspects for the relevant registers etc in the 16F886. Given that SPI is a fairly ubiquitous standard I don't understand why there would be a specific chip requirement for communicating with an MRF49XA. I'll take a look at the 18F stuff, I am using Hi-Tech C compiler currently \$\endgroup\$ – SimonBarker Jun 1 '11 at 21:25
  • 1
    \$\begingroup\$ I've never used them. When I work with anything like that I use the same chip and compiler to start with, get it working, and then change things. \$\endgroup\$ – Leon Heller Jun 1 '11 at 21:43
  • 1
    \$\begingroup\$ I'm beginning to feel that will be the best way to go - it's that temptation to "roll you own" when you see how much the dev boards are - I guess it's worth it in the long run though.cheers \$\endgroup\$ – SimonBarker Jun 1 '11 at 22:00
  • \$\begingroup\$ Just buy a couple of chips, design your own board, and get one made. \$\endgroup\$ – Leon Heller Jun 1 '11 at 22:21
2
\$\begingroup\$

From your screen shot, it looks like your SDO changes on the rising edge of the clock. While I haven't used this particular product, other Microchip parts seem to like the data to change on the falling edge of the clock.

According to the datasheet, the clock must idle low (which you've got), and data is clocked in on the rising edge of the clock. This means that the data must be stable on rising edge of the clock, and must change on the falling edge of the clock.

SSPSTAT = 0b10000000;

\$\endgroup\$
0
\$\begingroup\$

I had this problem recently and still couldn't find an answer in 2015, so I have updated this thread.

I actually read the register with a scope so not sure exactly when the data is clocked out, but I do know this device and suggest it will do one of the following.

CS Low, then clock 0x0000 into the MRF. While you do this capture the SDO from the MRF. Some registers clock out a byte during the second half of the write, ie on clocks 8-15 of the command word (the Rx FIFO register for example), but as the status word is 16 bits you may have to clock it out after the command.

Just checked, the Status word clocks out as you clock in 0x0000 with MSB actually present on SDO when CS=0. (all other command words start with a 1, by default status word is presented)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.