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/CC1310: I2C slave implemetation

Part Number: CC1310
Other Parts Discussed in Thread: SYSBIOS

Tool/software: TI-RTOS

Hello,

I'm trying to use the CC1310 I2C slave controller in combination with TI-RTOS.

I have looked that the solution described in the following post, but due to power restrictions a task-driven polled implementation will not work in my setup... 

 

The documentation say that no slave controller driver is implemented, so I guess that I have to write my own...

When writing my own driver I get stuck on how to register interrupt service routines. I have tried to register my own interrupt service routines using the API-functions provided in driverlib\i2c.h, but I get compile/linker errors. I have traced the ISR registration problem and it seems that TI-RTOS takes control and moves the Interrupt vector table to RAM...

I also have trouble figuring out how the status and Interrupt flags work in the I2C slave controller. I have tried to write a polled driver based on the example above. When I try to detect start and stop conditions using that raw interrupt flags through SRIS the status flags in SSTAT is cleared, something I did not expect...

I would greatly appreciate help on how to register and get the I2C slave controller hardware interrupts to work with TI-RTOS or any other information that might help me get an I2C slave working.

Regards,

Lars Mattsson 

  • Hi Lars,

    Regarding the interrupt, I would recommend you register them using the TI-RTOS Hwi dispatcher as such:

    HwiP_Struct hwi;
    HwiP_Params hwiParams;
    
    HwiP_Params_init(&hwiParams);
    hwiParams.arg = *an argument if you want*;
    hwiParams.priority = intPriority;
    HwiP_construct(&hwi, interupNumber, interruptFunction, &hwiParams);

    This should help you get the interrupts working. Regarding the other part, if you are not able to solve it with the interrupts, could you provide code snippets showing your implementation?

  • Hi M-W 

    That seems to be what I'm looking for... 

    Regarding the  problem with the SSTAT flags I have probably figured out how to handle them... 

    Thank you for your prompt reply!

    Regards,

    Lars Mattsson

  • Hi M-W

    Unfortunately I get a linker error for HwiP_construct()

    Regards,

    Lars Mattsson

    making ../src/sysbios/rom_sysbios.aem3 ...

    gmake[2]: Nothing to be done for 'all'.

    Building target: "LCX_rfWakeOnRadio_HW3.out"

    Invoking: ARM Linker

    "C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/bin/armcl" -mv7M3 --code_state=16 -me -Ooff --define=ccs -g --diag_warning=225 --diag_warning=255 --diag_wrap=off --display_error_number --gen_func_subsections=on --abi=eabi -z -m"LCX_rfWakeOnRadio_HW3.map" --heap_size=0 --stack_size=256 -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/lib" -i"C:/ti/ccsv8/tools/compiler/ti-cgt-arm_18.1.3.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --absolute_exe --xml_link_info="LCX_rfWakeOnRadio_HW3_linkInfo.xml" --rom_model -o "LCX_rfWakeOnRadio_HW3.out" "./CC1310DK_7XD.obj" "./RFQueue.obj" "./aes_handler.obj" "./ccfg.obj" "./flash_int.obj" "./i2cioemulator_handler.obj" "./led_handler.obj" "./lockcase_handler.obj" "./mpu_init.obj" "./protocol.obj" "./rand31-park-miller-carta-int.obj" "./rfWakeOnRadio.obj" "./rf_driver.obj" "./rf_handler.obj" "./rng_handler.obj" "./scif_framework.obj" "./scif_lcx.obj" "./scif_osal_tirtos.obj" "./serviceport_handler.obj" "./timers.obj" "./uart_driver.obj" "./utils.obj" "./version_info.obj" "./smartrf_settings/smartrf_settings.obj" "../CC1310DK_7XD.cmd" -l"configPkg/linker.cmd" -l"C:/ti/tirtos_cc13xx_cc26xx_2_21_01_08/products/cc13xxware_2_04_03_17272/driverlib/bin/ccs/driverlib.lib" -llibc.a

    <Linking>

    undefined      first referenced          

     symbol            in file                

    ---------      ----------------          

    HwiP_construct ./i2cioemulator_handler.obj

    error #10234-D: unresolved symbols remain

    error #10010: errors encountered during linking; "LCX_rfWakeOnRadio_HW3.out" not built

    >> Compilation failure

    makefile:167: recipe for target 'LCX_rfWakeOnRadio_HW3.out' failed

    gmake[1]: *** [LCX_rfWakeOnRadio_HW3.out] Error 1

    gmake[1]: Target 'secondary-outputs' not remade because of errors.

    makefile:163: recipe for target 'all' failed

    gmake: *** [all] Error 2

    **** Build Finished ****

  • Hi Lars,

    Have you included the HwiP header file: #include <ti/drivers/dpl/HwiP.h> ?

    You could also use the "non-P" version (that would be, the TI-RTOS module and not the driver porting layer version), this makes the code portable to other devices using TI-RTOS.

    dev.ti.com/.../index.html

  • Hi M-W 

    Now it works!

    The #include <ti/drivers/dpl/HwiP.h> was there... 

    Instead of using HwiP_construct() I used HwiP_create() followed by HwiP_enableInterrupt(), see below:

        #include <ti/drivers/dpl/HwiP.h>
        #include <driverlib/i2c.h>
        
        static HwiP_Params i2cHwiParams;
    
        // Init I2C slave hardware
        I2CSlaveInit(I2C0_BASE, I2C_SLAVEADDR);
        // Clear all interrupt flags
        I2CSlaveIntClear(I2C0_BASE, I2C_SLAVE_INT_STOP | I2C_SLAVE_INT_START | I2C_SLAVE_INT_DATA );
        // Enable all interrupt sources
        I2CSlaveIntEnable( I2C0_BASE, I2C_SLAVE_INT_STOP | I2C_SLAVE_INT_START | I2C_SLAVE_INT_DATA );
    
        // Construct the I2C hardware interrupt
        HwiP_Params_init(&i2cHwiParams);
        i2cHwiParams.arg = 0;
        i2cHwiParams.priority = ~0;
        HwiP_create( INT_I2C_IRQ, &2CInterruptServiceRoutine, &i2cHwiParams);
    
        HwiP_enableInterrupt(INT_I2C_IRQ);
    
        // Enable I2C reception
        I2CSlaveEnable(I2C0_BASE);

    Based on the linker output I don't think that HwiP_construct() is a part of the TI-RTOS referenced from my project (tirtos_cc13xx_cc26xx_2_21_01_08).

    I'm pretty new to the TI-RTOS and the driver libraries ... quite a learning curve with all include files and API calls that exist in multiple versions... 

    Many thanks!

    Regards,

    Lars Mattsson

     

  • Hi Lars,

    Glad you got it to work, strange however that construct did not link as expected as it is part of the DPL. The TI-RTOS kernel are delivered as part of the SimpleLink CC13x0 SDK, so I would expect the location of this to be inside "<SDK>/kernel/tirtos". Have you possibly downloaded the TI-RTOS as an external component?
  • Hi M-W

    That might be the case...

    I don't remember exactly what packages I installed at the beginning but it looks like I have both the simplelink_cc13x0_sdk_2_20_00_38 and the tirtos_cc13xx_cc26xx_2_21_01_08 packages installed and included from my project.

    ... and from your comment I take it that I should only have the simplelink_cc13x0_sdk_2_20_00_38... or?

    Regards,

    Lars Mattsson
  • Hi Lars,

    That is correct, as TI-RTOS is included as part of the SImpleLink SDK, you should not need to also use the stand-alone TI-RTOS package.