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.

CC1120EMK-420-470: generate the output of RSSI using GPIO (PWM, timer) in CC1120 Evaluation Module Kit with SmartRF Transceiver Evaluation Board

Part Number: CC1120EMK-420-470
Other Parts Discussed in Thread: CC1120

Hello, I am trying to use CC1120EMK-420-470 board to get the output of RSSI, using GPIO (PWM, timer) of MSP430 (smartRF transceiver board).

smartRF transceiver board can read the RSSI value in LCD screen, but also could I get RSSI value via GPIO? I hope to get the RSSI value and store in the variable, then convert RSSI value to PWM to convert  different DC values, based on the RSSI values. 

could you provide link for some example code for that? or suggest the way to get RSSI value?

Thanks!

  • It's not possible to get the RSSI value on a GPIO. The RSSI value is stored in a register and a register value can only be read through the SPI interface. See "6.9 RSSI" in the UserGuide. 

  • Hi there!

    We received the IAR Embedded Workbench IDE code for the MSP430 SmartRF TrxEB PCB that communicates and works with the CC1120 daughter board. The zipped folder that was sent to us was called swrc219c and this contained the project files we are referring to. Modifying the main function of that code, I suppressed some of the program that runs the LCD and copied and pasted a couple RSSI functions from the cc112x_sniff_mode_api.c file to read the RSSI through the SPI interface. I also added a couple functions to convert the RSSI value to a string and then print those values to the serial port, which I am reading externally using a FTDI cable and serial monitor. Currently the read RSSI response is a constant value, but that makes sense because the CC1120 module has not been configured and turned on. Below is the edited main.c code that we currently have (it was not letting us upload the code with the >insert >code option for some reason): 

    .

    .

    .

    //*****************************************************************************
    //! @file main.c
    //
    //! @brief This file implements the startup of the board and and a menu
    // menu driver.
    //
    // Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
    //
    //
    // Redistribution and use in source and binary forms, with or without
    // modification, are permitted provided that the following conditions
    // are met:
    //
    // Redistributions of source code must retain the above copyright
    // notice, this list of conditions and the following disclaimer.
    //
    // Redistributions in binary form must reproduce the above copyright
    // notice, this list of conditions and the following disclaimer in the
    // documentation and/or other materials provided with the distribution.
    //
    // Neither the name of Texas Instruments Incorporated nor the names of
    // its contributors may be used to endorse or promote products derived
    // from this software without specific prior written permission.
    //
    // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    //****************************************************************************/

    /******************************************************************************
    * INCLUDES
    */

    #include <msp430.h>
    #include "trx_rf_spi.h"
    #include "chip_detect.h"
    #include "freq_xosc_detect.h"
    #include "per_test.h"
    #include "main_graphics.c"
    #include "menu_system.h"
    #include "menu_driver.h"
    #include "sniff_mode.h"
    #include "chip_information.h"
    #include "easyLink.h"

    #include "lcd_dogm128_6.h"
    #include "bsp.h"
    #include "bsp_key.h"
    #include "bsp_led.h"

    //additional includes (not sure if all of them are necessary at this point)
    #include "cc112x_sniff_mode_api.h"
    #include "trx_rf_int.h"
    #include "trx_rf_spi.h"
    #include "menu_driver.h"
    #include "sniff_mode.h"
    #include "cc112x_spi.h"
    #include "cc120x_spi.h"

    void SerialPort_setup(void);
    void SerialPort_writeString(char *message);

    int intToStr(int x, char str[], int d);
    void reverse(char* str, int len);


    /******************************************************************************
    * GLOBAL VARIABLES
    */
    extern uint8 mclkFrequency;

    char version[] = "v4.3"; // Version number (versions from 4.0 includes CC120x support)

    /******************************************************************************
    * LOCAL FUNCTIONS
    */
    static uint8 contrastApp(void **pVoid);

    /******************************************************************************
    * The Main Menu
    */

    menu_t mainMenu;
    menu_t contrastMenu;

    menuItem_t mainMenuItems[] =
    {
    {0x00,"1","PER Test" ,0,&perAbstractHeadMenu ,0,&perChipSelectApp ,0},
    {0x00,"2","EasyLink Test" ,0,&easyLinkMainMenu ,0,&initEasyLink ,0},
    {0x00,"3","RX Sniff Test" ,0,&sniffModeFrequencyMenu ,0,&sniffInitApp ,0},
    {0x00,"4","Chip Information" ,0,&chipInfoMenu ,0,&chipInfoApp ,0},
    {0x00,"5","Set Contrast" ,0,&contrastMenu,0,0,0},
    {M_DISABLED,0,0,0,0,0,0,0},
    {M_DISABLED|M_STRING|M_RIGHT,0,0,version,0,0,0,0}
    };

    static const menuItem_t contrastMenuItems[] =
    {
    {0x00,"1","High",0,0,0 ,&contrastApp,(void**)20},
    {0x00,"2","Medium",0,0,0,&contrastApp,(void**)25},
    {0x00,"3","Low",0,0,0 ,&contrastApp,(void**)30}
    };

    menu_t contrastMenu =
    {
    (menuItem_t*)contrastMenuItems, /* pItems */
    &mainMenu, /* pParentMenu */
    0, /* pMenuGraphics */
    "Select Contrast", /* pTextHeader */
    "3", /* pTextMenuItems */
    3, /* nMenuItems */
    0, /* nCurrentItem */
    0, /* nSelectedItem */
    0, /* nScreen */
    0 /* reservedAreas */
    };

    menu_t mainMenu =
    {
    (menuItem_t*)mainMenuItems, /* pItems */
    0, /* pParentMenu */
    0, /* pMenuGraphics */
    "Main Menu", /* pTextHeader */
    "5", /* pTextMenuItems */
    7, /* nMenuItems */
    0, /* nCurrentItem */
    -1, /* nSelectedItem */
    0, /* nScreen */
    0 /* reservedAreas */
    };

    /******************************************************************************
    * @fn main
    *
    * @brief Main handles all applications attached to the menu system
    *
    * input parameters
    *
    * output parameters
    *
    *@return
    */
    void main( void )
    {

    // Init clocks and I/O
    bspInit(BSP_SYS_CLK_16MHZ);

    // Init leds
    // bspLedInit();

    // Init Buttons
    // bspKeyInit(BSP_KEY_MODE_POLL);

    // Initialize SPI interface to LCD (shared with SPI flash)
    // bspIoSpiInit(BSP_FLASH_LCD_SPI, BSP_FLASH_LCD_SPI_SPD);

    /* Init Buttons */
    // bspKeyInit(BSP_KEY_MODE_ISR);
    // bspKeyIntEnable(BSP_KEY_ALL);
    /* Init LCD and issue a welcome */
    //lcdInit();
    //lcdClear();
    // Instantiate tranceiver RF spi interface to SCLK ~ 4 MHz */
    //input clockDivider - SMCLK/clockDivider gives SCLK frequency
    trxRfSpiInterfaceInit(0x10);

    /* Welcome Screen Part */
    //lcdSendBuffer(trxebWelcomeScreen);
    //lcdBufferPrintString(lcdDefaultBuffer,"TEXAS",60,eLcdPage6);
    //lcdBufferPrintString(lcdDefaultBuffer,"INSTRUMENTS",60,eLcdPage7);
    //lcdSendBufferPart(lcdDefaultBuffer, 60,127,eLcdPage6, eLcdPage7);
    /* MCU will stay in sleep until button is pressed */
    //__low_power_mode_3();
    //bspKeyPushed(BSP_KEY_ALL);
    //Clear screen
    //lcdBufferClear(0);

    static int8 rssi;
    static uint8 rssi_readout;

    static uint8 cc112xRssiOffset = 96;

    uint8 rxBytes;

    char rssiString[30];

    //need to setup RX frequency, bandwidth
    //cc112xSpiWriteReg(uint16 addr, uint8 *pData, uint8 len)?
    //sniffModeFreqConfig(void** pFreqIndex)?

    SerialPort_setup();

    while(1)
    {
    //need to put RF chip in RX mode
    //cc112xSpiWriteReg(uint16 addr, uint8 *pData, uint8 len)?
    //trxSpiCmdStrobe(uint8 cmd)?

    //read RSSI
    cc112xSpiReadReg(CC112X_RSSI1,&rssi_readout,1);
    // Convert to decimal value from 2's complement rssi_readout.
    //rssi = (int16)((int8)rssi_readout) - cc112xRssiOffset;
    rssi = (int)((int8)rssi_readout) - cc112xRssiOffset;

    //print RSSI value to serial port
    intToStr(rssi, rssiString, 0);
    SerialPort_writeString("RSSI: ");
    SerialPort_writeString(rssiString);

    //print raw rssi value
    intToStr((int)rssi_readout, rssiString, 0);
    SerialPort_writeString(" rssi_readout: ");
    SerialPort_writeString(rssiString);

    SerialPort_writeString(" \r\n");

    //turn off RX mode
    // Put radio in powerdown to save power
    trxSpiCmdStrobe(CC112X_SPWD);

    //add delay
    }


    /* Menu Driver */
    // menu_t *pCurrentMenu = &mainMenu;
    // uint8 menuButtonsPressed;
    // menuDisplay(pCurrentMenu);
    // __low_power_mode_3();
    // while(1)
    // {
    // menuButtonsPressed = bspKeyPushed(BSP_KEY_ALL);
    // switch(menuButtonsPressed)
    // {
    // case BSP_KEY_LEFT:
    // pCurrentMenu = menuBack(pCurrentMenu);
    // break;
    // case BSP_KEY_RIGHT:
    // pCurrentMenu = menuEnter(pCurrentMenu);
    // break;
    // case BSP_KEY_DOWN:
    // menuDown(pCurrentMenu);
    // break;
    // case BSP_KEY_UP:
    // menuUp(pCurrentMenu);
    // break;
    // default:
    // break;
    // }
    // menuDisplay(pCurrentMenu);
    // /* Enter low power mode while menu driver waits on user input */
    // __low_power_mode_3();
    // }
    }


    static uint8 contrastApp(void **pVoid)
    {
    uint16 c = (uint16)*pVoid;
    lcdSetContrast(c&0x00FF);
    return 0;
    }

    void SerialPort_setup(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT

    P3SEL = 0x30; // P3.4,5 = USCI_A0 TXD/RXD
    UCA0CTL1 |= UCSWRST; // **Put state machine in reset**
    UCA0CTL1 |= UCSSEL_2; // SMCLK
    UCA0BR0 = 139; // 1MHz 115200 (see User's Guide) was 9
    UCA0BR1 = 0; // 1MHz 115200
    UCA0MCTL |= UCBRS_1 + UCBRF_0; // Modulation UCBRSx=1, UCBRFx=0
    UCA0CTL1 &= ~UCSWRST; // **Initialize USCI state machine**
    //UCA0IE |= UCRXIE; // Enable USCI_A0 RX interrupt

    //__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, interrupts enabled
    //__no_operation(); // For debugger
    }

    void SerialPort_writeString(char *message)
    {
    while (!(UCA0IFG&UCTXIFG));

    while (*message)
    {
    UCA0TXBUF = *message++; // transmit byte
    __no_operation();
    while (!(UCA0IFG&UCTXIFG)); // wait until transmit buffer is empty
    }
    }

    // Converts a given integer x to string str[].
    // d is the number of digits required in the output.
    // If d is more than the number of digits in x,
    // then 0s are added at the beginning.
    int intToStr(int x, char str[], int d)
    {
    int i = 0;
    while (x) {
    str[i++] = (x % 10) + '0';
    x = x / 10;
    }

    // If number of digits required is more, then
    // add 0s at the beginning
    while (i < d)
    str[i++] = '0';

    reverse(str, i);
    str[i] = '\0';
    return i;
    }

    // Reverses a string 'str' of length 'len'
    void reverse(char* str, int len)
    {
    int i = 0, j = len - 1, temp;
    while (i < j) {
    temp = str[i];
    str[i] = str[j];
    str[j] = temp;
    i++;
    j--;
    }
    }

    .

    .

    .

    Basically, I am trying to figure out how to setup/initialize the receiver of the CC1120 board to set the frequency and bandwidth and also how to initiate a receive cycle so that we can take a RSSI value. Can you point us to some sample code or where to find the possible inputs that the trxSpiCmdStrobe(uint8 cmd) and cc112xSpiWriteReg(uint16 addr, uint8 *pData, uint8 len) functions take?

    Thanks!

  • - Settings: A lot of the required register settings can be found using SmartRF Studio. The program can be used without anything connected enabling you to write in, as an example, the frequency you are interested in and then calculating the register values. 

    Have you also looked at https://www.ti.com/lit/zip/swrc253? 

  • Thanks for information! I solved the problems. regarding the RSSI, I would like to know the Received signal strength at antenna (RSSI shows the strength at transceiver), for that I try to find the attenuation (loss) between antenna and transceiver (cc1120) in CC1120EMK-420-470 evaluation board, but I could not find any information. could I ask information for that?

    Thanks!