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.

RM46L852 CAN Problem

Other Parts Discussed in Thread: HALCOGEN, RM46L852

Hi,

I have a RM46L852 MCU connected via an ADM3053 transceiver to a PEAK PCAN USB adapter (baud rate = 500 kBit/s). I'm using HALCoGen with the following settings:

I've generated the code and imported it in uVision. This is my example main function to receive data that I send via my PCAN USB adapter:

void main(void)
{
    unsigned char rx_data[12] = {0,0,0,0,0,0,0,0,0,0,0,0}; /* 1st 4 bytes will be ID */
    
    gioInit();
    canInit();

    while(!canIsRxMessageArrived(canREG1, canMESSAGE_BOX2));
    canGetData(canREG1, canMESSAGE_BOX2, rx_data);
    while(1) {}
}

Unfortunately I never receive any message from the PCAN USB adapter, so the program gets stucked at the first while loop. Sending data also doesn't work.

If I send a message with the PCAN View tool to the RM46 I receive a "BUSHEAVY" error (only error frames are sent I think, normally this error occurs if there is a physical problem). I have an oscillator between the transceiver and the RM46 and it is showing the following output if I try to send a message to the RM46:

The top signal is CAN1RX, the bottom signal is CAN1TX. If I send a message from the RM46 to the PEAK USB adapter I see nothing on the oscillator, there seems to be no output at all from the CAN1RX pin of the RM46.

If I call the "canIsMessageBoxValid" function from can.c it says that both messageboxes 1 and 2 are NOT valid, but I have no idea why.

For me it seems to be a software configuration mistake in HALCoGen, but I'm not sure what I did wrong. Do you have any ideas why I can't get the CAN messaging to work?

Thanks in advance,

