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.

RM48L940: Custom RM48 Board

Part Number: RM48L940
Other Parts Discussed in Thread: HALCOGEN

I working on a custom board built with RM48 and have a problem bringing it up in IAR (existing CCS project works OK but need to move to IAR for production).

In my test project I'm trying to blink an LED connected to CAN1RX (pin B10). I don't need CAN bus so I'd like to use this as GIO (configure as output). I'm able to compile and download my project but when I run it it goes into the weeds at this line in canInit():

/** - Setup control register

* - Enter initialization mode
*/
canREG1->CTL = 0x00000001U;

I believe the purpose of the above is to set the pin as GIO instead of CAN bus (correct me if I'm wrong).

The same line executes fine in CCS project. What am I missing and how do I find out what is going when execution gets stuck at this point (no errors, just sit there waiting indefinitely).

  • Hello,

    Using this statement is not enough to configure the CAN TX/RX pin as GPIO? (canREG1->CTL = 0x00000001U;).

    This is the correct sequence to configure the CAN TX/RX as GIO and toggle them::

    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 ) /*GIO mode*/
    | (uint32)((uint32)1U << 2U ) /*output*/
    | (uint32)((uint32)ti << 1U ); /*high*/
    canREG1->CTL &= 0xFFFFFFFE;

    The values of the IO Control registers are writable only if Init bit of CAN Control Register is set. The OD, Func, and Dir bits of the CAN RX IO and CAN TX IO Control registers are forced to certain values when Init bit of CAN Control Register is reset, see bit description.

    Is there a CAN transceiver on the board? If the LED is connected to CAN_H, the LED will be always ON since CAN_H is from 2.5V to 3.5V.
  • Thanks for the reply. LED is connected to CAN1TX and CAN1RX. The complete canInit() function I use is below. In my earlier post I only showed the line where execution goes off into the weeds (canREG1->CTL = (uint32)0x00000001U"). That is, when I single step and try to execute this line my only option after that is to abort debug because it appears to sit there forever. When I abort debug I end up in this assembly (some interrupt handler?).

    ***************after debug break (see highlighted line)***************************

            0x3586: 0x4904         LDR.N     R1, [PC, #0x10]         ; countEMACCore0RxIsr

           0x3588: 0x6008         STR       R0, [R1]

    }

           0x358a: 0x4770         BX        LR

        countEMACCore0TxIsr++;

    EMACCore0TxIsr:

           0x358c: 0x4803         LDR.N     R0, [PC, #0xc]          ; countEMACCore0TxIsr

           0x358e: 0x6800         LDR       R0, [R0]

           0x3590: 0x1c40         ADDS      R0, R0, #1

           0x3592: 0x4902         LDR.N     R1, [PC, #0x8]          ; countEMACCore0TxIsr

           0x3594: 0x6008         STR       R0, [R1]

    }

           0x3596: 0x4770         BX        LR

           0x3598: 0x08000028     DC32      countEMACCore0RxIsr

           0x359c: 0x0800002c     DC32      countEMACCore0TxIsr

    gSizeGPIOAlArray:

           0x35a0: 0x0000005c     DC32      0x5c (92)

    Abort_Handler:

    FIQ_Handler:

    IRQ_Handler:

    Prefetch_Handler:

    SWI_Handler... +2 symbols not displayed:

           0x35a4: 0xeafffffe     B         Abort_Handler           ; 0x35a4

    __iar_return_from_swi:

           0x35a8: 0xe1b0f00e     MOVS      PC, LR

    __iar_SB:

           0x35ac: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35b0: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35b4: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35b8: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35bc: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35c0: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35c4: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35c8: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

           0x35cc: 0xffffffff     MRC2      p15, #7, PC, C15, C15, #7

    ***************Complete canInit() function*********************

    void canInit(void)
    {
    /* USER CODE BEGIN (4) */
    /* USER CODE END */
        /** @b Initialize @b CAN1: */
     
        /** - Setup control register
        *     - Enter initialization mode
        */
        canREG1->CTL = (uint32)0x00000001U;
        
         /** - CAN1 Port output values */
        canREG1->TIOC =  (uint32)((uint32)1U  << 18U )
                       | (uint32)((uint32)1U  << 17U )
                       | (uint32)((uint32)0U  << 16U )               
                       | (uint32)((uint32)0U  << 3U ) 
                       | (uint32)((uint32)1U  << 2U )   
                       | (uint32)((uint32)0U << 1U );
                      
        canREG1->RIOC =  (uint32)((uint32)1U  << 18U )   
                       | (uint32)((uint32)1U  << 17U ) 
                       | (uint32)((uint32)0U  << 16U )  
                       | (uint32)((uint32)0U  << 3U ) 
                       | (uint32)((uint32)1U  << 2U )
                       | (uint32)((uint32)0U <<1U );       


        /**   @note This function has to be called before the driver can be used.\n
        *           This function has to be executed in privileged mode.\n
        */

    /* USER CODE BEGIN (5) */
    /* USER CODE END */
    }

  • Hello,

    If the CCE bit (bit 6 in canREG->CTL register) is cleared, the configure registered can not be accessed. I don't recommend to modify the canInit() generated by HALCoGen. Congiure the CAN_TX/RX as GIO and toggle them in your main().

    Please note that:

    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.

    while(1)

    {

    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 ) /*GIO mode*/

    | (uint32)((uint32)1U << 2U ) /*output*/

    | (uint32)((uint32)ti << 1U ); /*high*/

    canREG1->CTL &= 0xFFFFFFFE;

    }