Hopefully someone in the E2E community is familiar with this problem......
I'm bringing up a new board and I am using a MSP430F5508 to talk to my CC1101 radio. On the Rx side I am using the Chipcon Evaluation Board into a header that goes directly to my CC1101 and software controlled using the SmartRF Studio7 software tool.
On the Tx side I am attempting to communicate between the Rx and my board in this case the Tx side. So far I haven't been successful with the wireless communication link so I am listing my code here with hope that some of you experts can let me or make me aware of what it is that I am missing:
#include "A_Common.h"
#include "Spi.h"
#include "Io.h"
#include "CC1101.h"
#define CMD_SRES SPICommand(0x30) // Reset chip
#define CMD_SFSTXON SPICommand(0x31) // Enable calibrate of freq synthesizer
#define CMD_SXOFF SPICommand(0x32) // Turn off oscillator
#define CMD_SCAL SPICommand(0x33) // Calibrate then turn off
#define CMD_SRX SPICommand(0x34) // Enable RX
#define CMD_STX SPICommand(0x35) // Enable TX
#define CMD_SIDLE SPICommand(0x36) // Stop RX and TX and enter idle
#define CMD_SWOR SPICommand(0x38) // Start RX wake-on-radio poll
#define CMD_SPWD SPICommand(0x39) // Enter power down mode
#define CMD_SFRX SPICommand(0x3A) // Flush RX fifo
#define CMD_SFTX SPICommand(0x3B) // Flush TX fifo
#define CMD_SWORRST SPICommand(0x3C) // Reset WOR
#define CMD_SNOP SPICommand(0x3D) // NOP
//-----------------------------------------------------------------------------
const TsRadioSettings RegisterAddresses =
{
0x0B, // Frequency Synthesizer Control
0x02, // GDO0 Output Pin Configuration
0x0C, // Frequency Synthesizer Control
0x0D, // Frequency Control Word, High Byte
0x0E, // Frequency Control Word, Middle Byte
0x0F, // Frequency Control Word, Low Byte
0x10, // Modem Configuration
0x11, // Modem Configuration
0x12, // Modem Configuration
0x13, // Modem Configuration
0x14, // Modem Configuration
0x0A, // Channel Number
0x15, // Modem Deviation Setting
0x21, // Front End RX Configuration
0x22, // Front End TX Configuration
0x18, // Main Radio Control State Machine Configuration
0x19, // Frequency Offset Compensation Configuration
0x1A, // Bit Synchronization Configuration
0x1B, // AGC Control
0x1C, // AGC Control
0x1D, // AGC Control
0x23, // Frequency Synthesizer Calibration
0x24, // Frequency Synthesizer Calibration
0x25, // Frequency Synthesizer Calibration
0x26, // Frequency Synthesizer Calibration
0x29, // Frequency Synthesizer Calibration Control
0x2C, // Various Test Settings
0x2D, // Various Test Settings
0x2E, // Various Test Settings
0x03, // RX FIFO and TX FIFO Thresholds
0x00, // GDO2 Output Pin Configuration
0x07, // Packet Automation Control
0x08, // Packet Automation Control
0x09, // Device Address
0x06, // Packet Length
};
//-----------------------------------------------------------------------------
const TsRadioSettings TxrfSettings =
0x05, // PKTCTRL0 Packet Automation Control
0x00, // ADDR Device Address
0xFF, // PKTLEN Packet Length
};
//-----------------------------------------------------------------------------
// Deviation = 126.953125
// Base frequency = 433.999969
// Carrier frequency = 433.999969
// Channel number = 0
// Carrier frequency = 433.999969
// Modulated = true
// Modulation format = 2-FSK
// Manchester enable = false
// Sync word qualifier mode = 30/32 sync word bits detected
// Preamble count = 4
// Channel spacing = 199.951172
// Carrier frequency = 433.999969
// Data rate = 249.939
// RX filter BW = 541.666667
// Data format = Normal mode
// Length config = Variable packet length mode. Packet length configured by the first byte after sync word
// CRC enable = true
// Packet length = 255
// Device address = 0
// Address config = No address check
// CRC autoflush = false
// PA ramping = false
// TX power = 0
const TsRadioSettings rfSettings2 = {
0x05, // PKTCTRL0 Packet Automation Control
0x00, // ADDR Device Address
0xFF, // PKTLEN Packet Length
};
// Deviation = 126.953125
// Base frequency = 433.999969
// Carrier frequency = 433.999969
// Channel number = 0
// Carrier frequency = 433.999969
// Modulated = true
// Modulation format = 2-FSK
// Manchester enable = false
// Sync word qualifier mode = 30/32 sync word bits detected
// Preamble count = 4
// Channel spacing = 199.951172
// Carrier frequency = 433.999969
// Data rate = 249.939
// RX filter BW = 541.666667
// Data format = Random mode
// Length config = Fixed packet length mode. Length configured in PKTLEN register
// CRC enable = false
// Packet length = 32
// Device address = 0
// Address config = No address check
// CRC autoflush = false
// PA ramping = false
// TX power = 10
const TsRadioSettings rfSettings3 = {
//-----------------------------------------------------------------------------
uint8 SPICommand(uint8 data);
//-----------------------------------------------------------------------------
static TsRadioSettings LastRadioSettings;
#define CC_BURST_MODE 0x40
#define CC_READ 0x80
void ReadSPI(uint8 * data, uint8 reg, uint8 len)
{
SPI_STE_LOW;
while(SPI_DATA_IN) continue; // wait to power-up
TxRxSpiChar(reg);
while(len--) *(data++) = TxRxSpiChar(0);
SPI_STE_HIGH;
}
//-----------------------------------------------------------------------------
static void ConfigDevice(uint8 * addresses, uint8 * data, uint8 writeAll)
{
uint8 i;
uint8 currentAddress;
uint8 * lastSetting;
currentAddress = 0xFF;
lastSetting = (void*)&LastRadioSettings;
for(i=0;i<sizeof(TsRadioSettings);i++)
{
if((*lastSetting != *data) || writeAll)
{
if(currentAddress != *addresses)
{
SPI_STE_HIGH;
currentAddress = *addresses | CC_BURST_MODE;
SPI_STE_LOW;
while(SPI_DATA_IN) continue; // wait to power-up
TxRxSpiChar(currentAddress);
}
TxRxSpiChar(*data);
*lastSetting = *data;
currentAddress++;
}
addresses++;
data++;
lastSetting++;
}
SPI_STE_HIGH;
}
//-----------------------------------------------------------------------------
static void WaitForTxDone()
{
uint16 x;
uint8 c;
x = 50000;
do
{
c = 0x70 & CMD_SNOP;
} while((x) && (c != 0x70) && (c != 0));
}
//-----------------------------------------------------------------------------
static void WaitForIdleState()
{
uint16 x;
uint8 c;
x = 10000;
do
{
c = 0x70 & CMD_SNOP;
} while((x--) && (c != 0x00));
}
//-----------------------------------------------------------------------------
static void Send1100Data(uint8 * data, uint8 len)
{
SPI_STE_LOW;
while(SPI_DATA_IN) continue; // wait to power-up
TxRxSpiChar(0x3F | CC_BURST_MODE);
if(len)
{
while(len--) TxRxSpiChar(*(data++));
}
else
{
while(*data) TxRxSpiChar(*(data++));
}
SPI_STE_HIGH;
}
//-----------------------------------------------------------------------------
uint8 SPICommand(uint8 data)
{
uint8 c;
SPI_STE_LOW;
while(SPI_DATA_IN) continue; // wait to power-up
c = TxRxSpiChar(data);
SPI_STE_HIGH;
return c;
}
//-----------------------------------------------------------------------------
uint16 ReadId()
{
uint8 id1;
uint8 id2;
ReadSPI((void*)&id1, 0x30|CC_BURST_MODE|CC_READ, 1);
ReadSPI((void*)&id2, 0x31|CC_BURST_MODE|CC_READ, 1);
CMD_SPWD;
return (uint16)id1 + ((uint16)id2<<8);
}
//-----------------------------------------------------------------------------
void SendSomeData()
{
ConfigDevice((void*)&RegisterAddresses, (void*)&rfSettings3, 0);
//CMD_SFSTXON;
//WaitForIdleState();
Send1100Data("This is a crazy radio dude 2", 0);
CMD_STX;
WaitForTxDone();
CMD_SIDLE;
CMD_SPWD;
}
//-----------------------------------------------------------------------------
void Init_CC1101()
{
ConfigDevice((void*)&RegisterAddresses, (void*)&rfSettings2, 1);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------