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.

CCS/RM48L952: CANRx as GIO

Part Number: RM48L952


Tool/software: Code Composer Studio

Hi,

For configuring CAN3Tx Pin as GIO the following code is used

canREG3->TIOC = canREG3->TIOC |   0x00000002 ; // Pin HIGH
canREG3->TIOC = canREG3->TIOC & 0xFFFFFFFD; // Pin low

Where: TIOC is defined in canBase volatile struct as follows:

uint32 TIOC; /**< 0x01E0: TX IO Control Register */
uint32 RIOC; /**< 0x01E4: RX IO Control Register */

I want to know the code that would set the CAN3Rx Pin as GIO.

Also let us know if both CANxTx & CANxRx shall be set High or Both pins shall be set to Low without any conflict?

  • Hello Sudharsan,

    1. You need to reset the bit 3 to disable the CAN functional mode.
    2. Configure the pin as output by setting the bit 2
    3. Then write 0 or 1 to bit 1 to toggle the pin
  • Is there any app note for which I can refer to for more detailed instructions?
  • Is there any app note for which I can refer to for more detailed instructions?
  • Can you elaborate on this reply?


    I want to know the code for toggling RIOC pins HIGH & LOW
  • Hello,

    This is the code I wrote for you. The values of the IO Control registers are only writable if Init bit of CAN Control Register is set. The OD, Func, Dir, and Out bits of the CAN TX IO Control register are forced to certain values when Init bit of CAN Control Register is reset.

    The code is to toggle CAN1 TX pin and RX pin. I just tested the code, it works well.

    canInit();
    for(i=0; i<100; i++){
    for(j=0; j<0x10000; j++);
    canREG1->CTL |= 0x00000001;
    if (ti == 0){
    ti=1;
    }else{
    ti=0;
    }
    canREG1->TIOC = (uint32)((uint32)1U << 18U )
    | (uint32)((uint32)0U << 17U )
    | (uint32)((uint32)0U << 16U )
    | (uint32)((uint32)0U << 3U ) /*GIO mode*/
    | (uint32)((uint32)1U << 2U ) /*output*/
    | (uint32)((uint32)ti << 1U ); /*high*/

    canREG1->RIOC = (uint32)((uint32)1U << 18U )
    | (uint32)((uint32)0U << 17U )
    | (uint32)((uint32)0U << 16U )
    | (uint32)((uint32)0U << 3U )
    | (uint32)((uint32)1U << 2U )
    | (uint32)((uint32)ti <<1U );
    canREG1->CTL &= 0xFFFFFFFE;
    }