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.
Hi,
In my setup a lot of messages with different message IDs are send back and forth on both CAN busses (500.000kbit/s).
I use:
#define TX_MSG_OBJ_ID 1
#define RX_MSG_OBJ_ID 2
and when I send on CAN I use (taken from lib):
CANMessageSet(CANA_BASE, TX_MSG_OBJ_ID, &sTXCANMessage, MSG_OBJ_TYPE_TX);
But when i run the code unfortunately messages are missing (not send) and bus errors are popping up on my PC-app Busmaster.
For reading messages I use (taken from lib):
CANMessageGet(CANA_BASE, RX_MSG_OBJ_ID, &sRXCANMessage_Int, true);
I know that CANA and CANB both have 32 message objects (“message objects” are also referred to as “mailboxes” in the documentation)
How do I implement mailboxes into my system? Code example?
In the libs I found
CAN_sendMessage(uint32_t base, uint32_t objID, uint16_t msgLen,
const uint16_t *msgData)
and
CAN_readMessage(uint32_t base, uint32_t objID,
uint16_t *msgData)
Will it be better to use them? It looks almost the same to me.
I really need to see the connection between the mailboxes (the 32 message objects) and the different messages send (rx/tx) - do I have to handle the mailboxes and how?
Now tx is in mailbox 1 (TX_MSG_OBJ_ID= 1) and rx is in mailbox 2 (RX_MSG_OBJ_ID = 2) .... is that right?
Thanks!
Best regards,
Carsten
Carsten,
Please download my Application report http://www.ti.com/lit/sprace5. It has many tested examples. I urge you to look at the Debug tips provided. I also urge you to download and use the latest version of C2000Ware (https://www.ti.com/tool/download/C2000WARE ). What board are you using? Are you attempting communication between CAN-A & CAN-B of 28075?
But when i run the code unfortunately messages are missing (not send) and bus errors are popping up on my PC-app Busmaster.
Only some messages don’t get transmitted or no messages get transmitted.?
How do I implement mailboxes into my system? Code example?
The mailboxes are already there in the module. You just need to configure them through your code. Code examples are part of C2000Ware.
Will it be better to use them? It looks almost the same to me.
Yes you can. Didn’t understand your comment. They are two different functions.
I really need to see the connection between the mailboxes (the 32 message objects) and the different messages send (rx/tx) - do I have to handle the mailboxes and how?
Please try the tested examples that are part of C2000Ware and let me know if you have any difficulty.
Now tx is in mailbox 1 (TX_MSG_OBJ_ID= 1) and rx is in mailbox 2 (RX_MSG_OBJ_ID = 2) .... is that right?
Correct. Have you referred to the Driverlib documentation at C:\ti\c2000\C2000Ware_3_02_00_00\device_support\f2837xd\docs?
thanks a lot for your quick answer... you are the best!
I will let you know how it turns out.
Best regards,
Carsten
Hi Hareesh,
only some of the messages gets through.
The messages are send between two f28075 units. Both units are sending and receiving.
I would like to configure a mailbox for every ID (up to 32)
I don't find any places in the code examples where this this is done. The examples only use 1 and 2 as object ID's (mailboxes).
Extra question:
If I make a shortcut between rx and tx the CAN stops.
What will be the right way to make it run again? (disable and then enable... or perhaps re-init the CAN allover again?)
Thanks!
BG.
Carsten
Carsten,
I don't find any places in the code examples where this this is done. The examples only use 1 and 2 as object ID's (mailboxes).
The procedure is exactly the same regardless of the number of mailboxes you would like to configure.
If I make a shortcut between rx and tx the CAN stops. What will be the right way to make it run again?
Sorry I don’t understand. Please elaborate.
Did you read through the debug tips in my Application Report?
Hareesh,
I have now made a mailbox for every ID. It seems to work. Every message transmitted by unit #1 is also received by unit #2 and vice versa.
There are no errors detected... thanks!
My next issue is how to make the CAN connection between the two units resistant against every possible disturbance coming from the outside.
- burst
- short cut between rx and tx (for a short periode of time)
- etc.
My criteria is that it is OK to lose some messages due to disturbance but the CAN must not freeze...
When I make a quick shortcut between rx and tx the CAN transmission (hardware layer) stops.
Question:
- how do I detect that the message transmission has stopped?
- how do I start it up again?
Will try Auto-Bus-On in register CAN_CTL and perhaps SW reset enable.
Best regards and have a nice weekend,
Carsten
My criteria is that it is OK to lose some messages due to disturbance but the CAN must not freeze...
In a properly designed network, errors should be rare. By "properly designed", I am referring to correct choice of bit-timing parameters, proper termination etc. If the bus is disturbed due to external factors, error frames will be generated, but the network should recover on its own once the disturbing factors go away. The Transmit & Receive error counters facilitate fault detection/recovery/containment. Now, if the disturbances impact the MCU and its associated circuitry, it is conceivable that the MCU could lock up or reset or start executing garbage. This needs to be handled in the system H/W & S/W design. Problem are generally the result of insufficient decoupling/filtering, incorrect layout, improper (or lack of) shielding etc. There are numerous resources online that deal with this. Hard to explain them in a post. A chattering relay is helpful in generating noise across a wide spectrum. It is an extremely simple circuit. Since it is not electrically connected to the circuit, it provides a simple way to ascertain if the circuit is affected by radiated noise.
When I make a quick shortcut between rx and tx the CAN transmission (hardware layer) stops.
Are you saying you shorted CANTX & CANRX pins of the MCU? If you manually create such shorts, it is possible you pushed the node into bus-off.
- how do I detect that the message transmission has stopped?
There is no time-out detection mechanism built into this CAN module. You can implement one using the CPU-timer. In other words, this has to be dealt with in S/W.
- how do I start it up again?
If you detect a bus-off, recovery could be either automatic or manual. Please refer To the TRM for details.
Hi Hareesh,
first I want to thank you for all your help. I really appreciate your quick answers.
Status:
Yes the setup went into bus-off state when I made the burst test [4kV] onto the CAN connection, or when I made a short cut between RX and Tx.
But by the help of Auto-bus-On with a the build-in timer the CAN bus (A and B) works very fine. There are a lot of error transmissions of cause, but the
CAN bus does not break down anymore.
Thanks again - It works lige a charm.
/carsten