cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F4 discovery board not sending CAN messages.

Rde K.1
Associate III

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.

5 REPLIES 5
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk
Rde K.1
Associate III

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.

tictictoe
Associate

Hi, I am stuck with the same problem. If you have sorted out the issue please give me a heads up. Thanks in advance.

SofLit
ST Employee

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.

To give better visibility on the answered topics, please click on "Accept as Solution" on the reply which solved your issue or answered your question.
Ozone
Lead

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.