This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS: Access CC1120 registers over SPI

Other Parts Discussed in Thread: MSP430F5529, CC1120, SIMPLICITI, BOOSTXL-CC1120-90

Tool/software: Code Composer Studio

I have CC1120 module interfaced with my MSP430F5529 launchpad over SPI .But i am unable to read the same data which i have written already to same register over SPI.It means my SPI is not working properly.Can you please suggest me some example codes or documentation.Below is the code which i have written

#include<msp430.h>

unsigned char commandByte,dataByte,receivedByte,i;
void SPI_init();
void sendCommand(unsigned char);
void sendData(unsigned char);
unsigned char receiveData(void);
void CC1120_init();
void send_Serial(unsigned char);
void init_serial(void);
void send_Value(unsigned char);

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;                            // Stop watchdog timer

    //SFRIE1=0X0010;
    init_serial();
    SPI_init();                                            //initialize SPI
    CC1120_init();                                        //initialize RF Settings

    P1OUT=0X01;                                            //SELECT POUT
        P1OUT^=BIT0;
        sendCommand(0x80);
        receivedByte=receiveData();
                            send_Value(receivedByte);
        sendCommand(0x31);
        receivedByte=receiveData();
                    send_Value(receivedByte);
            sendCommand(0x34);//enable rx mode
            receivedByte=receiveData();
            send_Value(receivedByte);

            /* do    //***check condition for empty RXFIFO
                  {
                 P2OUT&=~BIT2;
                 for(i=0;i<128;i++)
                 {
                      receivedByte = receiveData();
                    //send_Value(receivedByte);
                    send_Serial('B');
                 }

                    P2OUT|=BIT2;
                  __delay_cycles(1000);
                  }while(1);*/


    return 0;
}
void sendCommand(unsigned char commandByte)
{

             UCB0TXBUF = commandByte;                         // Send Command Byte

             while(((UCB0IFG&UCTXIFG)!=UCTXIFG));
}
void send_Value(unsigned char byte)
{
    unsigned char byte2,byte1,byte0;
        byte2=(byte/100);
        byte2=byte2|0X30;
        send_Serial(byte2);
        byte=byte%100;
        byte1=byte/10;
        byte1=byte1|0X30;
        send_Serial(byte1);
        byte0=byte%10;
        byte0=byte0|0X30;
        send_Serial(byte0);
        send_Serial('\n');
}
void send_Serial(unsigned char byte)
{

        UCA1TXBUF=byte;
        //while(UCA1STAT&UCBUSY);
        while(!((UCA1IFG&UCTXIFG)==UCTXIFG));
}
void init_serial(void)
{
        P4SEL|=0X30;//SELECT P4.4,5 AS A txd,rxd;
        UCA1CTL1|=UCSWRST;//RESET UART
        UCA1CTL1|=UCSSEL_1;//SELECT 32668HZ
        UCA1BR0=3;//SET 9600 BAUD RATE
        UCA1BR1=0x00;
        UCA1IE=0X03;
        UCA1MCTL=0X06;
        UCA1CTL0=0X00;
        UCA1CTL1 &= ~UCSWRST;
}

void SPI_init()
{
    P2DIR|=BIT2;                                            //CONFIGURE CS FOR OUTPUT
    P2OUT = BIT2;                                           // CS High
    P3REN=BIT1;                                                //
        P3DIR |= BIT0 + BIT2;                                // Set as outputs
        P3SEL = BIT0+ BIT1+BIT2;                               // Configures SPI
        /* USCI */
        UCB0CTL1 = UCSWRST;                                 // Put state machine in reset
        UCB0CTL0 |= UCCKPL + UCMSB+UCMST + UCSYNC;        // 3 pin 8-bit SPI Master
        UCB0CTL1 |= UCSSEL_2;                                // USCI Clock Source: SMCLK
        UCB0BR0 |= 0x02;
        UCB0BR1 = 0;
        UCB0IE=0X03;
        UCB0CTL1 &= ~UCSWRST;                                //enable module or module initialization
        P2OUT &= ~BIT2;                                        //select device
        while((P3IN&0x02)==0x02);

}

void sendData(unsigned char dataByte)
{
               UCB0TXBUF = dataByte;                            // Enter value of 0-255 to transmit

           // while(UCB0STAT & UCBUSY);                        // Waits for completion for shift register and buffer to be empty
            while(((UCB0IFG&UCTXIFG)!=UCTXIFG));

}
unsigned char receiveData()
{

    unsigned char receivedByte;
    while(((UCB0IFG&UCRXIFG)!=UCRXIFG));

        receivedByte = UCB0RXBUF;                     // Store received data
            return receivedByte;
}

void CC1120_init()
{
    
        receivedByte=receiveData();
        send_Value(receiveData);//1st display
        while(!((receivedByte&0x00)==0x00));


        //while(!((P3IN&0x02)==0x02));
    sendCommand(0x40);
    sendData(0x20);

}

**Attention** This is a public forum