Other Parts Discussed in Thread: CC1100, CC2500, MSP430G2231
I am using the MSP430G2231 , trying to interface it to CC1100 for working in the 868 MHz band. I am using the CC1100 - CC2500 library for this. I have not been able to communicate with the CC1100, as it seems the SPI is not getting initialized.
I wanted to send a few bytes of data on switch press. On switch press the RF SendPacket() is called, and the code keeps waiting for the GDO0 line to change.
Using an oscilloscope i tried to see if the SCLK required is working, but, i cannot see any waveform on the line. Nor can i see any waveform on the SDO or SDI lines.
The call to TI_CC_SPISetup() should set up the SPI port, but, this does not seem to be the case. My code is more or less the same as the example code provided, with changes in the TI_CC_hardware_board.h file to accommodate my own connections.
Below is the code i am using.
/*
* ======== Standard MSP430 includes ========
*/
#include <msp430g2231.h>
#include <TI_CC_CC1100-CC2500.h>
#include <TI_CC_MSP430.h>
#include <CC1100-CC2500.h>
#include <TI_CC_hardware_board.h>
#include <TI_CC_spi.h>
/*---------------------------------------------------------------*/
// Variable Declarations
extern char paTable[];
extern char paTableLen;
char txBuffer[4];
char rxBuffer[4];
/*---------------------------------------------------------------*/
/*
* ======== main ========
*/
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
BCSCTL1=CALBC1_1MHZ;
DCOCTL = CALDCO_1MHZ;
P1SEL |= 0xE0; //1: for peripheral function and 0: for I/O fuction
P1DIR |= 0xF1; //1: for o/p and 0: for i/p
P2SEL = 0x00; // Sets P2.6 & P2.7 as GPIO
P2DIR |= 0x00;
// Configure ports -- switch inputs, LEDs, GDO0 to RX packet info from CCxxxx
TI_CC_SW_PxREN = TI_CC_SW1; // Enable Pull up resistor
TI_CC_SW_PxOUT = TI_CC_SW1; // Enable pull up resistor
TI_CC_SW_PxIES = TI_CC_SW1; // Int on falling edge
TI_CC_SW_PxIFG &= ~(TI_CC_SW1); // Clr flags
TI_CC_SW_PxIE = TI_CC_SW1; // Activate interrupt enables
TI_CC_LED_PxOUT &= ~(TI_CC_LED1); // Outputs = 0
TI_CC_LED_PxDIR |= TI_CC_LED1; // LED Direction to Outputs
TI_CC_GDO0_PxIES |= TI_CC_GDO0_PIN; // Int on falling edge (end of pkt)
TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // Clear flag
TI_CC_GDO0_PxIE |= TI_CC_GDO0_PIN; // Enable int on end of packet
TI_CC_SPISetup(); // Initialize SPI port
TI_CC_PowerupResetCCxxxx(); // Reset CCxxxx
writeRFSettings(); // Write RF settings to config reg
TI_CC_SPIWriteBurstReg(TI_CCxxx0_PATABLE, paTable, paTableLen);
// Write PATABLE
TI_CC_SPIStrobe(TI_CCxxx0_SRX); // Initialize CCxxxx in RX mode.
// When a pkt is received, it will
// signal on GDO0 and wake CPU
__bis_SR_register(GIE); // Enable interrupts
//while(1);
}
/*---------------------------------------------------------------*/
#pragma vector=PORT1_VECTOR
__interrupt void port1_ISR (void)
{
// Transmit on press of the switch
if(TI_CC_SW_PxIFG & TI_CC_SW1)
{
// Build packet
txBuffer[0] = 2; // Packet length
txBuffer[1] = 0x01; // Packet address
txBuffer[2] = (~TI_CC_SW_PxIN) & 0x08; // Load the switch input
RFSendPacket(txBuffer, 3); // Send value over RF
}
TI_CC_SW_PxIFG &= ~(TI_CC_SW1); // Clr flag that caused int
}
/*---------------------------------------------------------------*/
#pragma vector=PORT2_VECTOR
__interrupt void Port2_ISR(void)
{
// If GDO fired
if(TI_CC_GDO0_PxIFG & TI_CC_GDO0_PIN)
{
char len=2; // Len of pkt to be RXed (only addr
// plus data; size byte not incl b/c
// stripped away within RX function)
if (RFReceivePacket(rxBuffer,&len)) // Fetch packet from CCxxxx
{
TI_CC_LED_PxOUT ^= rxBuffer[1]; // Toggle LEDs according to pkt data
}
}
TI_CC_SPIStrobe(TI_CCxxx0_SIDLE);
TI_CC_SPIStrobe(TI_CCxxx0_SRX);
TI_CC_GDO0_PxIFG &= ~TI_CC_GDO0_PIN; // After pkt RX, this flag is set.
}
/*---------------------------------------------------------------*/
Can someone point out what i am doing wrong?
N.B. Please don't move this to a different forum like RF, where i don't expect to get any answers. I have a problem with SPI not CC1100. This has happened before.