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.

CC1101 GDO0 & GDO2 pins

Other Parts Discussed in Thread: CC1101, MSP430F5529

Hi all ! 

I am trying to interface CC1101 with MSP430F5529 using MSP-EXP430F5529 and CC1101-CC1190EM boards. I have achieved to read and write registers of CC1101, but I can`t use the GDO0 and GDO2 pins as inputs. When I configure them as inputs and with their associated interrupt isr, the SPI doesn´t run: I always read 0x00 and 0xFF. Only when I configure those pins as outputs, the SPI runs well.

What am I doing wrong? Anybody can help me? Has anybody a sample code with those evaluation boards? I test a lots of SPI codes for CC1101 but anyone runs well with MSP-EXP430F5529 board when I try to receive and send packets via Radio to another evaluation board.

Thanks a lot for pay attention!

Some of code that I am using is:

------------------------------------------------------------------------------------------------------------------------------------------------

/*PIN CONFIGURATION*/

/***************
RADIO PIN INTERFACE:
P3.0 -> SIMO SPI
P3.1 -> SOMI SPI
P3.2 -> CLK SPI
P2.6 -> CS radio SPI SLAVE TRANSMIT ENABLE
P2.3 -> PA_EN
P2.4 -> LNA_EN
GD0 -> P2.3
GD2 -> P2.4
***************/

P3SEL |= SPI_MISO + SPI_MCLK + SPI_MOSI;
P2SEL &= ~SPI_CS;
P3DIR |= SPI_MCLK + SPI_MOSI;
P3DIR &= ~SPI_MISO;
P2DIR |= SPI_CS;
P3REN |= SPI_MOSI; //Pull-up enable
P3OUT |= SPI_MOSI;

P2OUT |= SPI_CS; //CS = 1;

//HGM, LNA, PA, GD0 y GD2 PINS
P2SEL &= ~(PA_PIN + GD0_CC1101 + GD2_CC1101);
P2DIR |= PA_PIN; // + GD0_CC1101 + GD2_CC1101; //if I put GD0 and GD2 as inputs, SPI runs
P2DIR &= GD0_CC1101 + GD2_CC1101; //SPI NOT RUNS WITH THIS PINS AS INPUTS


P4SEL &= ~(HGM_PIN + LNA_PIN);
P4DIR |= HGM_PIN + LNA_PIN; //OUTS

------------------------------------------------------------------------------------------------------------------------------------------------

/*SPI CONFIGURATION FOR MSP-EXP430F5529*/

UCB0IE = 0;

UCB0CTL1 |= UCSWRST; // Put state machine in reset

UCB0IFG &= ~(UCRXIFG + UCTXIFG); //Rx & Tx flags clean

UCB0CTL0 = UCCKPL + UCMSB + UCMST + UCMODE_0 + UCSYNC; // 3-pin, 8-bit SPI master // Clock polarity select - The inactive state is high // MSB first

UCB0CTL1 |= UCSSEL__SMCLK; // Use SMCLK, keep RESET

//BDRSPI calculated for 9600bps with FCLK=4MHz

UCB0BR0 = BDRSPI & 0x00FF;

UCB0BR1 = (BDRSPI>>8) & 0x00FF; 

UCB0CTL1 &= ~UCSWRST; // Release USCI state machine

UCB0IE |= UCRXIE + UCTXIE;// Tx & Rx SPI interrupt enabled

------------------------------------------------------------------------------------------------------------------------------------------------

/*CHIP SELECT FUNCTIONS*/

void CSn_1 (void)
{
       unsigned int wait;
       for(wait=500;wait>0;wait--){_nop();} 
       P2OUT |= SPI_CS; //CS = 1
}


void CSn_0 (void)
{

       //SPI_MISO Pin 3.1 of Msp430f5529

          P3SEL &= ~SPI_MISO; //Configure SOMI as input
         P3DIR &= ~SPI_MISO;
         P2OUT &= ~SPI_CS; //CS = 0
         while(P3IN & SPI_MISO); //Wait until SOMI go low
         P3DIR |= SPI_MISO; //Reconfigure SOMI
         P3SEL |= SPI_MISO;
}

------------------------------------------------------------------------------------------------------------------------------------------------

/*SPI Write and Read FUNCTIONS*/

//READ REGISTERS

unsigned char ReadReg(unsigned char addr, unsigned char mode)
{
               unsigned char local_addr;
               unsigned char read_value;


               local_addr = addr | mode;

               CSn_0();

               while((UCB0STAT & 0x01)); //Wait until SPI not busy
               UCB0TXBUF = local_addr; //write register address
               while((UCB0STAT & 0x01)); //Wait until SPI not busy
               read_value = UCB0RXBUF;

               while((UCB0STAT & 0x01)); //Wait until SPI not busy
               UCB0TXBUF = 0xFF; //dummy byte
               while((UCB0STAT & 0x01)); //Wait until SPI not busy
               read_value = UCB0RXBUF; //Register's value

               CSn_1();

               return read_value;
}

void setreg(unsigned char reg, unsigned char data)
{
         CSn_0();

         writeByte(reg);
         writeByte(data);

         CSn_1();

}

------------------------------------------------------------------------------------------------------------------------------------------------

/*INTERRUPTS ISR*/

//SPI RADIO INTERRUPT
#pragma vector=USCI_B0_VECTOR
__interrupt void Radio_RX(void)
{
         extern volatile unsigned char read_Byte_SPI;
         extern volatile unsigned char flag_byte_receive;
         extern volatile unsigned char tx_empty;
         switch(UCB0IFG & (SPI_TXIFG + SPI_RXIFG))
         {
                  case 1:

                           //read_Byte_SPI = UCB0RXBUF;
                           flag_byte_receive = TRUE;

                           UCB0IFG &= ~SPI_RXIFG ;
                  break;
                  case 2: //Transmision
                           P1OUT ^= 0x20;
                           P1OUT ^= 0x10;

                           tx_empty = TRUE;
                           //TEST: UCB0IE &= ~UCTXIE;

                  break;
                  case 3: //Recepcion
                           //P1OUT |= 0x08;

                           //read_Byte_SPI = UCB0RXBUF;
                           //flag_byte_receive = TRUE;

                           UCB0IFG &= ~SPI_RXIFG;
                  break;
                  default:
                  break;
         }
}

//PORT 2 INTERRUPT
#pragma vector=PORT2_VECTOR
__interrupt void Port2_ISR(void)
{
             extern volatile unsigned char dato_recibido;

             dato_recibido = 2;

             switch(P2IFG)
             {
                          case GD0_CC1101:

                                       if(P2IN & GD0_CC1101)
                                                    P1OUT |= 0x20;
                                       else
                                                    P1OUT |= 0x10;

                                       dato_recibido = TRUE;
                                       P2IFG = 0;//~GD0_CC1101;
                          break;
                          case GD2_CC1101:
                                       P1OUT ^= 0x04;
                                       P2IFG &= ~GD2_CC1101;
                          break;
                          default:
                          break;
             }

}

  • According to the CC1101 user guide, GDO0 and GD02 are Digital outputs only. Please see the following table.

     

     

    Thanks,

    PM

  • Thanks for your reply.

    Yes I know that GDO pins are outputs of CC1101, so I configure as inputs in MSP430. But that is the problem: when I configure the pins of MSP430 as inputs for the GDO pins, SPI doesn`t run. Only when I configure those pins as outputs in MSP430, the SPI runs. I know that this situation is rare. I don´t know what can I do...

    BR.

  • I think when you do this:

    P2DIR &= GD0_CC1101 + GD2_CC1101; //SPI NOT RUNS WITH THIS PINS AS INPUTS

    You turn this pin into an input, which is bad.

    P2.6 -> CS radio SPI SLAVE TRANSMIT ENABLE

    Try this instead:

    P2DIR &= ~(GD0_CC1101 + GD2_CC1101); //SPI NOT RUNS WITH THIS PINS AS INPUTS

    In order to set pins as inputs you need to AND with an inverted mask.

  • Oh my god, that's it. I was configuring  wrongly the GDOs pins... I have done your recommendation and now it is running correctly.

    Thanks a lot Timothy, you have opened my eyes. I was blind.

    BR.

  • Hi luis.lopez,

    I'm using the MSP430F5529 with a CC1101 EM.

    May I ask you, how to set the registers up?

    Because in your post there is only the function "setreg" but I can't see their values.

    Thank you very much.

    Riccardo

  • I recommend you the TI tool SmartRF Studio 7. With this application you can setup CC1101 as you want, configuring a coding structure with all the register values of CC1101.

    BR,

    Luis