2021-11-08 06:25 AM
PREMISE: I have experience with other communication protocols but very little with CAN so I am not completely sure how to set the prescaler and other parameters.
GOAL: I want to read a sensor (namely the airspeed sensor ASPD-DLVR) through the CAN BUS. The connection is straightforward since I am using the JST-GH connector that comes with the sensor and with my board (pixhawk4).
PROBLEM: The interrupt does not trigger.
CONTEXT:
I have tested with a scope that there is traffic on the pins.
I set up the CAN pin as stated on the pixhawk4 datasheet (PI9 for the CAN1_RX and PH13 for the CAN1_TX).
I set up a simple application from the STM32CubeMx as shown in the pictures below.
In addition, I have added the following code to the MX_CAN1_Init() function:
//In the MX_CAN1_Init function
CAN_FilterTypeDef canfilterconfig = {0};
canfilterconfig.FilterActivation = CAN_FILTER_ENABLE;
canfilterconfig.FilterBank = 0; // which filter bank to use from the assigned ones
canfilterconfig.FilterFIFOAssignment = CAN_FILTER_FIFO0;
canfilterconfig.FilterIdHigh = 0x0000;
canfilterconfig.FilterIdLow = 0x0000;
canfilterconfig.FilterMaskIdHigh = 0x0000;
canfilterconfig.FilterMaskIdLow = 0x0000;
canfilterconfig.FilterMode = CAN_FILTERMODE_IDMASK;
canfilterconfig.FilterScale = CAN_FILTERSCALE_32BIT;
canfilterconfig.SlaveStartFilterBank = 13; // how many filters to assign to the CAN1 (master can)
if(HAL_CAN_ConfigFilter(&hcan1, &canfilterconfig) != HAL_OK)
{
Error_Handler();
}
if(HAL_CAN_Start(&hcan1) != HAL_OK)
{
Error_Handler();
}
if(HAL_CAN_ActivateNotification(&hcan1, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
{
Error_Handler();
}
2022-03-09 06:09 AM
Did you end up finding the solution?
I am having the exact same problem. I can clearly see the packet on the RX pin with an oscilloscope, but the interrupt handler is not being called. However, it does get called in loopback mode.