Because of the Thanksgiving holiday in the U.S., TI E2E™ design support forum responses may be delayed from November 25 through December 2. Thank you for your patience.

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.

Problem with CC1101EMK433 -MSP430F5599 LaunchPad SPI Interface

Other Parts Discussed in Thread: ENERGIA, CC1101

Hello,

  I am trying to make a interface between CC1101EMK433 transceiver module and MSP430F5599 LaunchPad using SPI interface. I am using Energia to program the interface. By using CC Debugger without any MCU, I am able to program the module to desired RF parameters. But when I use MSP430, it seems that the issue is with the SPI interface. When analysed the SPI channel using DSO, I found that the SPI clock is not at all propagating from the SCLK pin of MSP430. Then I came to a conclusion that the problem should be with the SPI library of energia where it can't establish the serial protocol. After checking the library source file, I came to know that the file had a single line of a calling a class. Then I replaced the entire library with another version which worked well for another application scenario. Even in this case, I am not able to program the RF module. I had a simple energia code which reads a register, alters that register value and re-reads the register again, prints the value. I have attached the codes for your reference. Kindly help me to resolve this issue.

CC1101 PCB INTERFACE:

                                                                                                         

 

  • SPI-CC1101 CODE:

    #include <SPI.h>
    const byte CONFIG_REG                  = 0x80;
    const byte STATUS_REG                  = 0xC0;
    const byte IOCFG2                     = 0x00; // GDO2 output pin configuration
    const int SPI_CS = P2_7;            //SLAVE SELECT PIN
    const int SPI_MOSI = P3_0;
    const int SPI_MISO = P3_1;
    const int SPI_SCLK = P3_2;
    const int LED=RED_LED;
    const byte SRES = 0x30; 
    void setup()
    {
      // put your setup code here, to run once:
      
      Serial.begin(9600);        //SERIAL COMMUNICATION INITIALISED WITH BAUD RATE OF 38400
      Serial.println("begin");
      SPI.begin();   
      SPI.setClockDivider(SPI_CLOCK_DIV4);
      SPI.setDataMode(SPI_MODE0);
       pinMode(SPI_CS,OUTPUT);         //SLAVE SELECT
     //pinMode(SPI_GDO0,INPUT);
     pinMode(SPI_MOSI,OUTPUT);       //MOSI PIN
     pinMode(SPI_MISO,INPUT);        //MISO PIN
      pinMode(SPI_SCLK,OUTPUT);       //SCLK
      pinMode(LED,OUTPUT);
      digitalWrite(LED,LOW);
      blinker();
                  //INITIALIZE SPI PARAMETERS
      
     Reset();                    //RESET THE CC1101 FOR DEFAULT VALUES IN REGISTERS
     // WriteSettings();            //WRITING THE SETTINGS OBTAINED FROM SMARTRF STUDIO
      
    Serial.println("device setup complete");    //CC1101 IS READY FOR PROGRAMMING
    }
    void loop()
    {
      // put your main code here, to run repeatedly:
      byte a = ReadReg(IOCFG2, CONFIG_REG);
      WriteReg(IOCFG2, 0xFA);
      byte b = ReadReg(IOCFG2, CONFIG_REG);
      Serial.println(a, BIN);
      delay(100);
      Serial.println(b,BIN);
      delay(100);
    }
    void waitMiso()                               //WAIT FOR MISO PIN TO GO LOW AFTER CS PIN GOES LOW
    {
      while(digitalRead(P3_1)==HIGH);
    }
    byte ReadReg(byte RegAddr,byte RegType)       //READ SINGLE BYTE FROM CONFIG OR STATUS REGISTERS
    {
      byte data =RegAddr | RegType;
      digitalWrite(SPI_CS,LOW);
      waitMiso();
      SPI.transfer(data);
      byte result =SPI.transfer(0x00);
      return(result);
      digitalWrite(SPI_CS,HIGH);
    }
    void WriteReg(byte RegAddr,byte data)         //WRITE SINGLE BYTE TO CONFIG REGISTERS
    {
      digitalWrite(SPI_CS,LOW);
      waitMiso();
      SPI.transfer(RegAddr);
      SPI.transfer(data);
      digitalWrite(SPI_CS,HIGH);
    }
    void blinker()
    {
       digitalWrite(LED, HIGH);
       delay(100);
       digitalWrite(LED, LOW);
       delay(100);
    }
    void Reset()                                  //RESET THE CC1101 USING SRES STROBE
    {
      digitalWrite(SPI_CS,HIGH);
      delayMicroseconds(5);
      digitalWrite(SPI_CS,LOW);
      delayMicroseconds(10);
      digitalWrite(SPI_CS,HIGH);
      delayMicroseconds(41);
      digitalWrite(SPI_CS,LOW);
      waitMiso();
      SPI.transfer(SRES);
      digitalWrite(SPI_CS,HIGH);
    }
  • SPI LIBRARY-ENERGIA:

    SPI SOURCE CODE:

    /*
     * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
     * SPI Master library for arduino.
     *
     * This file is free software; you can redistribute it and/or modify
     * it under the terms of either the GNU General Public License version 2
     * or the GNU Lesser General Public License version 2.1, both as
     * published by the Free Software Foundation.
     *
     * 2012-04-29 rick@kimballsoftware.com - added msp430 support.
     *
     */
    #include <Energia.h>
    #include "SPI.h"
    SPIClass SPI;
    void SPIClass::begin()
    {
        spi_initialize();
    }
    void SPIClass::end()
    {
        spi_disable();
    }
    void SPIClass::setBitOrder(uint8_t bitOrder)
    {
        spi_set_bitorder(bitOrder);
    }
    void SPIClass::setDataMode(uint8_t mode)
    {
        spi_set_datamode(mode);
    }
    void SPIClass::setClockDivider(uint8_t rate)
    {
        spi_set_divisor(rate);
    }
    SPI HEADER FILE:

    /*
    * Copyright (c) 2010 by Cristian Maglie <c.maglie@bug.st>
    * SPI Master library for arduino.
    *
    * This file is free software; you can redistribute it and/or modify
    * it under the terms of either the GNU General Public License version 2
    * or the GNU Lesser General Public License version 2.1, both as
    * published by the Free Software Foundation.
    *
    * 2012-04-29 rick@kimballsoftware.com - added msp430 support.
    *
    */

    #ifndef _SPI_H_INCLUDED
    #define _SPI_H_INCLUDED

    #include <Energia.h>
    #include <inttypes.h>

    #if defined(__MSP430_HAS_USI__) || defined(__MSP430_HAS_USCI_B0__) || defined(__MSP430_HAS_USCI_B1__) || defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_EUSCI_B0__)
    #include "utility/spi_430.h"
    #endif

    #define SPI_MODE0 0
    #define SPI_MODE1 1
    #define SPI_MODE2 2
    #define SPI_MODE3 4

    class SPIClass {
    public:
    inline static uint8_t transfer(uint8_t _data);

    // SPI Configuration methods

    static void begin(); // Default
    static void end();

    static void setBitOrder(uint8_t);
    static void setDataMode(uint8_t);
    static void setClockDivider(uint8_t);

    inline static void attachInterrupt();
    inline static void detachInterrupt();
    };

    extern SPIClass SPI;

    uint8_t SPIClass::transfer(uint8_t _data) {
    return spi_send(_data);
    }

    void SPIClass::attachInterrupt() {
    /* undocumented in Arduino 1.0 */
    }

    void SPIClass::detachInterrupt() {
    /* undocumented in Arduino 1.0 */
    }

    #endif