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.

CC115L: CC115L interface with MSPM0

Part Number: CC115L

hi All,

currently I'm working with CC115l with MSPM0 and have some difficulties to send some messages. I have already evaluate the circuit using using SmartRF via CC debugger and it successfully work with one of legacy rf receiver.

could you please rereview my following code and please help to develop a proper program flow.

Kind regards

Staneslouse

spi_peripheral_echo_interrupts.c
/*
 * Copyright (c) 2020, Texas Instruments Incorporated
 * All rights reserved.
 *
 * 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.
 */

#include "ti/driverlib/dl_spi.h"
#include "ti/driverlib/m0p/dl_core.h"
#include "ti_msp_dl_config.h"
#include <sys/_intsup.h>
#include <sys/_stdint.h>

/* Data for SPI to transmit and receive */
volatile uint8_t gData;
// volatile uint8_t setting_Data;
// volatile uint8_t parring_Data;
// volatile uint8_t relayOn_Data;
#define SIDLE 0x36 // CC115L Strobe for Idle
#define SFSTXON 0x31 // CC115L frequency calibration
#define STX 0x35 // CC115L enable transmite


uint8_t  cc115L_Rf_init_Settings[100] = 

{0x00, 0x2E, 
0x01, 0x2E, 
0x02, 0x06,
0x03, 0x47,
0x04, 0xAC,
0x05, 0x69,
0x06, 0x06,
0x07, 0x00,
0x08, 0x04,
0x09, 0x00,
0x0A, 0x00,
0x0B, 0x00,
0x0C, 0x00,
0x0D, 0x10,
0x0E, 0x12,
0x0F, 0x34,
0x10, 0xF6,
0x11, 0x37,
0x12, 0x31,
0x13, 0x42,
0x14, 0xE5,
0x15, 0x14,
0x16, 0x00,
0x17, 0x30,
0x18, 0x18,
0x19, 0x00,
0x1A, 0x00,
0x1B, 0x00,
0x1C, 0x00,
0x1D, 0x00,
0x1E, 0x00,
0x1F, 0x00,
0x20, 0x00,
0x21, 0x00,
0x22, 0x11,
0x23, 0xE9,
0x24, 0x2A,
0x25, 0x00,
0x26, 0x1F,
0x27, 0x00,
0x28, 0x00,
0x29, 0x59,
0x2A, 0x7F,
0x2B, 0x3F,
0x2C, 0x81, 
0x2D, 0x35,
0x2E, 0x09, 
0x2F, 0x00,
0x7E, 0x3F,
0x00, 0x84,

};

uint8_t  cc115L_Rf_paring_message[7] = 

{0x7F, 0x69, 
0xa5, 0x56,
0x55, 0x66, 0x99,
};

uint8_t  cc115L_Rf_relay_on_message[7] = 

{0x7F, 0x69, 
0xa5, 0x55,
0x55, 0x66, 0xa5,
};

/*SPI commands send to initiate CC115L */
void CC115L_init(void){
    
DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);
delay_cycles(20000);
    int i = 0;
    for (i = 0; i < 100; i++) {
        // while (DL_SPI_isBusy(SPI_0_INST))
        // ;
        //setting_Data = cc115L_Rf_init_Settings[i];   
        DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_init_Settings[i]);
    }
    DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);
}
/* SPI send Idle Strobe*/
void SPI_send_Idle_Strobe(void){

//  while (DL_SPI_isBusy(SPI_0_INST))
//         ;
    
        DL_SPI_transmitData8(SPI_0_INST, SIDLE);

}

/* SPI send frequency calibration Strobe*/
void SPI_send_SFSTXON_Strobe(void){

//  while (DL_SPI_isBusy(SPI_0_INST))
//        ;
        DL_SPI_transmitData8(SPI_0_INST, SFSTXON);

}

/* SPI send TX Strobe*/
void SPI_send_TX_Strobe(void){

//  while (DL_SPI_isBusy(SPI_0_INST))
//         ;
        DL_SPI_transmitData8(SPI_0_INST, STX);

}


void SPI_send_relay_On_message(void){
DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);

    int j = 0;
    for (j = 0; j < 7; j++) {
//  while (DL_SPI_isBusy(SPI_0_INST))
//         ;
        //relayOn_Data = cc115L_Rf_relay_on_message[j];   
        DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_relay_on_message[j]);



}
DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);
}
void SPI_send_pair_message(void){
DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);

    int k = 0;
    for (k = 0; k < 7; k++) {
//  while (DL_SPI_isBusy(SPI_0_INST))
//         ;
          
        DL_SPI_transmitData8(SPI_0_INST, cc115L_Rf_paring_message[k]);



}
DL_GPIO_setPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);
}


