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.

LAUNCHXL-CC1352R1: I2C Configuration

Part Number: LAUNCHXL-CC1352R1
Other Parts Discussed in Thread: SYSCONFIG,

Hello, I want to configure an I2C protocol with my CC1352 board and OV7670 camera. Based on the I2C reference, ı wrote the below code:

void i2cStart() {
// Initialize I2C driver
I2C_init();

// Initialize I2C parameters
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;

// Open I2C
i2cHandle = I2C_open(0, &i2cParams);
if (i2cHandle == NULL) {
// Handle I2C initialization error
return;
}
}

However, I don't know what should ı write on the first argument for I2C_open function. 

  • Hi Musa,

    Please have a look at the i2ctmp example of our SDK, as well as the documentation: https://dev.ti.com/tirex/explore/content/simplelink_cc13xx_cc26xx_sdk_7_10_02_23/docs/drivers/doxygen/html/_i2_c_8h.html

    It shows how to work with the driver, and SysConfig.

    Regards,

    Arthur

  • Thanks a lot, I looked there. However, I need some help on the below code:

    // Global variables
    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction = {0};
    void i2cStart(){
    // One-time init of I2C driver
    I2C_init();
    // initialize optional I2C bus parameters
    I2C_Params_init(&i2cParams);
    i2cParams.bitRate = I2C_400kHz;
    // Open I2C bus for usage
    i2cHandle = I2C_open(CC1352_I2C_INSTANCE, &i2cParams);
    if (i2cHandle == NULL) {
    // Error opening I2C
    while (1) {}
    }
    }

    In this function, 

    i2cHandle = I2C_open(CC1352_I2C_INSTANCE, &i2cParams);

    this line stops the function, for CC1352_I2C_INSTANCE = 0, this line is not working and there is no error message, CC1352_I2C_INSTANCE = 0x19, it goes to while loop and stocks. I observe this by step by step progress. How can I find the true value of CC1352_I2C_INSTANCE ? 

    Also, are there any printf vs function to print the output on the CCS ? System_printf() is not working.

  • Hi Musa,

    The instance has to be defined in the SysConfig tool. For instance, if you want to keep the same name as you have right now, it would look like this:

    As of the prints, you have several options, but you can for instance use the Display.h module, with Display_printf, as I have done in that E2E thread:

    https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1333776/cc1312r-queue-unable-to-delete-element

    Regards,

    Arthur

  • Thanks for the reply, as shown in the images, I got this error. How can I solve this?

    Thanks in advance.

  • Hi Musa,

    You can look at the generated SysConfig files, for instance, ti_drivers_config.h:

    Can you double check what constant is generated by SysConfig, and use that one in your program? 

    Make sure to save the SysConfig file prior to building.

    Regards,

    Arthur

  • This is ti_drivers_config.h, I couldn't solve the problem. I have 2 ti_drivers_config.c files, is this normal?

  • Hi Musa,

    This is not normal indeed, at least coming from a default example.

      

    Can you delete the file which is not generated by SysConfig? Basically, keep the one that is in the Debug\syscfg folder.

    Regards,

    Arthur

  • // Global variables
    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction = {0};
    void i2cStart(){
       // One-time init of I2C driver
       I2C_init();
       // initialize optional I2C bus parameters
       I2C_Params_init(&i2cParams);
       i2cParams.bitRate = I2C_400kHz;
       // Open I2C bus for usage
       i2cHandle = I2C_open(CC1352_IC2_INSTANCE_CONST, &i2cParams);
       if (i2cHandle == NULL) {
           // Error opening I2C
            while (1) {}
        }
    }

    With step-by-step observation, the code stuck on the line :  i2cHandle = I2C_open(CC1352_IC2_INSTANCE_CONST, &i2cParams);

    How can ı solve this problem, even it didn't return NULL?  Is this because of the function, or should it be a global variable ? 

    I really appreciate any help you can provide.

  • Part Number: LAUNCHXL-CC1352R1

    Hello, I want to connect a camera (OV7670) to my device with the I2C protocol. In my source file, I wrote a function like this : 

    void deviceInit(void) {

       I2C_init();
        // initialize optional I2C bus parameters
       I2C_Params_init(&i2cParams);
       i2cParams.bitRate = I2C_400kHz;
       // Open I2C bus for usage
       i2cHandle = I2C_open(CC1352_IC2_INSTANCE_CONST, &i2cParams);
       if (i2cHandle == NULL) {
       // Error opening I2C
           while (1) {}
       }

    }

    When I step through the code, it stops progressing at this line :  i2cHandle = I2C_open(CC1352_IC2_INSTANCE_CONST, &i2cParams);

    It even didn't return NULL. 

    // Global variables
    I2C_Handle i2cHandle;
    I2C_Params i2cParams;
    I2C_Transaction i2cTransaction = {0};

    I created these variables also on the source file.

    How can I solve this problem and make the connection working, any suggestion will be appreciated.

  • Hi Musa, 

    I joined these two threads, it seems to be referring to the same problem. 

    May I ask, what was your starting point for your project? 

    Arthur was referring to the i2ctmp example because it sets up everything you need to make the i2c driver to work.

    If you are using some other project as starting point, have you enabled i2c on sysconfig? 

    Regards,

    Sid

  • Hi, sorry for the late reply, If I understood you correctly, my starting point is the i2ctmp example. I have to set up the I2C connection between the device and the OV7670 camera module.  Since there is no example project I found, my only reference is the i2ctmp example. 

    I enabled i2c on sysconfig.

    As you can understand from my last question, Arthur's replies solved some problems with configuration, however, I still got stuck on the code part.

    Any suggestion or feedback will be appreciated.