cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get RX Can interrupt to work on a STM32F103c8T6. Sending works as well Receiving in poll mode.

SWant.239
Associate

I try to get the Rx Can interrupt to work, but I only can receive Can-messages in polling mode not with any interrupt.

Here is my Code from main.c

CAN_FilterTypeDef  sFilterConfig;
 
	sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
	sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
	sFilterConfig.FilterIdHigh = 0x0000;
	sFilterConfig.FilterIdLow = 0x0000;
	sFilterConfig.FilterMaskIdHigh = 0x0000;
	sFilterConfig.FilterMaskIdLow = 0x0000;
	sFilterConfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
	sFilterConfig.FilterActivation = ENABLE;
	sFilterConfig.FilterBank = 0;
 
	CAN_TxHeaderTypeDef MYtXhEADER;
	MYtXhEADER.DLC = 2;
	MYtXhEADER.ExtId = 0x0;
	MYtXhEADER.StdId = 0x666;
	MYtXhEADER.IDE = CAN_ID_STD;
	MYtXhEADER.RTR = CAN_RTR_DATA;
 
	CAN_RxHeaderTypeDef MyRxHeader;
 
 
 
	uint8_t data[10];
	uint32_t testttt =0;
	CAN_FIFOMailBox_TypeDef MailBox[1];
 
 
	__HAL_RCC_CAN1_CLK_ENABLE();
	__HAL_RCC_GPIOA_CLK_ENABLE();
 
 
	HAL_CAN_RegisterCallback(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING, HAL_CAN_RxFifo0MsgPendingCallback) ;   //HAL_CAN_RxFifo0MsgPendingCallback  RxFifo0MsgPendingCallback
 
	HAL_NVIC_SetPriority(CAN1_RX1_IRQn,0,0);
	HAL_NVIC_EnableIRQ(CAN1_RX1_IRQn);
 
    HAL_CAN_ConfigFilter(&hcan, &sFilterConfig);
    HAL_CAN_ActivateNotification(&hcan,CAN_IT_RX_FIFO0_MSG_PENDING);
    __HAL_CAN_ENABLE_IT(&hcan,CAN1_RX1_IRQn);
 
    HAL_CAN_Start(&hcan);
 

The filter should accept every Can message.

I also defined a Callback for the RX Interrupt

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
 
	printf("Test");
}

I hope someone has an idea what I can try to solve this issue.

Many thanks in advance!

Atached the CubeMX config file

1 REPLY 1
SWant.239
Associate

Switching back to an older version solved the problem ....