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.

TMS570LS1224: Configuring the mibSPI / CAN pins as GPIO

Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

I wanted to know to configure the mibSPI / CAN pins pins as GPIO ( Input/ output) in CCS. What I need to configure in Halcogen ?

CAN1TX as' Input pin' ( GIO)

CAN1RX as' Input pin' ( GIO)

N2HET1[24]/MIBSPI1NCS[5] as' Input pin' ( GIO)

MIBSPI1NENA/N2HET1[23]/ECAP4 as 'output pin' ( GIO)

MIBSPI5SOMI[0] as' output pin' ( GIO)

MIBSPI5CLK as' Input pin' ( GIO)

Also how to make the particular pin say MIBSPI5CLK output a ' Logic High' .

Example code would be most appreciated, but I can understand if there isn't anything available.  General instructions would be fine, I'll muddle through them.

  • Hi,

    All of the MibSPI pins can be programmed to be GIO pins through SPIPCx register.

    1. First, configure MIBSPI5CLK as GIO:  mibspiREG5->PC0 &= ~(9 << 0x1); //write 0 to bit 9 of SPIPC0 register

    2. Configure the direction of BibSPI5CLK:  gioSetDirection(mibspiPORT5, 0x1<<9);

    3. Set the pin to high: gioSetBit(mibspiPORT5, 9, 0x1);  //set bit 9 (SPICLK) of SPIPC4

  • The CAN_TX and CAN_RX pins can also be used as GIO pins. The CAN TIOC and RIOC registers are used to set the direction, and value of the pins.

    1. set the Init bit of CAN control register: canREG1->CTL |= 0x1;

    2. canREG1->TIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1);   // CAN_TX as output, high

    3. canREG1->RIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1);   // CAN_RX as output, high 

  • Can I please know from where you got this information and also what i need to do in Halcogen?

    How do i need to include these lines in my CCS code? any variable to declared ?

  • You can use HALCOGen to enable MibSPI or DCAN pins as GIO pins:

  • Do i need to enable the CAN , MIBSPI drivers in below tabs ?

    and is canInit(); // Initialization function call required in the CCS ?

  • 1. If you want to use HALCOGen GUI to configure mibSPI or CNA pins, you need to enable those 2 modules, and run the module initialization to manipulate the pins, for example set one mibspi PIN to High.

    2. If you don't use GUI to configure MibSPI and CAN pins, you don't need to enable those two modules. This is the example code:

    #include "HL_mibspi.h"
    #include "HL_can.h"
    /* USER CODE END */
    int main(void)
    {
    /* USER CODE BEGIN (3) */
         mibspiREG1->GCR0 = 0x1;
         mibspiREG1->PC0 = ~(0x1 << 9);
         gioSetDirection(mibspiPORT1, 0x1<<9);
         gioSetBit(mibspiPORT1, 9, 0x1); //set bit 9 (SPICLK) of SPIPC4

         canREG1->CTL |= 0x1;
         canREG1->TIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_TX as output, high
         canREG1->RIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_RX as output, high  

  • I tried the above steps but I am getting the below errors. Please tell what I need to next.

    Only GIO is enabled in Halcogen.
    >> Compilation failure
    source/subdir_rules.mk:9: recipe for target 'source/sys_main.obj' failed
    "../source/sys_main.c", line 53: fatal error #1965: cannot open source file "HL_mibspi.h"
    1 catastrophic error detected in the compilation of "../source/sys_main.c".
    Compilation terminated.
    gmake: *** [source/sys_main.obj] Error 1
    Building file: "../source/can.c"
    Invoking: ARM Compiler
    "C:/ti/ccs1011/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/bin/armcl" -mv7R4 --code_state=32 --float_support=VFPv3D16 --include_path="C:/Users/sakthidav/Desktop/tms570/can_gpio" --include_path="C:/Users/sakthidav/Desktop/tms570/can_gpio/include" --include_path="C:/ti/ccs1011/ccs/tools/compiler/ti-cgt-arm_20.2.1.LTS/include" -g --diag_warning=225 --diag_wrap=off --display_error_number --enum_type=packed --abi=eabi --preproc_with_compile --preproc_dependency="source/can.d_raw" --obj_directory="source"  "../source/can.c"
     
    >> Compilation failure
    source/subdir_rules.mk:9: recipe for target 'source/can.obj' failed
    "../source/can.c", line 1051: error #20: identifier "CAN1_CTL_CONFIGVALUE" is undefined
    "../source/can.c", line 1052: error #20: identifier "CAN1_ES_CONFIGVALUE" is undefined
    "../source/can.c", line 1053: error #20: identifier "CAN1_BTR_CONFIGVALUE" is undefined
    "../source/can.c", line 1054: error #20: identifier "CAN1_TEST_CONFIGVALUE" is undefined
    "../source/can.c", line 1055: error #20: identifier "CAN1_ABOTR_CONFIGVALUE" is undefined
    "../source/can.c", line 1056: error #20: identifier "CAN1_INTMUX0_CONFIGVALUE" is undefined
    "../source/can.c", line 1057: error #20: identifier "CAN1_INTMUX2_CONFIGVALUE" is undefined
    "../source/can.c", line 1059: error #20: identifier "CAN1_INTMUX3_CONFIGVALUE" is undefined
    "../source/can.c", line 1060: error #20: identifier "CAN1_TIOC_CONFIGVALUE" is undefined
    "../source/can.c", line 1061: error #20: identifier "CAN1_RIOC_CONFIGVALUE" is undefined
    10 errors detected in the compilation of "../source/can.c".
    gmake: *** [source/can.obj] Error 1
    gmake: Target 'all' not remade because of errors.

    **** Build Finished ****



    /* USER CODE BEGIN (0) */
    /* USER CODE END */

    /* Include Files */

    #include "sys_common.h"

    /* USER CODE BEGIN (1) */
    #include "HL_mibspi.h"
    #include "HL_can.h"
    #include "system.h"
    #include "gio.h"



    /* USER CODE END */

    /** @fn void main(void)
    *   @brief Application main function
    *   @note This function is empty by default.
    *
    *   This function is called after startup.
    *   The user can use this function to implement the application.
    */

    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    int main(void)
    {
    /* USER CODE BEGIN (3) */
         mibspiREG1->GCR0 = 0x1;
        mibspiREG1->PC0 = ~(0x1 << 9);
         gioSetDirection(mibspiPORT1, 0x1<<9);
        gioSetBit(mibspiPORT1, 9, 0x1); //set bit 9 (SPICLK) of SPIPC4

         canREG1->CTL |= 0x1;
         canREG1->TIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_TX as output, high
         canREG1->RIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_RX as output, high

    return 0;
    /* USER CODE BEGIN (4) */
    /* USER CODE END */

  • 1. You need to add the include folder to #include search path. This can be in project properly/Arm Compiler/Incluse options

    2. If CAN module is not enabled, the HALCoGen will not generate source code for CAN (can.c). But I noticed that you tried to compile can.c and got some error.

    If the CAN module was enabled and can.c was generated earlier, the can.c will not be removed after the CAN module is disabled. You have to delete the source code file manually.

  • Thanks a lot QJ Wang,

    It's working now!

    CODE THAT I USED :


    /* USER CODE BEGIN (0) */
    /* USER CODE END */

    /* Include Files */


    /* USER CODE BEGIN (1) */
    #include "mibspi.h"
    #include "can.h"
    #include "gio.h"
    /* USER CODE END */


    /* USER CODE BEGIN (2) */
    /* USER CODE END */

    int main(void)
    {
    /* USER CODE BEGIN (3) */
        mibspiREG1->GCR0 = 0x1;
             mibspiREG1->PC0 = ~(0x1 << 8);
             gioSetDirection(mibspiPORT1, 0x1<<8);
             gioSetBit(mibspiPORT1, 8, 0x1); //set bit 9 (SPIENA) of SPIPC4

             canREG1->CTL |= 0x1;
             canREG1->TIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_TX as output, high
             canREG1->RIOC = (0x0 << 3) | ( 0x1 << 2) |(0x1 << 1); // CAN_RX as output, high
    /* USER CODE END */

        return 0;
    }


    /* USER CODE BEGIN (4) */
    /* USER CODE END */