2016-06-09 01:58 AM
Hello there,
I am using STM32F4. I am trying to configure can peripheral the way that when messages are received, they pass through 2 filters. If filter 0 matches they go to FIFO0, if filter 1 matches they should be stored in FIFO1. Is this possible? A for now I have a problem with can busy flag- Im am trying to turn rx interrupts to work for FIFO0 and FIFO1, like this:HAL_CAN_Receive_IT(canHandle, 0);
HAL_CAN_Receive_IT(canHandle, 1);
The problem is that after the 1st line of code is executed, the can status is set to HAL_CAN_STATE_BUSY_RX so the second one doesnt work.
What is the proper way of making this idea work? 2 different filters, 2 different FIFO's, 1 can peripheral. I would really appreciate all help.
2016-06-09 03:08 AM
Hi Bremen,
It is already reported issue caused by the busy state of setting . until it will be fixed, as a work around try to comment the following lines in the HAL_CAN_Transmit() function after __HAL_LOCK().if(hcan->State == HAL_CAN_STATE_BUSY_RX)
{
/* Change CAN state */
hcan->State = HAL_CAN_STATE_BUSY_TX_RX;
}
else
{
/* Change CAN state */
hcan->State = HAL_CAN_STATE_BUSY_TX;
}
-Hannibal-
2016-06-09 03:12 AM
But the problem is within
HAL_CAN_Receive_IT(); Like this: // Flag is not busy
HAL_CAN_Receive_IT(canHandle, 0); // now flag is busy // now next HAL_CAN_Receive_IT(); for FIFO1 wont work. HAL_CAN_Receive_IT(canHandle, 1);2016-06-09 03:29 AM
Okay I have commented out the lines you specified in the HAL_CAN_Receive_IT() function and receiving on both fifos. I have found however more bugs.
1. The member of the stuct CanRxMsgTypeDef called FIFONumber is not used in the code at all I believe. Its comment says:uint32_t FIFONumber; /*!< Specifies the receive FIFO number.
This parameter can be CAN_FIFO0 or CAN_FIFO1 */
But when you look into the CAN_Receive_IT function this parameter is not set before going further to the HAL_CAN_RxCpltCallback. I believe just before going to HAL_CAN_RxCpltCallback it is a good place to add something like:
hcan->pRxMsg->FIFONumber = FIFONumber;
2. Parameter FMI doesnt seem to be updated correctly. It should say which filter number worked. I am using filter 0 and 1 and even though this line in CAN_Receive_IT always sets FMI to 0:
/* Get the FMI */
hcan->pRxMsg->FMI = (uint8_t)0xFF & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8);
I would appreciate all feedback regarding this.
2016-09-01 06:29 AM
Hi Bremen,
Sorry for the late response. I take your feedbacks into consideration concerninf the FIFONumber to add the missed instance configuration into the receive function. I report it to be fixed. -Hannibal-2016-09-01 11:48 PM
i configured filters to receive it in both fifos. i want to arm both interrupts for receiving.
my workaround:void
_CAN_Receive_ALL (CAN_HandleTypeDef * hcan)
{
HAL_CAN_Receive_IT (hcan, CAN_FIFO0); // start receiving
// make sure both fifos will be checked
__HAL_CAN_ENABLE_IT (hcan, CAN_IT_FMP1);
__HAL_CAN_ENABLE_IT (hcan, CAN_IT_FMP0);
}
2016-09-03 04:16 AM
check this post.
https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy%2est%2ecom%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fRECIVE%20FIFO%20ON%20CAN%20BUS&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&cu...2016-11-13 08:41 AM
Hello there,
I see that the FIFO number is now updated in HAL F4 version 1.1. Was the problem with FMI discussed as well? I see that in the new version the only difference is that ''unsigned'' specifiers were added in the line:hcan->pRxMsg->FMI = (uint8_t)0xFFU & (hcan->Instance->sFIFOMailBox[FIFONumber].RDTR >> 8U);
2016-11-13 09:30 AM
I don't think the FMI issue advanced, last I remember you had several tasks to perform, so the validation guys had something to shoot at and I never heard back, so the ticket is probably dead at this point.
2016-11-13 10:00 AM
You are right, I got buried by other stuff. I am still onto this issue as soon as I get the time to write the testing programs.