2020-01-21 02:29 AM
I am using this Flow for Transmitting Data and Receiving If Anything I am Missing From Flow of Execution wise i am not getting Receiver Callback.
filterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
filterConfig.FilterIdHigh = 0;
filterConfig.FilterIdLow = 0;
filterConfig.FilterMaskIdHigh = 0x0000;
filterConfig.FilterMaskIdLow = 0x0000;
filterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
filterConfig.FilterActivation = CAN_FILTER_ENABLE;
filterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
filterConfig.FilterBank = 0;
filterConfig.SlaveStartFilterBank = 0;
/*##-2- Configure the CAN Filter ###########################################*/
if( HAL_CAN_ConfigFilter(&hcan1, &filterConfig) != HAL_OK )
{
strcpy((char *)pData,"failCFG");
HAL_UART_Transmit( &huart1,pData, 10, 10 );
}
/*##-3- Start the CAN peripheral ###########################################*/
if (HAL_CAN_Start(&hcan1) != HAL_OK)
{
/* Start Error */
Error_Handler();
}
/*##-4- Activate CAN RX notification #######################################*/
if (HAL_CAN_ActivateNotification(&hcan1,CAN_IT_RX_FIFO0_MSG_PENDING ) != HAL_OK)
{
/* Notification Error */
Error_Handler();
}
void CAN1_Tx( void )
{
CAN_TxHeaderTypeDef TxHeader;
uint32_t TxMailBox;
TxHeader.DLC = 2;
TxHeader.StdId = CAN_TRANSMIT_ID;
TxHeader.IDE = CAN_ID_STD;
TxHeader.RTR = CAN_RTR_DATA;
TxHeader.ExtId = 0x01;
TxHeader.TransmitGlobalTime = DISABLE;
aTxData[0] = ubKeyNumber;
aTxData[1] = 0xAD;
if( ubKeyNumber == 0x2 )
{
ubKeyNumber = 0x0;
}
if( HAL_OK != HAL_CAN_AddTxMessage( &hcan1, &TxHeader, aTxData, &TxMailBox ) )
{
strcpy((char *)pData,"failed\r\n");
HAL_UART_Transmit( &huart1,pData, 10, 10 );
}
//while( HAL_CAN_IsTxMessagePending(&hcan1, TxMailBox ) );
while(HAL_CAN_GetTxMailboxesFreeLevel(&hcan1) != 3) {}
strcpy((char *)pData,"msgSucees");
HAL_UART_Transmit( &huart1,pData, 10, 10 );
HAL_Delay(200);
LED_Switch(++ubKeyNumber);
}
If anything I am Missing For Enabling Rx Interrupt Let me know
2020-02-05 10:10 PM
I got The RX Interrupt Callback. because of hardware issue on Transceiver so after fixing that i got the message what i transmitted.