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.

RM42L432: Problem with CAN on RM42L432

Part Number: RM42L432
Other Parts Discussed in Thread: CCSTUDIO, HALCOGEN, TCAN337,

I have a problem on the CAN of my TI HERCULE (RM42L432PZ).

I added a CAN Transceiver (TCAN337), I followed  tuto on Halcogen and CCStudio to generate CAN's librairies and driver for my TI HERCULE.

But when I send data with the function canTransmit(), nothing happens, no signal on OUTPUT of CAN1. I don't have any errors in my programs, and my function return a succes. Moreover I have test TCAN37 with my Arduino and I don't have any problems.

I don't know where the problems come froms.

Matheo S.

void Send(uint8_t *tab_TX){
   while(1){                                                           /*Infinite loop*/
        canTransmit(canREG1, canMESSAGE_BOX1, *tab_TX);               /* Transfer data on CAN's port*/
        sciSend(scilinREG, 15, (unsigned char *)"SEND CAN TRAM\n\r"); /*Send on Serial's console information*/
        delay_second(5);
   }}


void main(void)
{   _enable_IRQ();
    canInit();
    sciInit();
    uint8_t data[8]={'D','A','T','A','S','E','N','D'};
    Send(data);
}

  • Please read the TCAN337 datasheet carefully. In your schematics, the TX and RX signals are swapped.  

    The pin1 of TCAN337 should be TXD and pin4 should be RXD

  • Thanks for your note QJ Wang.

    But it's just a mistake when I wrote this schematic. When I test my driver the TX and RX are not swapped.

    Sorry, I correct my schematic.

    If you have any others ides or notes, can you comment ?

  • Is the mailbox1 enabled?

  • Yes, I have already enabled this mailbox.

    Below, I add all modifications that I did on Halcogen in picture:

  • Hi Siagh,

    In this config, the CAN1 high priority is used:

    But in VIM table config, the CAN1 high priority interrupt is not enabled. Please check the channel 16 (CAN1 Level 0).

       

    If the CAN Transceiver is connected to MCU properly, you should be able to see the transmitted message on CAN bus.

  • Thanks Wang, now I can send message.

    But I can't receive message,

    I send a continuous CAN frame but the reception does not work. It's strange because I can send well. I put you my code just below.

    Thanks in advance.

    Sincerely Mathéo.

  • My function canIsRxMessageArrived return 0 and my function canGetData return 0

  • now I can send message.

    But I can't receive message,

    The RM42 is only used to transmit CAN message, right? Which device is to receive the CAN message transmitted by RM42?

    My function canIsRxMessageArrived return 0 and my function canGetData return 0

    The function canIsRxMessageArrived() is generated by HALCoGen. It is used to check to see if the Rx message box has pending Rx data, returns 0 is flag not set. Do you also use RM42 to receive the CAN message transmitted by RM42 CAN1?

    Yes, you can connect RM42 CAN1 to RM42 CAN2 for communication. Two CAN transceivers are required: one is for CAN1 module, and one for CAN2 module. Each CAN module acts as a CAN node.

    The message ID of the RX mailbox should be the same as the message ID of the transmiited message.

  • Thanks for you faster answer,

    Firstly, It's a communication between two RM42, one to send and other to receive.

    Secondly, I want each card can send and receive to other one. Each card have a can transeiver (TCAN337) connect on their can1.

    I send you my code and my Halcogen, which are in two RM42L432.

    My first test, it's to send CAN's frame with one RM42 and one ARDUINO(1) to another ARDUINO(2). In oscilloscope, I can see the CAN's frame and ARDUINO(2) receive the differents messages which comes from TI and ARDUINO(1).

    My second test,, it's to send CAN's frame with one RM42(1) and one ARDUINO(1) to another RM42(2). In oscilloscope, I can see the CAN's frame but RM42(2) receive nothing, nor Can's frame about ARDUINO(1) and nor Can's frame about RM42(1). 

    When I debbug canIsRxMessageArrived() return 0, and canGetData() does not fill my table. I join my fonction receive and main with this message.

    Is it possible to send and receive with two differents card ? or I have a problem with my code or/and my halcogen ?

    void main(void){
    
        _enable_IRQ();
        sciInit();
        canInit();
        
        Receive();
    
    }
    
    
    void Receive()
    {
        int i=0 ;
        uint8 buf[8]={0};
    
        while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX2))
        {
            canGetData(canREG1, canMESSAGE_BOX2, buf);
            delay_second(2);
            sciSend(scilinREG, 19,(unsigned char *)"DATA RECEIVED: \r\n");             /*Send a message when data is arrived*/
    
            for(i=0;i<8;i++)
            {
                sciSend(scilinREG, sizeof(buf), (char)buf[i]);                             /*Print the data received*/
                sciSend(scilinREG, 4, "    ");
            }
            sciSend(scilinREG, 4, "\r\n");
        }
    
            sciSend(scilinREG, 21,"DATA NO RECEIVED \r\n");
            sciSend(scilinREG, 4, "\r\n");
            delay_second(2);
    
    
    }

    Sincerely Mathéo

  • Thanks Matheo,

    Is it possible to send and receive with two differents card ?

    Yes

    I have a problem with my code or/and my halcogen ?

    In your CAN configuartion, mailbox2 is to receive the message, and the message ID is 2. Does the transmitted message from another RM42 has the message ID of 0x2? If not, the message won't pass the acceptance filterring.  

  • Yes, the two RM42 have the ID 0x01.

  • The following are the CAN nodes confguration in your code:

    1. CAN node 1: #1 RM42

         Mailbox 1 is to TX message, ID=1

         and

         Mailbox 2 is to RX message, ID=2

     

    2. Can node 2: #2 RRM42

        Mailbox 1 is to TX message, ID = 1

        and

        Mailbox 2 is to RX message, ID = 1

    Two nodes on the network are not allowed to send messages with the same ID. 

    Can you please change the message ID of #2 RM42 to 0x2?

  • Thanks QJ WANG,

    I resolv my problem, now I can send and receive message.

    Regards SIAGH MATHEO.