2019-11-12 03:25 AM
I am working with stm32f04c6 microprocessor.I've already sent data with canbus. now it does not work. status (tsr) code terro bit 1 is.
there is no ack
CAN error status register (CAN_ESR)
LEC[2:0]=011; 011: Acknowledgment Error
what should i do?
////can cubemx init.
hcan.Instance = CAN;
hcan.Init.Prescaler = 12;
hcan.Init.Mode = CAN_MODE_NORMAL;
hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
hcan.Init.TimeSeg1 = CAN_BS1_13TQ;
hcan.Init.TimeSeg2 = CAN_BS2_2TQ;
hcan.Init.TimeTriggeredMode = DISABLE;
hcan.Init.AutoBusOff = DISABLE;
hcan.Init.AutoWakeUp = DISABLE;
hcan.Init.AutoRetransmission = DISABLE;
hcan.Init.ReceiveFifoLocked = DISABLE;
hcan.Init.TransmitFifoPriority = DISABLE;
if (HAL_CAN_Init(&hcan) != HAL_OK)
{
Error_Handler();
}
//filter config
sFilterConfig.FilterBank = 0;
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_RX_FIFO0;
sFilterConfig.FilterActivation = ENABLE;
sFilterConfig.SlaveStartFilterBank = 14;
if(HAL_CAN_ConfigFilter(&hcan, &sFilterConfig) != HAL_OK)
{
Error_Handler();
}
if (HAL_CAN_Start(&hcan) != HAL_OK)
{
Error_Handler();
}
/* Activate CAN RX notification*/
if (HAL_CAN_ActivateNotification(&hcan, CAN_IT_RX_FIFO0_MSG_PENDING) != HAL_OK)
{
Error_Handler();
}
TxHeader.StdId = 0x4DE;//degiskene donecek
TxHeader.ExtId = 0x01;//degiskene ..
TxHeader.RTR = CAN_RTR_DATA;
TxHeader.IDE = CAN_ID_STD;
TxHeader.DLC = 8;//degiskene ..
TxHeader.TransmitGlobalTime = DISABLE;
///loop
while(1)
{
do
{
freeTxMailBox=HAL_CAN_GetTxMailboxesFreeLevel(&hcan);
}while(freeTxMailBox!=3);
if (HAL_CAN_AddTxMessage(&hcan, &TxHeader, paketDataSekiz, &TxMailbox) != HAL_OK);
}