int main(void)
{
    SYSCFG_DL_init();

    NVIC_ClearPendingIRQ(SPI_0_INST_INT_IRQN);
    NVIC_EnableIRQ(SPI_0_INST_INT_IRQN);
    CC115L_init();
    SPI_send_Idle_Strobe(); //send Idle 
    SPI_send_SFSTXON_Strobe();// send frequency calibration Strobe
    SPI_send_pair_message();// write to TX FIFO
    SPI_send_TX_Strobe(); // strobe for transmite
    //SPI_send_Idle_Strobe(); //send Idle 
    delay_cycles(100);
    //SPI_send_FSTXON_Strobe();// send frequency calibration Strobe
    SPI_send_pair_message();// write to TX FIFO
    SPI_send_TX_Strobe(); // strobe for transmite
    delay_cycles(100);
    SPI_send_pair_message();// write to TX FIFO
    SPI_send_TX_Strobe(); // strobe for transmite
    delay_cycles(100);
    //SPI_send_Idle_Strobe();
    SPI_send_relay_On_message();
    SPI_send_TX_Strobe();
    SPI_send_Idle_Strobe();

    //gData = 1;

    while (1) {
        /* Wait for interrupt until a push button is pressed */
        __WFI();
    }
}

void SPI_0_INST_IRQHandler(void)
{
    switch (DL_SPI_getPendingInterrupt(SPI_0_INST)) {
        case DL_SPI_IIDX_RX:
         //DL_GPIO_clearPins(GPIO_SPI_0_CS_PORT, GPIO_SPI_0_CS_PIN);
            /* Read RX FIFO and echo it back to the SPI Controller */
            // gData = DL_SPI_receiveData8(SPI_0_INST);
            
            // SPI_send_pair_message();
            // SPI_send_relay_On_message();

            /* Toggle the Blue LED after data reception */
            DL_GPIO_togglePins(GPIO_LEDS_PORT, GPIO_LEDS_USER_LED_1_PIN);
            

            break;
        default:
            break;
    }
}

  • Hi Staneslouse,

    This seems like code that runs on MSP. I am assigning it to the MSP organization. 

    It is more likely to get better help on this forum, if you ask specific questions. For instance, in your case, please be more specific regarding the behavior you see (status/error)etc. 

    Regards,

    Sid

  • Hi

    I looked at your code, and there are several things you need to check.

    First of all, you should start off with configuring the radio with a list of settings given by SmartRF Studio.

    Do not write to other registers than what Studio recommend.

    For example, what are you trying to do with these registers?:


    0x7E, 0x3F,
    0x00, 0x84,

    Also, I do not understand your use of Chip select.

    you are not setting/clearing chip select when you for example send a strobe command.

    To send a 7 byte packet on the air (without length byte) the following steps are required:

    // Pseudo code
    
    // Reset radio
    trxSpiCmdStrobe(CC1101_SRES);
    
    // Write registers to radio
    for(uint16 i = 0; i < (sizeof(preferredSettings)/sizeof(registerSetting_t)); i++)
    {
        writeByte = preferredSettings[i].data;
        cc1101SpiWriteReg(preferredSettings[i].addr, &writeByte, 1);
    }
    
    cc1101SpiWriteReg(CC1101_PA_TABLE0, paTable, sizeof(paTable));
    
    // Write packet to TX FIFO
    cc1101SpiWriteTxFifo(txBuffer,sizeof(txBuffer));
    
    // Strobe TX to send packet
    trxSpiCmdStrobe(CC1101_STX);
    
    // Wait for falling edge of GPIO0 (packet sent)
    
    

    Start by using known good settings from SmartRF Studio.

    Below are the settings for 2.4 kbps, modified to support fixed packet length (since your packet does not contain a length byte):

    static const registerSetting_t preferredSettings[]=
    {
        {CC115L_IOCFG2, 0x2E},
        {CC115L_IOCFG0, 0x06},
        {CC115L_FIFOTHR, 0x47},
        {CC115L_PKTLEN, 0x07},
        {CC115L_PKTCTRL0, 0x04},
        {CC115L_FREQ2, 0x21},
        {CC115L_FREQ1, 0x62},
        {CC115L_FREQ0, 0x76},
        {CC115L_MDMCFG4, 0xF6},
        {CC115L_MDMCFG3, 0x83},
        {CC115L_MDMCFG2, 0x13},
        {CC115L_DEVIATN, 0x15},
        {CC115L_MCSM0, 0x18},
        {CC115L_RESERVED_0X20, 0xFB},
        {CC115L_FSCAL3, 0xE9},
        {CC115L_FSCAL2, 0x2A},
        {CC115L_FSCAL1, 0x00},
        {CC115L_FSCAL0, 0x1F},
        {CC115L_TEST2, 0x81},
        {CC115L_TEST1, 0x35},
        {CC115L_TEST0, 0x09},
    };
    
    
    
    

    Siri

  • hi Siri, 

    thank you for your reply, I got your point and  0x7E, 0x3F used for PA is not the way to set up the power?

    I will update further after those modifications that you mentioned earlier.

    Kind regards

    Staneslouse

  • 0x7E is trying to tell the PA table that you are doing a burst access, and a burst access lasts until CSn is pulled high again. That means that you are trying to write 3 bytes (0x3F, 0x00, 0x84) to a table that is 2 bytes.

    Please see 5.5.6 PATABLE Access in the data sheet on how the PA table should be programmed.

    Siri