2014-11-21 05:58 AM
2014-11-21 06:41 AM
You have to send the CAN data to something that will receive it, you can use a transceiver or a diode arrangement.
On an F4 you can externally loop through transceivers CAN1 and CAN2. I'd recommend doing initial experiments on hardware known to work.2014-11-21 07:11 AM
So could you place answer me to this: If i don't use CAN tranceiver and i wont have something to accept data or diode arrangement for test, i won't be able to see any data with oscilloscope and initialization will fail? Yes or no? If yes, then what is purpose of silent loopback mode? Shouldnt it work without a CAN tranceiver? Because i have wired up a CAN tranceiver, i thought i would look first is it possible to send data first, but i only have a tranceiver, no receiver.
2014-11-21 10:27 AM
I'm not using CAN on the F3, so have little time invested, or too invest, in what the silicon may or may not do.
What I can tell you is that in the F1/F2/F4, that ''loopback'' internally is a pretty useless test if you want to see real bus traffic, and I don't know what feedback the CAN peripheral is looking for on the pins in ''normal'' mode. I wired up two nodes with transceivers, and can see traffic. This would seem like a minimal threshold to effectively test anything. The ''silent loop back'' on the F3, no signalling gets to the pins (per Ref Manual), but you can presumably sit in a loop sending and receiving to yourself. The non-silent loop back should at least get a signal to CAN_TX pin STM32F30x_DSP_StdPeriph_Lib_V1.0.0\Project\STM32F30x_StdPeriph_Examples\CAN\CAN_LoopBack\main.c2014-11-21 02:02 PM
The loopback mode is useful for software unit testing the CAN stack, since it allows you to send a message and debug how it is processed when it is received after loopback.
To see signals on the CAN bus you need two nodes. Inherent in CAN is a requirement for a minimum of two nodes. A single node will recognize the bus is not configured right and will throw lots of errors. The silent mode is useful after detecting a bus error (i.e. only one node). To stop the flood of errors disable the CAN node but periodically enable in silent mode to see if the errors have cleared. This gives you a sort of hot plug recovery on the bus. The silent mode will be the receiver for the other node so if you only have two nodes it will come up. The trick is to listen a multiple period longer than attempting to transmit so you don't get into a race condition. The gap between silent listening should be smaller that the time you try to send before erroring out. The logic for the CAN peripheral seems odd but after implementing a stack it's actually well thought out, especially for CANopen. Jack Peacock2014-11-22 03:27 AM
Clive and Jack Peacock, thank you for your answers and explaining things clearly. But i didn't understand one thing from explanations: So that silent loopback mode stilll wont work if i don't have two CAN nodes? If it internally connects as ref manual states, why would i need CAN tranceiver for that? CAN should at least go through initialization?
2014-11-24 02:11 AM
I still don't get it. When CAN is being initialized, it waits for the acknowledge. What should give the ack here? because i am always jumping to InitStatus = CAN_InitStatus_Failed. So as i see The INAK bit in MSR is never set to 0. Why?
/* Request leave initialisation */ CANx->MCR &= ~(uint32_t)CAN_MCR_INRQ; /* Wait the acknowledge */ wait_ack = 0; while (((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) && (wait_ack != INAK_TIMEOUT)) { wait_ack++; } /* ...and check acknowledged */ if ((CANx->MSR & CAN_MSR_INAK) == CAN_MSR_INAK) { InitStatus = CAN_InitStatus_Failed; } else { InitStatus = CAN_InitStatus_Success ; }2014-11-27 05:02 PM
2014-11-29 08:44 AM
Hi, I have to command an industrial motor using the CAN bus. I've never used it, and so I'm wondering what exactly I need to use it. If I got an STM 32F303 or 32F4 or 32F2, do I need a seperate Transceiver? And are there libraries for using the CAN bus/Transceivers? And or any kind of Tutorials, Examples or the like?
2014-11-29 02:51 PM
do I need a seperate Transceiver? And are there libraries for using the CAN bus/Transceivers? And or any kind of Tutorials, Examples or the like?
Yes, generally you'd want a transceiver. Suggest you look at STM32 board schematics using CAN, and the examples in the firmware library. I've posted a bunch of examples here too. CAN's been around for decades, so I'm sure there's plenty of documentation and implementation stuff out of the internets. There are also plenty of low cost STM32 based boards available with CAN .