2020-07-15 05:31 AM
here is my code
void can(void)
{
CAN_TxHeaderTypeDef TxHeader;
uint32_t TxMailbox;
uint8_t usr_msg[10]={'h','e','l','l','o'};
TxHeader.DLC=2;
TxHeader.RTR= CAN_RTR_DATA ;
TxHeader.IDE= CAN_ID_STD;
TxHeader.StdId= 0x65;
if(HAL_CAN_AddTxMessage(&hcan1,&TxHeader,usr_msg,&TxMailbox)!=HAL_OK)
{
Error_Handler();
}
while(HAL_CAN_IsTxMessagePending(&hcan1,TxMailbox));
HAL_GPIO_WritePin(GPIOB, LD1_Pin, GPIO_PIN_SET);
}
void RX(void)
{
CAN_RxHeaderTypeDef RxHeader;
uint8_t rcv_msg[10];
while(HAL_CAN_GetRxFifoFillLevel(&hcan2,CAN_RX_FIFO0));
if(HAL_CAN_GetRxMessage(&hcan2,CAN_RX_FIFO0,&RxHeader,rcv_msg)!=HAL_OK)
{
Error_Handler();
}
HAL_GPIO_WritePin(GPIOB, LD2_Pin, GPIO_PIN_SET);
}
2020-07-16 02:48 AM
if(HAL_CAN_GetRxMessage(&hcan2,CAN_RX_FIFO0,&RxHeader,rcv_msg)!=HAL_OK)
{
HAL_CAN_GetError(&hcan2);
}
2020-07-16 03:01 AM
HAL_CAN_GetError returns an error code. Look it up in the stm32f4xx_hal.h source file and analyze yourself.
2020-07-16 10:43 PM
sir message not entering into CAN_RX_FIFO0
2020-07-31 02:37 AM
sir problem has not resolved till now .any help from you it could be very helpful....:)
2020-08-03 05:30 AM
No more ideas, sorry. Have you checked at the electrical level what's going on on the bus?