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.

MSP430G2553: CC1101 programming using msp430g2553

Part Number: MSP430G2553
Other Parts Discussed in Thread: CC1101, , ENERGIA

Hi All,

This is my first post on texas instrument forum.

I have been playing with texas instrument transceiver cc1101 from last few days. I managed to interface them with mbed-enabled NXP microcontrollers. i was successful to send data from my transmitting node (cc1101 with K64F) to my receiving node (cc1101 with LPC1768). Now I want to use msp430g2553 in my transmitting node instead of K64F micro-controller.

I am using msp430 launchpad and I am using energia to program the MCU

my connection for msp430 are as follows:

  1. csn is at pin 8
  2. sck is at pin 7
  3. mosi is at pin14
  4. miso is at pin 15
  5. I just declare csn as output, the rest of the pins i assume gets configured when we call spi.begin()?


I imported the cc1101 library from mbed and managed to convert and compile it without errors. However I am still struggling to send the message to receiving node. My logic is as follows:

  • initialize SPI library (1 MHZ of frequency,SPI msb datamode and SPI_mode0)
  • initialize registers of cc1101 
  • send data after every 4 seconds

I used Serial.println to debug my program and I can see it is calling the spi_send function in usci_spi.cpp file but i cant see any packet in the receiving end.

I can see that NXP micro-controllers return non-zero values in response when I write data using SPI to registers. However msp430g2553 returns zero. 

Almost same logic and code is running on k64f, even my print statements are giving me same values of registers,addresses and data. But msp430 is not sending data mbed-k64f is sending data.
I read it one of the forum that I need to connect resistor with CSn output is it correct? as i did not connect any resistor while using NXP microcontroller.

Please advise accordingly.

thanks in advance,

