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.

TMS570LC4357: CAN and UART not working properly

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

Hi Team,

I have a customer who is using TMS570LC4357 and they have downloaded the sample code to use.

Their blinking LED application image is working properly but when they tried to communicate using CAN or UART, there seem to be an issue. Their CAN was not able to transmit anything while their UART is transmitting wrong characters.

Do you have any guidance or tips for this? 

Thank you.

Best Regards,

Ernest

  • Hi Ernest,

    Please try the examples in HALCOGen:

  • For CAN communication, does you board have CAN transceivers?

    This is an example for CAN1 and CAN 2 communication using interrupt mode:

    1. Enable CAN driver: CAN1 and CAN2

    2. Configure CAN1 to transmit message, and Enable CAN1 High level interrupt

    Configure CAN2 Message box 1 as receive, and Enable CAN2 High level interrupt

    3. Enable CAN interrupts in VIM:

    4. Generate code

    5. copy the following code to HL_sys_main.c and do a test:

    /* 
    * Copyright (C) 2009-2015 Texas Instruments Incorporated - www.ti.com
    * 
    * 
    *  Redistribution and use in source and binary forms, with or without 
    *  modification, are permitted provided that the following conditions 
    *  are met:
    *
    *    Redistributions of source code must retain the above copyright 
    *    notice, this list of conditions and the following disclaimer.
    *
    *    Redistributions in binary form must reproduce the above copyright
    *    notice, this list of conditions and the following disclaimer in the 
    *    documentation and/or other materials provided with the   
    *    distribution.
    *
    *    Neither the name of Texas Instruments Incorporated nor the names of
    *    its contributors may be used to endorse or promote products derived
    *    from this software without specific prior written permission.
    *
    *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
    *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
    *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
    *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES INCLUDING, BUT NOT 
    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON ANY
    *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
    *  INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE 
    *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    *
    */
    
    /* USER CODE BEGIN (0) */
    /* USER CODE END */
    
    /* Include Files */
    
    #include "sys_common.h"
    #include "system.h"
    
    /* USER CODE BEGIN (1) */
    #include "HL_can.h"
    #include "HL_esm.h"
    #include "HL_sys_core.h"
    
    #define D_COUNT  8 
    
    uint32 cnt=0, error =0, tx_done =0;
    uint8 tx_data[D_COUNT][8] = {0};
    uint8 rx_data[D_COUNT][8] = {0};
    uint8 *tx_ptr = &tx_data[0][0];
    uint8 *rx_ptr = &rx_data[0][0];
    uint8 *dptr=0;
    
    void dumpSomeData();
    /* USER CODE END */
    
    
    /** @fn void main(void)
    *   @brief Application main function
    *
    */
    
    /* USER CODE BEGIN (2) */
    /* USER CODE END */
    
    
    void main(void)
    {
    /* USER CODE BEGIN (3) */
    
        /* enable irq interrupt in Cortex R4 */
        _enable_interrupt_();
    
        /** - writing a random data in RAM - to transmit */
        dumpSomeData();
            
        /** - configuring CAN1 MB1,Msg ID-1 to transmit and CAN2 MB1 to receive */
        canInit();
    
        /** - enabling error interrupts */    
        canEnableErrorNotification(canREG1);
    	canEnableErrorNotification(canREG2);
        
        /** - starting transmission */
         for(cnt=0;cnt<D_COUNT;cnt++)
        {         
          canTransmit(canREG1, canMESSAGE_BOX1, tx_ptr); /* transmitting 8 different chunks 1 by 1 */
          while(tx_done == 0){};                 /* ... wait until transmit request is through        */
          tx_done=0;
          tx_ptr +=8;    /* next chunk ...*/
        }
        
        /** - check the received data with the one that was transmitted */
        tx_ptr = &tx_data[0][0];
        rx_ptr = &rx_data[0][0];
            
        for(cnt=0;cnt<63;cnt++)
         {
              if(*tx_ptr++ != *rx_ptr++)
              {
                   error++; /* data error */
              }
         }
    
        while(1){}; /* wait forever after tx-rx complete. */
    	
    /* USER CODE END */	
    }
    
    /* USER CODE BEGIN (4) */
    /* writing some data to ram  */
    void dumpSomeData()
    {
         uint32 tmp = 0x11;
         
         cnt = (D_COUNT*8)-1;
         dptr = &tx_data[0][0];
         *dptr = tmp;
    
         while(cnt--)
         {
            tmp = *dptr++;
            *dptr = tmp + 0x11;
         }
    }
    
    
    /* can interrupt notification */
    /* Note-You need to remove canMessageNotification from notification.c to avoid redefinition */
    void canMessageNotification(canBASE_t *node, uint32 messageBox)
    {
         /* node 1 - transfer request */
         if(node==canREG1) 
         {     
           tx_done=1; /* confirm transfer request */
         }
    
         /* node 2 - receive complete */     
         if(node==canREG2)
         {
          while(!canIsRxMessageArrived(canREG2, canMESSAGE_BOX1));
          canGetData(canREG2, canMESSAGE_BOX1, rx_ptr); /* copy to RAM */    
          rx_ptr +=8;     
         }     
    
        /* Note: since only message box 1 is used on both nodes we dont check it here.*/
    }
    /* USER CODE END */

  • Hi Qing Jun, 

    My customer have tried these and it worked without the bootloader. However once they integrate it with the bootloader, the issue came. 

    They only make changes on the linker file (They changed the start address of the application program), could there be any other configuration that is required? 

    Many thanks!

  • Hi Ernest,

    Do you mean that the application works fine if it is programmed to 0x00000000, and doesn't work when it is programmed to other location for example 0x20000?