2023-02-24 02:18 AM
Hi there, I'm new to ST development and am currently trying to setup a CAN connection between two STM32F4 discovery board. However, using an oscilloscope I can see that no messages are being send. Can anyone help me out finding what the problem is?
Attached are my main.c and a schematic overview of all connections.
2023-02-24 02:51 AM
I forgot already what was what but I do this and it works:
I noticed about your canfilter.SlaveStartFilterBank=15?
void CanSETUPnoFilter(){
//usage of can filters
//https://schulz-m.github.io/2017/03/23/stm32-can-id-filter/
//https://www.diller-technologies.de/stm32.html <-----this guy knows better
canfilter.FilterActivation = CAN_FILTER_ENABLE; //CAN_FILTER_ENABLE;//CAN_FILTER_DISABLE
canfilter.FilterBank = 0;
canfilter.FilterFIFOAssignment = CAN_FILTER_FIFO0; //CAN_FILTER_FIFO1
canfilter.FilterIdHigh = 0;
canfilter.FilterIdLow = 0;
canfilter.FilterMaskIdHigh = 0;
canfilter.FilterMaskIdLow = 0;
canfilter.FilterMode = CAN_FILTERMODE_IDMASK; //CAN_FILTERMODE_IDMASK;//CAN_FILTERMODE_IDLIST
canfilter.FilterScale = CAN_FILTERSCALE_32BIT; //CAN_FILTERSCALE_32BIT
canfilter.SlaveStartFilterBank = 0;
HAL_CAN_ConfigFilter(_hcan, &canfilter);
HAL_CAN_ActivateNotification(_hcan, CAN_IT_RX_FIFO0_MSG_PENDING); //activate interrupt for received canbus
HAL_CAN_Start(_hcan); //CRANK UP THE MOTORS!! BRRREM BRRREM starts can
}
maybe post your cubemx file also if youre using cubeMx at all
2023-02-24 03:18 AM
Thank you for the quick reply.
I am using CAN2, so that's why FilterBank and SlaveStartFilterBank are 15 and 14 resp. Also the filter does not filter anything, so may I ask why you think the problem lays here? Do you have any remarks on the electrical connections?
I am using STM32CubeIDE for this, so I also attached the .ioc file of the project if that helps.
2023-07-04 05:19 AM
Hi, I am stuck with the same problem. If you have sorted out the issue please give me a heads up. Thanks in advance.
2023-07-05 01:02 AM
Hello,
If you are using the same board for the two nodes and you are not seeing anything on the bus using the oscilloscope, you have to:
- Don't use any internal clock source (HSI etc) .. to clock the CAN peripheral. Use crystal for system clock.
- Check all the connections (connection continuity check).
- Check your bitrate: it should not exceed 1Mb/s.
- Check your transceivers, they could be not genuine. Some chips on the market are fake!
- If the transceiver has a standby pin, please check its datasheet to know how to force it to wake up from this mode.
2023-07-05 01:18 AM
I don't do Cube/HAL, so I cannot help you with that.
First thing is, you can bypass the transceivers and connect Rx/Tx directly if the cables are not too long. Though in this case, you will need a GND connection, too.
Second, check the CAN_ESR register after transmission attempts. If the value goes up, there is probably a wiring issue.