Zain

  • Have you looked at this thread:
    e2e.ti.com/.../894975
  • Hi Zain,
    These application notes will be helpful
    www.ti.com/.../swra116a.pdf
    www.ti.com/.../slaa325a.pdf
    Regards,
  • Hi Zain,

    I hope it is an OC issue.
    I will check it tomorrow.
  • Hi,

    Thanks for your quick response.  I have looked into these threads. I have already written the code and it is running without any errors.

    Problem is when I try to get response from cc1101 i get 0 in return for example if I write

    void CC1101::WriteReg(unsigned char addr, unsigned char value)
    
    {
    
       delay(0.005);
    
       digitalWrite(chipSelectPin, LOW);
    
       delay(0.002);
    
    //while (digitalRead(dataReadyPin));
    
       SPI.transfer(addr);
    
    int x=   SPI.transfer(value);
    
       delay(0.002);
    
       digitalWrite(chipSelectPin, HIGH);;
    Serial.println(x);
    Serial.println("done.."); }// WriteReg

    i just receive 0 from cc1101. whether it is single byte or burst write i always get 0 in return.
    I am using energia to program it. the following code is to initiliaze SIP and write the data into cc1101, this is the spi library using by energia

    void spi_initialize(void)
    {
    	UCB0CTL1 = UCSWRST | UCSSEL_2;      // Put USCI in reset mode, source USCI clock from SMCLK
    	UCB0CTL0 = SPI_MODE_0 | UCMSB | UCSYNC | UCMST;  // Use SPI MODE 0 - CPOL=0 CPHA=0
    
     	/* Set pins to SPI mode. */
    	pinMode_int(SCK, SPISCK_SET_MODE);
    	pinMode_int(MOSI, SPIMOSI_SET_MODE);
    	pinMode_int(MISO, SPIMISO_SET_MODE);
    
    	UCB0BR0 = SPI_CLOCK_DIV() & 0xFF;   // set initial speed to 4MHz
    	UCB0BR1 = (SPI_CLOCK_DIV() >> 8 ) & 0xFF;
    
    	UCB0CTL1 &= ~UCSWRST;			    // release USCI for operation
    }

    uint8_t spi_send(const uint8_t _data)
    {
    UCB0TXBUF = _data; // setting TXBUF clears the TXIFG flag
    while (UCB0STAT & UCBUSY)
    ; // wait for SPI TX/RX to finish
    
    return UCB0RXBUF; // reading clears RXIFG flag
    }

  • Thank you for providing additional information. I will try to look into it.
    But as I said I have done the coding part of it, however I am not getting the response from cc1101.
    I want to make sure what i am doing wrong before changing the software platform (from energia to ccs or IAR)
  • Thanks Tomasz,

    Please update me accordingly. I just saw a youtube video on how to interface SPI device with launchpad and I can see that he has linked MOSI of SPI slave with MISO of launch pad and vice versa(please find youtube video link). I am not sure what I am doing wrong. To me following could be the possibilities:

    • IC issue, SPI pins not working??
    • Connections are wrong:

                At the moment I connect SCK pin of cc1101 with pin 7(P1_5) of the launch pad,csn with pin 8 (configure as output P2_0). MOSI with pin 14(P1_6) and MISO with pin 15(P1_7)

    •         Energia not initializing the SPI library properly
    • I use SPI.begin() to initiliaze the SPI library which calls the following code
      void spi_initialize(void)
      {
      	UCB0CTL1 = UCSWRST | UCSSEL_2;      // Put USCI in reset mode, source USCI clock from SMCLK
      	UCB0CTL0 = SPI_MODE_0 | UCMSB | UCSYNC | UCMST;  // Use SPI MODE 0 - CPOL=0 CPHA=0
      
       	/* Set pins to SPI mode. */
      	pinMode_int(SCK, SPISCK_SET_MODE);
      	pinMode_int(MOSI, SPIMOSI_SET_MODE);
      	pinMode_int(MISO, SPIMISO_SET_MODE);
      
      	UCB0BR0 = SPI_CLOCK_DIV() & 0xFF;   // set initial speed to 4MHz
      	UCB0BR1 = (SPI_CLOCK_DIV() >> 8 ) & 0xFF;
      
      	UCB0CTL1 &= ~UCSWRST;			    // release USCI for operation
      }

      After caling this library I set the clock rate, MSB data format, and polarity by calling the following functions

      void spi_set_divisor(const uint16_t clkdiv) //set clock rate
      {
      	UCB0CTL1 |= UCSWRST;		// go into reset state
      	UCB0BR0 = clkdiv & 0xFF;
      	UCB0BR1 = (clkdiv >> 8 ) & 0xFF;
      	UCB0CTL1 &= ~UCSWRST;		// release for operation
      }
      
      /**
       * spi_set_bitorder(LSBFIRST=0 | MSBFIRST=1)
       */
      void spi_set_bitorder(const uint8_t order)
      {
          UCB0CTL1 |= UCSWRST;        // go into reset state
          UCB0CTL0 = (UCB0CTL0 & ~UCMSB) | ((order == 1 /*MSBFIRST*/) ? UCMSB : 0); /* MSBFIRST = 1 */
          UCB0CTL1 &= ~UCSWRST;       // release for operation
      }
      
      /**
       * spi_set_datamode() - mode 0 - 3
       */
      void spi_set_datamode(const uint8_t mode) // set polarity and phase
      {
          UCB0CTL1 |= UCSWRST;        // go into reset state
          switch(mode) {
          case 0: /* SPI_MODE0 */
              UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_0;
              break;
          case 1: /* SPI_MODE1 */
              UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_1;
              break;
          case 2: /* SPI_MODE2 */
              UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_2;
              break;
          case 4: /* SPI_MODE3 */
              UCB0CTL0 = (UCB0CTL0 & ~SPI_MODE_MASK) | SPI_MODE_3;
              break;
          default:
              break;
          }
          UCB0CTL1 &= ~UCSWRST;       // release for operation
      }

      I am not expert in assembly language so please advise accordingly.

      thank you everyone for support

  • Hey, just to answer my own query. I have solved the problem. Thanks to everyone, and that guy who uploaded this youtube video.
    In NXP controllers we connect MISO of MCU to MISO of cc1101, and MOSI of MCU to MOSI to cc1101. However in msp430 launch pad it is the other way arround. I swapped the connection (MOSI of cc1101 to MISO of launchpad and MISO of cc1101 to MOSI of launch pad) and it worked as expected I can see data is receiving at the other end. I posted this question in different forums but this forum gave quick response to my query.

    thank you all
    stay blessed :)

**Attention** This is a public forum