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.

TMS320F280049C: Can _ex1_loopback

Part Number: TMS320F280049C
Other Parts Discussed in Thread: C2000WARE

Hi 

I am working with TI TMS320f280049c Controller, I have configured CANB -> RX & TX lines for communication , GPIO 16 for TXD  and GPIO 17 for RXD. I am using Can_Ex1_loopback Code from C2000Ware_MotorControl_SDK_100_00_00 -> c2000ware > drivelib> f28004x example>can for  testing.


The example file has CANA configured, But i have configured CANB, i have changed the settings in devices.h as well for CANB.

After  Device_initGPIO(); i have added below GPIO setting for CANB RXD & TXD  in cqn_ex1_loopback.c File  & I am using TJA1043T as my Trans receiver. 

GPIO_setMasterCore(16, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_16_CANTXB);
GPIO_setDirectionMode(16, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(16, GPIO_PIN_TYPE_STD);

// UV MCU_CAN_RXD Pin.No 55
GPIO_setMasterCore(17, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_17_CANRXB);
GPIO_setDirectionMode(17, GPIO_DIR_MODE_IN);
GPIO_setPadConfig(17, GPIO_PIN_TYPE_STD);

// UV CAN STB_N Pin.No 57
GPIO_setMasterCore(25, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_25_GPIO25);
GPIO_setDirectionMode(25, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(25, GPIO_PIN_TYPE_STD);

// UV CAN MCU_CAN_EN Pin.NO 58
GPIO_setMasterCore(26, GPIO_CORE_CPU1);
GPIO_setPinConfig(GPIO_26_GPIO26);
GPIO_setDirectionMode(26, GPIO_DIR_MODE_OUT);
GPIO_setPadConfig(26, GPIO_PIN_TYPE_STD);

// Set CAN STB_N
GPIO_writePin(25, 1);
//
// Set CAN MCU_CAN_EN
GPIO_writePin(26, 1);
//
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB);
GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB);

And rest of  program is unchanged !

After programming the device and enabling debug mode i can see the data getting incremented from 0 to 255 in txMsgData & rxMsgData in watch expression window but  there is not data getting transmitted for RX and TX lines of the controller.

I am using an Oscilloscope to monitor and data pulses across TX and RX lines of the controller

Kindly help me with issues, that how can in see the data getting transmitted on RX and TX lines of the controller as well

Thank you

shivashankar

  • Hi Shiva,

    Couple of comments below:

         - Might be redundant defining the master core for the GPIOs.  I do not think these are needed.

         - The function GPIO_setPinConfig() will automatically choose the GPIO pin function as well as direction.  You do not need to set the direction after calling this function, like what was done on the examples.

        - This may not be related to your issue but just curious why you need extra GPIOs 25 and 26.

        - You have selected GPIO 16 as CAN TX pin and GPIO 17 as CAN RX pin for CANB module, no issues with that however the last 2 statements GPIO_setPinConfig(DEVICE_GPIO_CFG_CANTXB) and GPIO_setPinConfig(DEVICE_GPIO_CFG_CANRXB) will override the previous CAN TX and RX pin definitions for GPIO 16 and 17 respectively.  DEVICE_GPIO_CFG_CANTXB and DEVICE_GPIO_CFG_CANRXB might be pointing to a different set of GPIOs other than GPIO 16/17 pair.  This might be the reason you are not getting the signals from the oscilloscope.

    Regards,

    Joseph

  • Hi Joseph 

    We were able to  solve problem, issue was with the function 

    DEVICE_DELAY_US(500000);

    When we traced back for  value 500000 there was no sufficient timing get data on TX and RX pins. The system itself goes delay before interrupts are called.

    When we realized the system delay should be less than 50 counts(i really don't know timing of loop interrupt), we modified the function to

    DEVICE_DELAY_US(150); where DEVICE_DELAY_US depends upon no of bytes that can be transmitted in single frame.

    Thank you

    SHIVASHANKAR

  • Hi Shivashankar,

    Good to know that you have identified the reason why you are not seeing the CAN frames in the TX pin.  I'm still not completely understanding where the delay is inserted in your code and why this is critical to your application.  Anyway, when you get a chance, maybe you can describe where this delay is in your code and we will see why that matters.  In the meantime, i'll close this thread but if you have any questions on this topic, please feel free to post.

    Regards,

    Joseph