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.

RTOS/CC1350: Problem with the TI-RTOS I2C example

Part Number: CC1350
Other Parts Discussed in Thread: CC1310

Tool/software: TI-RTOS

I'm currently trying to do some basic I2C comms work. My eventual goal is to talk to the mpu6050 but I was initially trying to get the I2c example from the resource explorer working. I'm monitoring the comms using the Saleae Logic to confirm if it is working. When I initially ran it I noticed that I wasn't detecting anything on IO4 or IO5 (the default pins), I then tried stepping through the code to see where the problem occurs. The I2C appears to initialise correctly but then during the I2C_transfer call, the program seems to hang. Stepping in deeper the line it fails on is

/*
 * Wait for the transfer to complete here.
 * It's OK to block from here because the I2C's Hwi will unblock
 * upon errors
 */
SemaphoreP_pend(&(object->transferComplete), SemaphoreP_WAIT_FOREVER);

I've got no idea why this might be the case but the only thing that is confusing me is that the code seems to be referencing the CC26XX family, which seems odd as this is an example for the cc1350, is this correct? if not what would the solution be? Does this example normally work? 

I've not had a huge ammount of experience with RTOS's in general and inparticular TI-RTOS so if I could get some help that would be great.

Thanks

George

  • Hello George,

    reference to CC26Xxxis o.k. Both CC13xx and CC26xx use the same subsystems.

    Could you provide the name of your example?
    Also, please provide information about your hardware, CCS, compiler and TI-RTOS versions,
    path, filename and line numbers for a code you have listed above.
  • Hi Tomasz,

    Thanks for your reply, in answer to your questions:

    • The example I am using is i2ctmp007 the link to it is here.
    • I'm running Code Composer 8.1.0 with the compiler version TI v18.1.3.LTS.
    • I'm not sure what RTOS version is running, in the project properties page (general tab > products ) the only box that is ticked is the Simplelink CC13x0 SDK version 2.20.0.38, there is a TI-RTOS aswell Version 2.21.1.08 and enabling that as well didn't seem to help. If I'm looking in the wrong place please let me know.
    • The line in question that I posted above is line 911 in I2CCC26XX.c, which on my system is located at: <system>\ti\simplelink_cc13x0_sdk_2_20_00_38\source\ti\drivers\i2c\,

  • It's probably also worth mentioning that I'm using the cc1350 launchpad
  • Hi George,

    before I started debugging, I have broken my CC1310 LP which is compatible with your LP at I2C drivers level.
    Probably an ESD issue. Not good start.

    I took another LP.
    First of all, really nasty piece of code and it does not work!
    Using resource explorer I have installed i2ctmp007 project.
    It has arrived from C:\ti\sail_1_20_00_02. Why? I do not know.
    Project properties shows that last release of this project was based on C:\ti\simplelink_cc13x0_sdk_1_60_00_21 which is much older than your version.
    I have moved to TI v16.9.8.LTS because TI v18.x.x uses different ABI.

    Maybe TI-RTOS recompilation would help. Probably tomorrow.
    I am pretty sure that this example was working under certain conditions.
  • So I tried downloading the simplelink cc13x0 sdk version 1.60.00.21, this didn't seem to work either and without digging in to it too far it does appear to be failing at the same point.

    Thanks George
  • I had no problem to run I2C on MSP432 and 5994 LPs with TI-RTOS and tasks, not pthreads.
  • Presumably that's a different example or does simple link cover all the differences? If so does that mean that the i2c on the cc1350 is broken in the lower level drivers?

  • Currently I have no project on CC1310. I have a big gap between an initial CC1310 release and a current s/w.
    Bear on mind that CC13x0 drivers reside in a chip memory.
    Chip hardware, drivers release, LP (LaunchPad), TI-RTOS, compiler versions have to be checked before a code analysis.
    Start with the first two on the list.
  • I'm sorry I must be being really slow. First two what? Devices? The msp432 and 5994? I don't have either of those? Or are you suggesting using those as an example for the cc1350? Or have I completely missed your meaning?
  • Check h/w release and driver library revisions.
  • I'm out the house at the moment so can't check either right now, I will do when I get back. But I did look the errata up (www.ti.com/.../swrz067) before posting on here, and I didn't see anything in there that looked relevant to this.
  • So I've checked and as far as I can tell there appears to only be a single silicon revision for the cc1350, which is 2.1, However the LP has had a few versions and I'm using v1.3, I doubt this has any relevance though.

    There appear to be several versions of the SDK that have been released

    • 2.20.00.38 (29 Jun 2018)
    • 2.10.00.36 (12 Apr 2018)
    • 1.60.00.21 (20 Dec 2017)
    • 1.50.00.08 (28 Sep 2017)
    • 1.40.00.10 (28 Jun 2017)
    • 1.30.00.06 (08 Mar 2017)
    • 1.00.00.13 (22 Nov 2016)

    I've tried both the most recent (2.20.00.38) and the one which you said was the one the example had been compiled for (1.60.00.21) neither of which seemed to help.

  • To run the i2ctmp007 example successfully on the CC1350LP you need to connect the Sensors Boosterpack (www.ti.com/.../boostxl-sensors) to the LP (as stated in the example's readme file).

    Siri
  • I have cc1310 LP rev. 1.3
    There were some issues related to 433 MHz and as I remember there were updates to silicon and driver libs.
    My cc1310 are older than coil.

    In your case I would recommend:
    - create an empty TI-RTOS project
    - read API for I2C and look for an I2C example for TI-RTOS
    - look for tmp007 libs within SAIL packages.

    API for I2C drivers is pretty straight forward.
    You can even start with mpu6050 to do not waste time on tmp007.
  • Siri,

    does your replay means that the i2ctmp007 example works on your CC1350LP?

    I have installed the i2ctmp007 example for CC1310LP and it does not work on my LP ver. 1.3 even with SDK ver. 1.60.00.21.
    But that is a different story.
  • George,

    I have it working with the newest SDK ver. 2.20.00.38.

    The example documentation says:
    1. Run the example. Board_GPIO_LED0 turns ON to indicate driver initialization is complete.
    2. The example will request temperature samples from the TMP007 and print them on the console. A total of 20 temperature samples are read/printed before the example exits. Console output should resemble:

    and later
    'getTempTask' - performs the following actions:

    There is no getTTempTask!
    Its job is served by mainThread.
    mainThread does:
    /* Open the HOST display for output */
    display = Display_open(Display_Type_UART, NULL);
    It does not use System_printf to write to the console as suggested at point 2.) above.
    This 'console' name is really misleading!.
    It opens a separate terminal to write to the host which is my laptop.

    XDS110 debugger probe used on CC13110LP (and 1350, I hope) uses two virtual COMs on the USB connection to the host.

    1. Connect only one LP via USB to your PC.
    2. Check in Windows Devices Manager -> Ports, there will be two ports listed - XDS110 Class Application/User UART (COM##) and XDS110 Class Auxilliary Data Port (COM##).
    3. Use View -> Terminal or open Putty or other terminal and use the COM port number for the XDS110 Class Application/User UART.
    4. Setup your terminal. In my case: COM3, baud rate 11500, data bits 8, stop bits 1, parity NONE, flow control NONE.
    5. You should now be able to type in a character in PUTTY and have it echoed back.

    Please mark your post as RESOLVED.

  • I do not have the boosterpack with the sensor on it, so I am not able to test that, but all examples are tested before they are released, and we have no reports about any problems with this code example. My point was simply that you cannot expect it to work if you do not have the boosterpack connected as long as the sensor the code is communication with is on the boosterpack and not on the LP itself.
  • Hello Siri,

    there are tons of non working examples.
    Please, give me your LaunchPad model with MSP430FRxxx MCU and I will show you a non working example.

    George, who has issued this post, is a beginner and needed help.
    If you carefully read this post, you would read that George and me have both not mentioned that drivers were not initialized (LED was on).
  • Tomasz

    If you have problems with MSP430 examples, I strongly suggest that you are posting that on the MSP Low-Power Microcontroller Forum and not here, as we are not supporting msp430.

    If you read my posts, I have never claimed that you or George have issues initializing the drivers. I simply asked George if he had had connected the sensor boosterpack needed by the i2ctmp007 example in the simplelink_cc13x0_sdk_2_20_00_38.

    If the sensor was not connected, the driver would be initialized just fine, but you would not be able to communicate over I2C since the sensor was not there.
  • Siri,

    agree with you, I do not know non working examples on sub 1 GHz LPs.
    You have said: but all examples are tested before they are released
    and I have switched my thinking to all examples.

    You: If the sensor was not connected, the driver would be initialized just fine, but you would not be able to communicate over I2C since the sensor was not there.
    My fault.
    In case of no sensor, LED0 would be turned on, however the message: "I2C Bus fault\n" would be sent to the console, which is not the console but the user application terminal.

    By the way, I have found a bug within the i2ctmp007.c example.
    Starting from line 112:

                /*
                 * If the MSB is set '1', then we have a 2's complement
                 * negative value which needs to be sign extended
                 */
    
                if (rxBuffer[0] & 0x80) {
                    temperature |= 0xF000;
                }
    
               /*
                * For simplicity, divide the temperature value by 32 to get rid of
                * the decimal precision; see TI's TMP007 datasheet
                */
                temperature /= 32;

    The temperature is declared as uint16_t.
    In case of negative values the temperature /= 32; statement makes rubbish.

    The temperature should be declared as int16_t.
    Within
    Display_printf(display, 0, 0, "Sample %u: %d (C)\n", i, (int) temperature);
    the temperature should be casted to int like above.

  • ok. I agree that there are 2 errors in the example;

    1) the comment in the code says:

    "Take 20 samples and print them out onto the console"

    While the readme file says:

    "•The example will request temperature samples from the TMP007 and print them via the UART. A total of 20 temperature samples are read/printed before the example exits. Terminal output should resemble"

    The code will print wrong numbers if the temperature is negative.

    The temperature variable should be changed from:

    uint16_t        temperature;

    to:

    int16_t        temperature;

    and

    Display_printf(display, 0, 0, "Sample %u: %d (C)\n", i, temperature);

    should be changed to:

    Display_printf(display, 0, 0, "Sample %u: %d (C)\n", i, (int16_t)temperature);

    Siri

  • One remark.

    The %d format applies to a signed int.
    In case of Cortex M0, M3, M4 and M7 32 bit MCU the int16_t conforms to short.
    I do recommend the cast to int type.
    It will give us no warnings and it would be fine on 64 bits platform.

  • Siri said:


    If the sensor was not connected, the driver would be initialized just fine, but you would not be able to communicate over I2C since the sensor was not there.

    I would have still expected the I2C to have worked to an extent, the first byte would have been transmitted and you'd have then not got an ACK from the slave. I was using a Saelea logic probe to check for that and I wasn't seeing anything appearing on the data or clock pins.
    I would also expect to see the message "I2C Bus fault\n", if the I2c had failed which was the expected result. The problem isn't so much that the I2C failed but that it failed in the way that it has done (i.e. hanging the whole program and not transmitting anything).
    I'm sorry for my slow replies over the last few days, I've been at a wedding with no access to computers, prior to doing that I did try altering the code as I had picked up on the display_prinf vs system_printf issue and had altered the code to read as below:
        GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
        System_printf("Starting the i2ctmp007 example\n");
    
        /* Create I2C for usage */
        I2C_Params_init(&i2cParams);
        i2cParams.bitRate = I2C_400kHz;
        i2c = I2C_open(Board_I2C_TMP, &i2cParams);
        if (i2c == NULL) {
            System_printf("Error Initializing I2C\n");
            while (1);
        }
        else {
           System_printf("I2C Initialized!\n");
        }
    
        /* Point to the T ambient register and read its 2 bytes */
        txBuffer[0] = TMP007_OBJ_TEMP;
        i2cTransaction.slaveAddress = Board_TMP_ADDR;
        i2cTransaction.writeBuf = txBuffer;
        i2cTransaction.writeCount = 1;
        i2cTransaction.readBuf = rxBuffer;
        i2cTransaction.readCount = 2;
    
        /* Take 20 samples and print them out onto the console */
        for (i = 0; i < 20; i++) {
            if (I2C_transfer(i2c, &i2cTransaction)) {
                /* Extract degrees C from the received data; see TMP102 datasheet */
                temperature = (rxBuffer[0] << 6) | (rxBuffer[1] >> 2);
    
                /*
                 * If the MSB is set '1', then we have a 2's complement
                 * negative value which needs to be sign extended
                 */
                if (rxBuffer[0] & 0x80) {
                    temperature |= 0xF000;
                }
               /*
                * For simplicity, divide the temperature value by 32 to get rid of
                * the decimal precision; see TI's TMP007 datasheet
                */
                temperature /= 32;
    
                System_printf("Sample %u: %d (C)\n", i, temperature);
            }
            else {
                System_printf("I2C Bus fault\n");
            }
    
            /* Sleep for 1 second */
            sleep(1);
        }
    
        /* Deinitialized I2C */
        I2C_close(i2c);
        System_printf("I2C closed!\n");

    This cause the output:

    Starting the i2ctmp007 example

    I2C Initialized!

    if the example had been working correctly, even without the sensorpack I should have still had more output than that.

  • I can't try this right now but I will give it a go later today, but I'm not convinced that this will fix the issue as I thought the code was getting stuck waiting for the I2C transfer to complete and it wasn't returning from there. Would this solution mean that under the bonnet the UART is capable of blocking the I2C?

  • I do recommend to do:
    uninstall your i2ctmp007 project with an option to delete all files,
    uninstall tirtos_builds_CC1350_LAUNCHPAD_release_ccs (you should see it in Project Explorer) with an option to delete all files,
    import the i2ctmp007 project example,
    build it with defaults,
    start debug and a terminal to watch System_printf(),
    debug.

    My local time is GMT+2.
  • Hi, ok so it works but I don't really understand what it was that was breaking it.

    Previously when I tried it it seemed to be hanging in the I2C section of the code if you stepped through it (though in fairness this could be a red herring). But more importantly, the logic analyser wasn't seeing any comms. and when I put a breakpoint on line 128 (Display_printf(display, 0, 0, "I2C Bus fault\n");) it would never trigger.

    Now I'm seeing comms using the logic analyser which looks to be correct device address and a register with NACKs due to the slave being absent, and the code is running to completion.

    But I had several attempts and redownloading the software (including tirtos_builds_CC1350_LAUNCHPAD_release_ccs). I don't understand what has now changed.

    The good news the is the problem seems to have gone so I can try talking to the MPU6050, I'd just like to know why. 

    I miss the days of simpler Micros :P

    George

  • Hi,

    it was my guessing that something, unintentionally, went wrong with TI-RTOS.

    30 years ago It was impossible to cope with these f..ing fat manuals.
    On Earth, there was not enough trees to print all errata sheets.
    We live in a post Guttenberg civilization.:-)

    Please mark this post as solved.
  • Hello,

    I've been into the same problem, and I observed that "hang up" only happens on RTSC-type of projects but not with the CCS-type ones.

    Regards,
    Elton
  • Elton,

    please, describe RTSC issue in a separate post.