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.

CC2340R5: How to define PINs originally in Board.h

Part Number: CC2340R5
Other Parts Discussed in Thread: CC2640R2F, SYSCONFIG,

Hi TI members,

Below is my building environment:

Software

Version

Code Composer Studio

12.3.0.00005 

SimpleLink SDK

7.10.00.35

XDCtools

3.62.1.16_core

We are working on migrating an old project from CC2640R2F to CC2340R5.

In C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\source\ti\ble5stack\boards\CC2640R2DK_4XS\Board.h, we could see these PINs defined:

But we don't know how to define these PINs in CC2340R5.

There wouldn't be a Board.h file in this example as this document has stated.

Then, how should we do what Board.h has done in our CC2340R5 project?

And what is the relationship between the PINs defined in Board.h and these DIO shown in CC2640R2F's document (www.ti.com/.../cc2640r2f)

Thanks.

BR,

  • Hi,

    The pin instances (now called GPIOs on CC23xx devices) are generated by SysConfig.

    You should use SysConfig to define the GPIOs instances you need.

    I hope this will help,

    Best regards,

  • What about the relationship between the PINs defined in Board.h and the DIOs in the snapshot?

    How can I map the PINs to those DIOs?

  • Hi,

    In the CC2640R2F code base, you should find the file CC2640R2_LAUNCHXL.c/.h (included from the file board.c and cc2640r2lp_board.c) providing the "translation" pin-instance to GPIO.

    For your reference, here is an extract of the file included in the SDK (it may have been slightly modified for your project):

    /* Analog Capable DIOs */
    #define CC2640R2_LAUNCHXL_DIO23_ANALOG          IOID_23
    #define CC2640R2_LAUNCHXL_DIO24_ANALOG          IOID_24
    #define CC2640R2_LAUNCHXL_DIO25_ANALOG          IOID_25
    #define CC2640R2_LAUNCHXL_DIO26_ANALOG          IOID_26
    #define CC2640R2_LAUNCHXL_DIO27_ANALOG          IOID_27
    #define CC2640R2_LAUNCHXL_DIO28_ANALOG          IOID_28
    #define CC2640R2_LAUNCHXL_DIO29_ANALOG          IOID_29
    #define CC2640R2_LAUNCHXL_DIO30_ANALOG          IOID_30
    
    /* Digital IOs */
    #define CC2640R2_LAUNCHXL_DIO0                  IOID_0
    #define CC2640R2_LAUNCHXL_DIO1_RFSW             IOID_1
    #define CC2640R2_LAUNCHXL_DIO12                 IOID_12
    #define CC2640R2_LAUNCHXL_DIO15                 IOID_15
    #define CC2640R2_LAUNCHXL_DIO16_TDO             IOID_16
    #define CC2640R2_LAUNCHXL_DIO17_TDI             IOID_17
    #define CC2640R2_LAUNCHXL_DIO21                 IOID_21
    #define CC2640R2_LAUNCHXL_DIO22                 IOID_22
    
    /* Discrete Inputs */
    #define CC2640R2_LAUNCHXL_PIN_BTN1              IOID_13
    #define CC2640R2_LAUNCHXL_PIN_BTN2              IOID_14
    
    /* GPIO */
    #define CC2640R2_LAUNCHXL_GPIO_LED_ON           1
    #define CC2640R2_LAUNCHXL_GPIO_LED_OFF          0
    
    /* I2C */
    #define CC2640R2_LAUNCHXL_I2C0_SCL0             IOID_4
    #define CC2640R2_LAUNCHXL_I2C0_SDA0             IOID_5
    
    /* I2S */
    #define CC2640R2_LAUNCHXL_I2S_ADO               IOID_0
    #define CC2640R2_LAUNCHXL_I2S_ADI               IOID_1
    #define CC2640R2_LAUNCHXL_I2S_BCLK              IOID_30
    #define CC2640R2_LAUNCHXL_I2S_MCLK              PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_I2S_WCLK              IOID_29
    
    /* LCD (430BOOST - Sharp96 Rev 1.1) */
    #define CC2640R2_LAUNCHXL_LCD_CS                IOID_24 /* SPI chip select */
    #define CC2640R2_LAUNCHXL_LCD_EXTCOMIN          IOID_12 /* External COM inversion */
    #define CC2640R2_LAUNCHXL_LCD_ENABLE            IOID_22 /* LCD enable */
    #define CC2640R2_LAUNCHXL_LCD_POWER             IOID_23 /* LCD power control */
    #define CC2640R2_LAUNCHXL_LCD_CS_ON             1
    #define CC2640R2_LAUNCHXL_LCD_CS_OFF            0
    
    /* LEDs */
    #define CC2640R2_LAUNCHXL_PIN_LED_ON            1
    #define CC2640R2_LAUNCHXL_PIN_LED_OFF           0
    #define CC2640R2_LAUNCHXL_PIN_RLED              IOID_6
    #define CC2640R2_LAUNCHXL_PIN_GLED              IOID_7
    
    /* PWM Outputs */
    #define CC2640R2_LAUNCHXL_PWMPIN0               CC2640R2_LAUNCHXL_PIN_RLED
    #define CC2640R2_LAUNCHXL_PWMPIN1               CC2640R2_LAUNCHXL_PIN_GLED
    #define CC2640R2_LAUNCHXL_PWMPIN2               PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_PWMPIN3               PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_PWMPIN4               PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_PWMPIN5               PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_PWMPIN6               PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_PWMPIN7               PIN_UNASSIGNED
    
    /* SPI */
    #define CC2640R2_LAUNCHXL_SPI_FLASH_CS          IOID_20
    #define CC2640R2_LAUNCHXL_FLASH_CS_ON           0
    #define CC2640R2_LAUNCHXL_FLASH_CS_OFF          1
    
    /* SPI Board */
    #define CC2640R2_LAUNCHXL_SPI0_MISO             IOID_8          /* RF1.20 */
    #define CC2640R2_LAUNCHXL_SPI0_MOSI             IOID_9          /* RF1.18 */
    #define CC2640R2_LAUNCHXL_SPI0_CLK              IOID_10         /* RF1.16 */
    #define CC2640R2_LAUNCHXL_SPI0_CSN              PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_SPI1_MISO             PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_SPI1_MOSI             PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_SPI1_CLK              PIN_UNASSIGNED
    #define CC2640R2_LAUNCHXL_SPI1_CSN              PIN_UNASSIGNED
    
    /* UART Board */
    #define CC2640R2_LAUNCHXL_UART_RX               IOID_2          /* RXD */
    #define CC2640R2_LAUNCHXL_UART_TX               IOID_3          /* TXD */
    #define CC2640R2_LAUNCHXL_UART_CTS              IOID_19         /* CTS */
    #define CC2640R2_LAUNCHXL_UART_RTS              IOID_18         /* RTS */

    Note that "IOID_x" and "DIO_x" refer to the same physical resource.

    I hope this will help,

    Best regards,

  • Hi,

    Thanks for the information!

    Does that mean I shall put those defined items like this?

    I took "

    /* GPIO */
    #define CC2640R2_LAUNCHXL_GPIO_LED_ON 1" for example.



    If the above setting is correct, 
    Then, if I would like to define "

    /* Discrete Inputs */
    #define CC2640R2_LAUNCHXL_PIN_BTN1              IOID_13

    ", what should I set in column "GPIO pin"?

    Thanks.

    BR,

  • Hi,

    The symbol "CC2640R2_LAUNCHXL_GPIO_LED_ON" is rather used to describe a GPIO level (i.e. 1 or 0). I don't think it makes sense to define it with SysConfig this way.

    For the symbol "CC2640R2_LAUNCHXL_PIN_BTN1", you should define a GPIO instance "CC2340R5_PIN_BTN1" (or different name, this is up to you).

    You can take the drivers example (especially the gpiointerrupt example when you are dealing with buttons) as model:

    Similarly, if you wish to define a UART, I2C, SPI, ADC, etc., you can use the corresponding drivers example stored in <SDK>\examples\rtos\LP_EM_CC2340R5\drivers

    I hope this will help,

    Best regards,

  • Hi,

    Thanks for the advice!

    1. I still wonder what it should be like in CC2340R5 if I originally had "/* GPIO */
    #define CC2640R2_LAUNCHXL_GPIO_LED_ON 1" in CC2640R2F's source codes?

    2. What about the PinMux part? What should I set in "GPIO pin"? What exactly pin will it be controlling if I set it to "Any"?

    Thanks.

    BR,

  • Hi,

    1- Again, xxx_LED_ON only holds a logical level, so you can do something like:

    #define CC2340R5_LAUNCHXL_GPIO_LED_ON 1

    2- The "PinMux" allows you to physically connect a GPIO pin to the newly created GPIO instance. Selecting "Any" tells SysConfig to find any pin available. If this is not suitable for you, i.e. if you prefer to select a specific pin number, make sure to select it using the drop-down list.
    Also, make sure to notice the field "Use Hardware". This field is particularly helpful when using a TI LaunchPad as it directly tells SysConfig to use the pins where the physical peripherals (e.g. buttons and LEDs) are routed. In case you are not using a TI LaunchPad, it might be wise to set the "Use Hardware" field to "None".

    To finish, I recommend reviewing SysConfig getting started guide available here: https://software-dl.ti.com/simplelink/esd/simplelink_lowpower_f3_sdk/7.10.00.35/exports/docs/ble5stack/ble_user_guide/html/ble-stack-5.x-guide/sysconfig-index-cc23xx.html

    I hope this will help,

    Best regards,

  • Hi,

    Thanks for the explanation.

    For question1, shall I put this line in C:\ti\simplelink_lowpower_f3_sdk_7_10_00_35\source\ti\drivers\Board.h, 
    while in CC2640R2F I saw it in C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\source\ti\ble5stack\boards\CC2640R2_LAUNCHXL\CC2640R2_LAUNCHXL.h ?

    Thanks.

    BR,

  • Hi,

    This could be an option.

    You may also want to consider relying on the symbol CONFIG_GPIO_LED_ON generated by SysConfig in ti_drivers_config.h

    Regards,

  • Hi,

    Does that mean if I have this in my ti_drivers_config.h:

    I wouldn't need to define "CC2340R5_LAUNCHXL_GPIO_LED_ON" myself in SysConfig, is that right?

    And if I would like to mimic CC2640R2F to generate the same GPIO definitions in CC2640R2_LAUNCHXL.h, shall I manually add those weren't shown in ti_drivers_config.h through sysconfig?

    e.g. In CC2640R2_LAUNCHXL.h, I saw something like this:

    #define CC2640R2_LAUNCHXL_DIO24_ANALOG          IOID_24

    and I have't found it in my ti_drivers_config.h now, so I should add it through sysconfig like this:

    I'm not sure if I shall set the "GPIO Pin" to "DIO24/9 (Header)". Does DIO24 and 9 using the same PIN?

    Please correct me if I misunderstood anything.

    Thanks.

    BR,

  • Hi,

    Does that mean if I have this in my ti_drivers_config.h:

    I wouldn't need to define "CC2340R5_LAUNCHXL_GPIO_LED_ON" myself in SysConfig, is that right?

    This is correct.

    And if I would like to mimic CC2640R2F to generate the same GPIO definitions in CC2640R2_LAUNCHXL.h, shall I manually add those weren't shown in ti_drivers_config.h through sysconfig?

    e.g. In CC2640R2_LAUNCHXL.h, I saw something like this:

    #define CC2640R2_LAUNCHXL_DIO24_ANALOG          IOID_24

    and I have't found it in my ti_drivers_config.h now, so I should add it through sysconfig like this:

    This is also correct.

    I'm not sure if I shall set the "GPIO Pin" to "DIO24/9 (Header)". Does DIO24 and 9 using the same PIN?

    When selecting "DIO24/9 (Header)", you actually select the DIO24 and the tools indicates it is mapped on the pin 9 of the LaunchPad. Please refer to the pinout of the LP-EM-CC2340R5 (https://www.ti.com/lit/swru588) for more details:

    Best regards,

  • Hi, 

    Thanks for the clear explanation!

    I just wonder if there are C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\source\ti\ble5stack\boards\CC2640R2DK_4XS\Board.h that defined things like this:

    #define Board_PTM               CC2640R2DK_4XS_PTM

    And in C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\source\ti\ble5stack\boards\CC2640R2DK_4XS\CC2640R2DK_4XS.h it showed:

    #define CC2640R2DK_4XS_PTM                           IOID_6

    In the main code, it used "Board_PTM" rather than simply called CC2640R2DK_4XS_PTM (while Board.h and CC2640R2DK_4XS.h are under the same path).

    In my current understanding, in CC2340R5's syscfg we could do things like what CC2640R2DK_4XS.h did.

    Then, in CC2340R5's main code, shall we called CC2640R2DK_4XS_PTM  (assume that we have defined it in syscfg and it has been atomatically added in ti_drivers_config.h) directly or is there any way to do something like what Board.h did?

    Which way does TI recommended for CC2340R5?

    1. Calling items in ti_drivers_config.h directly

    or

    2. Further define items in Board.h and call items in it.

    (It seemed that for CC2640R2F, it used option 2, but in CC2340R5, Board.h has been removed. Does that mean I shall use option 1?)

    Thanks.

    BR,

  • Hi,

    In my current understanding, in CC2340R5's syscfg we could do things like what CC2640R2DK_4XS.h did.

    This is correct understanding, on CC23xx devices SysConfig should be used to configure all the GPIO instances used.

    Then, in CC2340R5's main code, shall we called CC2640R2DK_4XS_PTM  (assume that we have defined it in syscfg and it has been atomatically added in ti_drivers_config.h) directly or is there any way to do something like what Board.h did?

    SysConfig will not produce the aliases (e.g. "Board_PTM") but you can produce them on your own if you need them.
    I'll let you assess if such aliases are useful in your case or if you prefer remove them.

    Which way does TI recommended for CC2340R5?

    1. Calling items in ti_drivers_config.h directly

    or

    2. Further define items in Board.h and call items in it.

    (It seemed that for CC2640R2F, it used option 2, but in CC2340R5, Board.h has been removed. Does that mean I shall use option 1?)

    TI recommends "Option 1".

    Regards,