cancel
Showing results for 
Search instead for 
Did you mean: 

Nucleo-F446RE CAN bus RX interrupt

FJB2069
Associate III

I cannot get the CAN bus CAN1_RX0 interrupt to fire. I have two other development boards (STM32429i-EVAL1 and STM32373C-eval) that both work correctly. I am using the same code in each setup thru the ST MX and IDE. The Eval boards have built in CAN interface, so on the Nucleo board I am using a CAN adapter.

I have a USB CAN device to receive and send CAN messages to boards. I also have a CAN logic analyzer verifying messages.

So on the NUCLEO board I am able to verify the CAN message being received is correct on the port PINS PB8 and PB9. tried configuring CAN1_RX to PA11 also, same result.

I have gone back and forth between boards and project trying to find a difference or reason I cannot receive the CAN interrupt on the Nucleo board!

I have attached the Nucleo project.

Any help would be appreciated.

9 REPLIES 9

Filter looks like it would reject everything..

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
FJB2069
Associate III

FilterMaskIDHigh and Low set to 0x0. I believe that will allow everything.

Normally I had it set to 0xFFFF so that only ID 0x245 would be let thru. That is how the other projects have worked, 0x0 allow everything, 0xF only allows FilterID.

If I am wrong, please advise correct way.

IF ((PATTERN & FilterMaskId) == FilterId) THEN TAKE

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
FJB2069
Associate III

pTxHeader.DLC=2;
		 	  				  pTxHeader.IDE=CAN_ID_EXT;
		 	  				pRxHeader.IDE=CAN_ID_STD;
 
		 	  				  pTxHeader.RTR=CAN_RTR_DATA;
		 	  				  //pTxHeader.StdId=0x20; //0x244;
		 	  				  pTxHeader.ExtId=0x20;
		 	  				  uint8_t message[2] = {'A','B'};
 
		 	  				  sFilterConfig.FilterFIFOAssignment=CAN_FILTER_FIFO0;
		 	  				  sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
 
		 	  				  /* High ID must be shifted by <<5 and low shifted by >> 3*/
		 	  				  sFilterConfig.FilterIdHigh=0x245<<5; //0x245<<5;
		 	  				  sFilterConfig.FilterIdLow=0x245<<3; //0x245<<3;
		 	  				  sFilterConfig.FilterMaskIdHigh=0xFFFF;//If filter is F it must match ID
		 	  				  sFilterConfig.FilterMaskIdLow=0xFFFF;
		 	  				  sFilterConfig.FilterScale=CAN_FILTERSCALE_32BIT;
		 	  				  sFilterConfig.FilterActivation=CAN_FILTER_ENABLE;
 
		 	  				  HAL_CAN_ConfigFilter(&hcan1, &sFilterConfig);

0693W00000WJGldQAH.png 

 Still not receiving.

Cause its STILL broken

Try the TAKE EVERYTHING pattern

  1. sFilterConfig.FilterIdHigh=0;
  2. sFilterConfig.FilterIdLow=0;
  3. sFilterConfig.FilterMaskIdHigh=0;
  4. sFilterConfig.FilterMaskIdLow=0;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

TAKE STDID 0x245

sFilterConfig.FilterIdHigh=0x245 << 5;

sFilterConfig.FilterIdLow=0;

sFilterConfig.FilterMaskIdHigh=0x7FF << 5;

sFilterConfig.FilterMaskIdLow=0;

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

TAKE EXTID 0x245

sFilterConfig.FilterIdHigh=0;

sFilterConfig.FilterIdLow=0x245 << 3; // | 8 for IDE bit

sFilterConfig.FilterMaskIdHigh=0xFFFF;

sFilterConfig.FilterMaskIdLow=0x1FFF << 3; // | 8 for IDE bit

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
FJB2069
Associate III

I tried all of your suggested config, but same result. Will not receive interrupt.

Again, any of these configurations will work correctly with other demo boards. Apparently, I am missing something with the setup of this F446 board. As you can see in the above graph, the logic analyzer is showing correct received CAN message on the pins PB8 and PB9 directly on the board so I have to assume the CAN adapter board is working, plus as you can also see, the F446 board is correctly transmitting the CAN message (and these are again going thru the CAN adapter).

I have even tried reconfiguring the board changing the CAN1_RX pin from PB8 to PA11. I assumed the port pin was damaged, but i get same result on PA11.

FJB2069
Associate III

I figured out the issue! The RX interrupt needs to be "Activated". It is not enough to enable the RX interrupt in the MX .ioc file,

You must call:

HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING);// Initialize CAN Bus Rx Interrupt
  /* USER CODE BEGIN CAN_Init 2 */
  HAL_CAN_Start(&hcan);
  HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING);// Initialize CAN Bus Rx Interrupt
  /* USER CODE END CAN_Init 2 */

Now it will interrupt on RX0_IRQ