Cywm6935 and arduino HELP!

Sorry if this is in the wrong section. Im currently trying to get a project going in which I want to read the signal strength from my Cypruss CYWM6935 2.4ghz wireless module and pass the info along to my arduino diecemilia. The chip uses SPI communication and no one at my school really knows how to get me going in the right direction. I know that the rssi register on the CYWM6035 is stored at 0x22 - this information ranges from i believe 0-32. zero being a clear channel, ten being some activity, and 32 being a very strong signal.

Honestly, this seems so easy that its really frustrating me that I cant figure out how to access that register with my arduino and just simply see the number that is being stored in the rssi registry.

all the code snippets that I find are not written with the arduino in mind, and im having a hard time figuring it out. Im more than familiar with the concepts of turning the pins high and low for SPI communication, but i just dont know how to actually program it.

can someone step up to try and help me?

The AVR has SPI hardware. Details will be in the data sheet.

Leon

yes…i understand this…ive got the module hooked up to the proper pins…im just having a problem getting the information off the module and passing it to the arduino so i can read it.

here’s how you should sequence the radio to bring it out of reset for reliable operation →

void RadioReset(void)
{
   nRST_LO; nPD_LO;  nSS_HI;  SCK_LO;
   DelayMicroSec(tPWR_RST);                  //1300usec min.
   nPD_HI;
   DelayMicroSec(tPDN_X13);                  //2000usec typ.
   nRST_HI;
   DelayMicroSec(tSPI_RDY);                  //1usec min.
   nPD_HI;                                   
   DelayMicroSec(CRYSTAL_STARTUP);           // ~Xmsec for crystal start to stable - idle
}

then you should probably perform basic radio initialization, here’s one example →

// RadioInit table - reg addr followed by init value, sequence is important
const BYTE code RadioInitTable[] =
{
   0x20, 0x45,    //REG_ANALOG_CTL
   0x20, 0x44,    //REG_ANALOG_CTL
   0x2E, 0x80,    //REG_PWR_CTL
   0x26, 0xC0,    //REG_VCO_CAL
   0x33, 0x41,    //REG_CLOCK_ENABLE
   0x32, 0x41,    //REG_CLOCK_MANUAL
   0x24, 0x40,    //REG_CRYSTAL_ADJ
   0x06, 0x09,    //REG_SERDES_CTL, EOF=1 (first missed correlation)
   0x10, 0xFF,    //REG_TX_VALID
   0x23, 0x05,    //REG_PA - PA=5
   0x21, 0x02     //REG_CHANNEL = 2402MHz
};

void RadioInit(void)
{
   BYTE i;
   
   for(i=0;i<sizeof(RadioInitTable);i+=2) {
      SpiWrite(RadioInitTable[i],RadioInitTable[i+1]); 
   }
}

then you can perform a manual RSSI conversion by doing something like this →

BYTE RadioGetRssi(void)
{
   BYTE x=0;
   SpiWrite((SPI_FRZ | 0x2F), 0x80);            //REG_CARRIER_DETECT -  set CDET to force radio to manually acquire rssi reading
   SpiWrite((SPI_FRZ | 0x03), 0x90);            //REG_CONTROL - put radio in receive mode - triggers rssi adc
   DelayMicroSec(SYNTH_SETTLE);                 // wait for synth to settle
   DelayMicroSec(RECEIVER_READY);               // wait for receiver ready
   DelayMicroSec(RSSI_ADC_CONVERSION);          // wait for 5-bit rssi adc to complete
   x = SpiRead((SPI_FRZ | 0x22));               //REG_RSSI - flush stale rssi reading
   DelayMicroSec(RSSI_ADC_CONVERSION);          // wait for 5-bit rssi adc to complete
   x = SpiRead((SPI_FRZ | 0x22));               //REG_RSSI - get rssi reading
   SpiWrite((SPI_FRZ | 0x2F), 0x00);            //REG_CARRIER_DETECT - manually clear CDET
   SpiWrite((SPI_FRZ | 0x03), 0x00);            //REG_CONTROL - put radio in idle mode
   return(x);
}

where →

#define SPI_FRZ   0x00
#define SYNTH_SETTLE           200 * 0.65    // 200usec
#define RECEIVER_READY          35 * 0.65    // 35usec
#define CRYSTAL_STARTUP       2100 * 0.65    // 2100usec
#define RSSI_ADC_CONVERSION     50 * 0.65    // 50usec
#define CRYSTAL_STARTUP       2100 * 0.65    // 2100usec
#define tPD                     10 * 0.65    // 10usec
#define tPWR_RST              1300 * 0.65    // 1300usec
#define tPDN_X13              2000 * 0.65    // 2000usec
#define tSPI_RDY                 1 * 0.65    // 1usec

// 0.65 is the implementation specific cal factor for DelayMicroSec();

Thanks so much for the help! Do you know if this code will work with the arduino? If so will I have to initialize some of the pins first? Can’t wait to get home from work to try this out.

Sorry, I don’t know if they’ll work “as-is” with the arduino target… I originally wrote them for standard 8051 target. I don’t expect these code snippets to directly drop-in and work on arduino.

Here’s an outline of the effort I think you’ll need to complete in order to successfully interface your arduino to the radio module →

  1. First, you’ll need to get basic GPIO functioning as outputs and also create simple software delays to use for RadioReset() call…

  2. Next, you’ll need to work on getting the SPI master hardware block functioning for basic writes for RadioInit() call… Tip: SCK must not exceed 2MHz. SPI slave select (nSS signal from arduino to radio) is normally just a GPIO output.

  3. Then, you’ll need to work on getting SPI master hardware block functioning for basic reads for RadioGetRSSI() call… Tip: SCK must not exceed 2MHz. SPI slave select (nSS signal from arduino to radio) is normally just a GPIO output.

  4. Finally, adapt these code snippets to your working output pins, software delays, and basic SPI write and read routines. Tip: Do keep the basic sequence of events the same in your arduino port of the ones I’ve included here.

hey T- thanks for all of your help in this matter. i am reading the code and it makes sense to me - in theory that is. Im understanding a little better what it would take to clear the radio and then go high and low to get the rssi reading…the only problem is that I have no clue how to adapt this for the arduino which is running on an atmega168 chip. I found some stuff over here http://code.google.com/p/cywusb/source/ … &spec=svn2 - but again im having a hard time compiling for the atmega168.

any ideas?

-Chris

you’re very welcome :slight_smile:

do you have basic SPI reads and writes working on your target hardware? or is this the specific step that you’re currently having troubles with?

sorry, but i’m not at all familiar with the Arduino development environment. you did mention “compiling”, so I’m assuming that means you already have a “C” compiler environment for your own target hardware.

can you upload a link to your specific Arduino development system - board revision, software version, errata, etc?

one gentlemen on this thread already mentioned that the target processor that you’re using has hardware SPI built-in (cool, that’s a nice luxury) and that information should be included in the processor’s data sheet.

have you had a look see at the data sheet?

that’s certainly the right place to start learning about your specific processor and its implementation :slight_smile:

the link that you’ve provided to the source code looks like another good resource for configuring hardware SPI, sample radio code, etc …as well.