Timm

  • Hello Timm,

    I have forwarded your question to one of our experts and they will be responding soon.

  • Hi,

    I have an update for this issue: I tried to connect the PEAK USB adapter at CAN2 and at least there, if I call canInit(), there is no error flooding on the line (I can see it on the oscillator). The oscillator shows that I send nice clean CAN messages from the PEAK USB to the RM46 (but only on CAN2, CAN1 is still flooding with errors if I try to send something to the RM46). BUT I can still not send or receive ANYTHING with my program on the RM46. canTransmit() returns successfully but there is absolutely no output on the RX/TX pin of CAN2. canIsRxMessageArrived() says that there are no messages (but I can see them on the oscillator).

    I have no clue what could be wrong, but I'm pretty sure it's a HALCoGen issue. There seems to be a wrong initialization of the CAN bus. Please help me with that issue.

    Boundary Scan Tests with the CAN TX pin are successfully. I can generate high/low signals at the pins.

    Thanks, Timm

  • Hello Timm,

    can you please send us the halcogen files that you used for your configuration?

    If it is sensitive, please turn off all other IP except CAN1 and CAN2.

    I can not see what you cut and paste here.

    We have not seen any issue with CAN1 or CAN2 so far.

  • 1541.TI Example CAN2.zip

    Hi, you can find an example project in the attachment. I also wrote some explaining comment lines in sys_main.c.

  • As a brief summary for what I did in HALCOGEN:

    - created a new project with the RM46L852PGE

    - used the "ARM Tools"

    - disabled all other drivers except GIO and CAN2

    - in can 2: activated message 1, using it as TX

    - in can 2: activated message 2, using it as RX

    - generated the code, imported it to Keil

    - used "sys_link.cmd" in linker settings

    - replaced "FIQ" in "esm.c" through "__irq", replaced "IRQ" in "sys_vim.c" through "//IRQ" (otherwise error message)

    - wrote the main function

  • Hi Timm,

    i just take a look at your halcogen for CAN1, i think there is a mistake in the configuration.

    There are potentially 2 issues that i can see on first glance:

    #1- You did not click on the activate button for message 1 and message 2 of CAN1 or any mailbox of CAN1.  This is the reason why you did not see anything on CAN1.

    #2- Your CAN2 is configured to send message ID = 1 in mailbox 1 and receive message ID = 2 in mailbox 2.  So one of your CAN1 mailbox X should send message ID=2 and another CAN1 mailbox Y should receive message ID=1.

    Can you give it a try? 

  • Hi Henry,

    thanks for your answer. It's fine that CAN1 is not configured. I've just taken the CAN2 and connected it with the PEAK USB adapter. There is no loopback in my example, so CAN1 is not being used at all. I'm sending a message in mailbox 1 and then wait till I receive a message in mailbox 2 (this is the code you see in the sys_main.c).

    Right now I have a permanent recessive signal on CAN2TX, so the RM46 does not send anything. Now I have started analyzing the messages that I send from the PEAK USB adapter to the RM46 and if I'm interpreting the data on the oscillator right, then there is a Bit Stuffing Error everytime I try to send a message to the RM46. So that would be an indication that the bit rates are not the same right? The PEAK USB is running at 500 kbit/s, and in HALCoGen I have the default settings for the bit rate. Is there maybe a chance that the bitrate is, despite all that, not the same? Maybe that is causing the error?

    Thanks,

    Timm

  • Hi,

    sorry, my mistake! I misinterpreted the oscillator data! I can see now clearly the message. It's sent correctly but the RM46 does not receive it. I have no idea where the problem might be? Do you have any further ideas?

    Greetings

  • Hi,

    I did more research and found out the following: the CAN messages are sent correctly from the PEAK USB to the RM46, I can see the whole message on the oscillator.

    The messages are also getting acknowledged correctly, I can see the dominant bit being set on the TX line of the RM46.

    If I evaluate bit 4 of the error status register (RxOK from canREG2->ES) I can see that the messages have been received successfully. The bit indicates a received message BEFORE acceptance filtering. So my strongest guess would be that the filter is not working right, since the message seems to not appear in the message RAM.

    I'm using extended identifiers and send messages with ID 2 (message box 2) from the PEAK USB to the RM46.

    The configuration of message box 2 of CAN2 that HALCoGen generated:

    canREG2->IF2MSK  = 0xC0000000U | (((uint32)0x000007FFU & (uint32)0x1FFFFFFFU) << (uint32)0U);
    canREG2->IF2ARB  = (uint32)0x80000000U | (uint32)0x40000000U | (uint32)0x00000000U | (((uint32)2U & (uint32)0x1FFFFFFFU) << (uint32)0U);
    canREG2->IF2MCTL = 0x00001080U | (uint32)0x00000000U | (uint32)8U;
    canREG2->IF2CMD  = (uint8) 0xF8U;
    canREG2->IF2NO   = 2U;

    Any kind of help would be very much appreciated, since I'm running out of time.

    Greetings,

    Timm

  • Is there nobody who might be able to help concerning this issue? Henry Nguyen, do you know something?

  • I was facing same problem.

    1. kindly check Enable Identifier Extension in Hercules.

    if it is ticked use Extended frame message type from PCAN USB transmit message.

    else dont use it. simply send message.

    2. While transmitting message from PCAN make sure that transmit message id is same as Hercules receive message box id.


    Regards

    Ashwini Lohote

  • Thank you Ashwini!

    Timm, if you still have trouble after trying what Ashwini suggested - then please post the message that should have been received given the mask settings that you want us to check.

    Also, have you ruled out issues with bit timings as a possible cause?

     

  • Using a PEAK USB Can adapter, HalCoGen 4.6.1, RM46852ZWT (RM46 HDK) I was able to receive and send frames on CAN1. It was built using CCS 7.0. I used CanMsg1 for TX and CanMsg2 for Rx and made sure to activate both. For Rx, I cleared the mask to 0x00000000.

    Most of the troubles described, I experienced myself until I located the solutions.