2023-11-19 12:00 PM
Question 1: When I make the mcanconf like described in AN the second mcanconf is named exact the same, it does not autoincrement to mcanconf1 as it is in the example. Is that important? Or how/when do I link a certain mcanconf to a subsystem? They must be linked somehow, or? (My mcanconf1 also does not work when I set it up myself, that's why I ask)
Question 2: The code looks like this:
returnvalue = can_lld_transmit(&CAND2, CAN_ANY_TXBUFFER, &txf);
osalThreadDelayMilliseconds(1);
if (returnvalue != CAN_MSG_OK) {
for (;;) {
}
}
So if I have a error on my CAN transmission the program will be endlessly trapped in the for loop?
Isn´t the automatic resending of invalid frames/messages handled by the transceiver? Or does it have to be taken care of here in the sending call? Or is this just an example for loop that should throw an error? -> I thought of handling that one with the error callback.
Question 3: Maybe the answer is already in Q2 but, having a CAN line open or disturbed for some seconds will end the the transmission completely. It will not start again. So I wonder what I am forgetting. My expectation is that the program tries to send CAN endlessly until some other node starts acknowledging and everything's runs normal. But as it comes I would need to rewrite the program in the debugger to get it working again.
THX
Solved! Go to Solution.
2023-11-20 03:06 AM
Hi Orbiter,
For what concern to the first question, I suggest you follow the demo in AutoDevKit Studio "SPC58ECxx_RLA CAN Test Application for Discovery" where you can find the example of two different can configurations used for two can bus.
Finally, the following image shows that by default, low-level CAN drivers configure the DAR register to 0.
regards,
Alessandro
2023-11-20 03:06 AM
Hi Orbiter,
For what concern to the first question, I suggest you follow the demo in AutoDevKit Studio "SPC58ECxx_RLA CAN Test Application for Discovery" where you can find the example of two different can configurations used for two can bus.
Finally, the following image shows that by default, low-level CAN drivers configure the DAR register to 0.
regards,
Alessandro
2023-11-21 02:08 PM
Hello Alessandro,
thanks for the answer!
I have follow up questions:
Q1: Yes it works with the example. I try to reproduce the example, so that I am sure I understood whats happening. How can I link a configuration to a mcan subsystem? Or is it always the first one to subsystem 0 and the second to subsystem1?
Q2: Polling mode? So when I check for the returnvalue, thats called polling mode? And if I set the error callback that would be no-polling mode. So I can choose one, no need to do both?
Q3: The automatic resending will set the callback, right? So I am just fine handling transmission losses in the error callback function?
New question:
I would like to send several frames, is there a recommended way to organize? Like making a CANstruct for every frame I want to send? Or shall I stick to one struct and just change the ID and Payload and iterate through my whole adress list? Maybe it does not matter?
2023-11-22 08:45 AM
2023-11-22 09:40 AM
Thank you so much, this solved some great mysteries for me. Now my program works, the first "hello world" on CAN sending and receiving, quite robustly (At least I can´t crash it, no matter what I do on my testbench) Nice!