Modified version of rf-24g example for free version of CC5X

In trying to compile the (graciously provided) example code for the RF-24G in CC5X I came across the following error:

Error[1] D:\Other\Projects\SensorNetwork\Software\rf-24g-example.c 257 : Unable to generate code
 The C syntax is correct. However, CC5X is unable to generate code.
 The workaround is often to split the code into simpler statements,
 using an extra variable to store temporary results. Sometimes it is
 enough to change the sequence of operations.

I made a code change, with the assumption that the error is caused by the CC5X free version not handling higher than uns16 (with the config word for the transceiver being 24-bit. I split it up into an 8-bit and a 16-bit and sent them out one after the other. I’ve attached a ‘prototype’ of this splitting up for two reasons: 1) So those more knowledgable can review it to see if I did it correctly, and 2) So those people with only the free CC5X version can benefit.

The code demonstrating this change is below (although it’s not the actual code that should be put in the rf-24g-example.c:

void main(void)
{
    uns8 i;
    uns8 config_setup_high;
	uns16 config_setup_low;
	int RX_DATA;

    //Setup configuration word
    config_setup_high = 0b.0010.0011;
	config_setup_low  = 0b.0110.1110.0000.0101; //Look at pages 13-15 for more bit info

    for(i = 0 ; i < 8 ; i++)
    {
		RX_DATA = config_setup_high.7;
        config_setup_high <<= 1;
    }
    for(i = 0 ; i < 16 ; i++)
    {
		RX_DATA = config_setup_low.15;
        config_setup_low <<= 1;
    }
}

Thanks,

Jeff

Looks good to me. Nice clean fix.

Sorry about that! I didn’t mean to write code that needed expensive compilers. I’ve just been coding with a paid version of CC5X for so long (first paid piece of software in a long time), I don’t really think about the incompatibilities.

-Nathan

No problem at all; I usually suspect it’s my coding that causes the errors/warnings, but when I haven’t written the code (and I know you’ve verified that it works), the next place to go is the difference between the free and full versions.

Jeff

Don’t use the code I put above without modifying it!

After much head-scratching I realized I forgot to cycle the clock after putting each configuration bit onto the data line. Basically inside each loop (for the receiver setup) put:

RX_CLK1 = 1;
RX_CLK1 = 0;

and inside each loop for the transmitter setup put:

TX_CLK1 = 1;
TX_CLK1 = 0;

Sorry about that; I just realized I made that mistake and wanted to clarify.

Jeff[/b]