cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105 can bus FIFO didn't receive Extended ID

GK2
Associate

Hi

I am new at stm32 and build my can bus code i can receive and loop std id message between can1 and can 2 without problems. But when i send extended ID FIFO didn't receive them so didn't loop to another can

setup stm32f105

transreceiver actual TJA1055

 while (1)
 
 {
 
  /* USER CODE END WHILE */
 
 if(HAL_CAN_GetRxFifoFillLevel(&hcan1,CAN_RX_FIFO0)>0)
 
 {
 
             HAL_CAN_GetRxMessage(&hcan1, CAN_RX_FIFO0, &receiver1, receivermssgcan1);
 
txtransmittercan2.StdId= receiver1.StdId;
 
txtransmittercan2.ExtId= receiver1.ExtId;
 
txtransmittercan2.IDE= receiver1.IDE;
 
txtransmittercan2.RTR= receiver1.RTR;
 
txtransmittercan2.DLC= receiver1.DLC;
 
 
 
HAL_CAN_AddTxMessage(&hcan2,&txtransmittercan2, receivermssgcan1, &txmailboxcan2);
 
}
 
 
 
 
 
 
 
/* Schleife für can 2 Durchgang  */
 
if (HAL_CAN_GetRxFifoFillLevel(&hcan2,CAN_RX_FIFO1)>0)
 
 
 
{ HAL_CAN_GetRxMessage(&hcan2, CAN_RX_FIFO1, &receiver2, receivermssgcan2);
 
txtransmittercan1.RTR= receiver2.RTR;
 
 txtransmittercan1.DLC= receiver2.DLC;
 
 txtransmittercan1.StdId= receiver2.StdId;
 
 txtransmittercan1.ExtId= receiver2.ExtId;
 
 txtransmittercan1.IDE= receiver2.IDE;
 
HAL_CAN_AddTxMessage(&hcan1,&txtransmittercan1, receivermssgcan2, &txmailboxcan1);
 
}
 
 
 
  /* USER CODE BEGIN 3 */
 
 }
 
 /* USER CODE END 3 */
 
}
 
 
 
/**
 
 * @brief System Clock Configuration
 
 * @retval None
 
 */
 
void SystemClock_Config(void)
 
{
 
 RCC_OscInitTypeDef RCC_OscInitStruct = {0};
 
 RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
 
 RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
 
 
 
 /** Initializes the RCC Oscillators according to the specified parameters
 
 * in the RCC_OscInitTypeDef structure.
 
 */
 
 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
 
 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
 
 RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
 
 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
 
 RCC_OscInitStruct.LSIState = RCC_LSI_ON;
 
 RCC_OscInitStruct.Prediv1Source = RCC_PREDIV1_SOURCE_HSE;
 
 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
 
 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
 
 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
 
 RCC_OscInitStruct.PLL2.PLL2State = RCC_PLL_NONE;
 
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 
 {
 
  Error_Handler();
 
 }
 
 
 
 /** Initializes the CPU, AHB and APB buses clocks
 
 */
 
 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
 
               |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
 
 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
 
 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
 
 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
 
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
 
 
 
 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
 
 {
 
  Error_Handler();
 
 }
 
 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_RTC;
 
 PeriphClkInit.RTCClockSelection = RCC_RTCCLKSOURCE_LSI;
 
 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
 
 {
 
  Error_Handler();
 
 }
 
 
 
 /** Configure the Systick interrupt time
 
 */
 
 __HAL_RCC_PLLI2S_ENABLE();
 
}
 
 
 
/**
 
 * @brief CAN1 Initialization Function
 
 * @param None
 
 * @retval None
 
 */
 
static void MX_CAN1_Init(void)
 
{
 
 
 
 /* USER CODE BEGIN CAN1_Init 0 */
 
 
 
 /* USER CODE END CAN1_Init 0 */
 
 
 
 /* USER CODE BEGIN CAN1_Init 1 */
 
 
 
 /* USER CODE END CAN1_Init 1 */
 
 hcan1.Instance = CAN1;
 
 hcan1.Init.Prescaler = 18;
 
 hcan1.Init.Mode = CAN_MODE_NORMAL;
 
 hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ;
 
 hcan1.Init.TimeSeg1 = CAN_BS1_2TQ;
 
 hcan1.Init.TimeSeg2 = CAN_BS2_1TQ;
 
 hcan1.Init.TimeTriggeredMode = DISABLE;
 
 hcan1.Init.AutoBusOff = DISABLE;
 
 hcan1.Init.AutoWakeUp = DISABLE;
 
 hcan1.Init.AutoRetransmission = DISABLE;
 
 hcan1.Init.ReceiveFifoLocked = DISABLE;
 
 hcan1.Init.TransmitFifoPriority = DISABLE;
 
 if (HAL_CAN_Init(&hcan1) != HAL_OK)
 
 {
 
  Error_Handler();
 
 }
 
 /* USER CODE BEGIN CAN1_Init 2 */
 
CAN_FilterTypeDef Canfilteraufbau;
 
 
 
Canfilteraufbau.FilterActivation= CAN_FILTER_ENABLE;
 
Canfilteraufbau.FilterBank= 13;
 
Canfilteraufbau.FilterFIFOAssignment= CAN_FilterFIFO0;
 
Canfilteraufbau.FilterIdHigh= 0;
 
Canfilteraufbau.FilterIdLow= 0;
 
Canfilteraufbau.FilterMaskIdHigh = 0x0000;
 
Canfilteraufbau.FilterIdLow= 0x0000;
 
Canfilteraufbau.FilterMode=CAN_FILTERMODE_IDMASK;
 
Canfilteraufbau.FilterScale= CAN_FILTERSCALE_32BIT;
 
Canfilteraufbau.SlaveStartFilterBank=0;
 
HAL_CAN_ConfigFilter(&hcan1, &Canfilteraufbau);
 
/* USER CODE END CAN1_Init 2 */
 
 
 
}
 
 
 
/**
 
 * @brief CAN2 Initialization Function
 
 * @param None
 
 * @retval None
 
 */
 
static void MX_CAN2_Init(void)
 
{
 
 
 
 /* USER CODE BEGIN CAN2_Init 0 */
 
 
 
 /* USER CODE END CAN2_Init 0 */
 
 
 
 /* USER CODE BEGIN CAN2_Init 1 */
 
 
 
 /* USER CODE END CAN2_Init 1 */
 
 hcan2.Instance = CAN2;
 
 hcan2.Init.Prescaler = 18;
 
 hcan2.Init.Mode = CAN_MODE_NORMAL;
 
 hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ;
 
 hcan2.Init.TimeSeg1 = CAN_BS1_2TQ;
 
 hcan2.Init.TimeSeg2 = CAN_BS2_1TQ;
 
 hcan2.Init.TimeTriggeredMode = DISABLE;
 
 hcan2.Init.AutoBusOff = DISABLE;
 
 hcan2.Init.AutoWakeUp = DISABLE;
 
 hcan2.Init.AutoRetransmission = DISABLE;
 
 hcan2.Init.ReceiveFifoLocked = DISABLE;
 
 hcan2.Init.TransmitFifoPriority = DISABLE;
 
 if (HAL_CAN_Init(&hcan2) != HAL_OK)
 
 {
 
  Error_Handler();
 
 }
 
 /* USER CODE BEGIN CAN2_Init 2 */
 
 CAN_FilterTypeDef Canfilteraufbau2;
 
 
 
 Canfilteraufbau2.FilterActivation= CAN_FILTER_ENABLE;
 
 Canfilteraufbau2.FilterBank= 27;
 
 Canfilteraufbau2.FilterFIFOAssignment= CAN_FilterFIFO1;
 
 Canfilteraufbau2.FilterIdHigh= 0;
 
 Canfilteraufbau2.FilterIdLow= 0;
 
 Canfilteraufbau2.FilterMaskIdHigh = 0;
 
 Canfilteraufbau2.FilterIdLow= 0;
 
 Canfilteraufbau2.FilterMode=CAN_FILTERMODE_IDMASK;
 
 Canfilteraufbau2.FilterScale= CAN_FILTERSCALE_32BIT;
 
 Canfilteraufbau2.SlaveStartFilterBank=14;
 
 HAL_CAN_ConfigFilter(&hcan2, &Canfilteraufbau2);
 
 
 
 /* USER CODE END CAN2_Init 2 */

2 REPLIES 2
FBL
ST Employee

Hello @Görkem Kayur​ ,

There could be some possible reasons:

  • The issue could be related to the initialization sequence
  • It could be the software is not properly handling the Extended ID format, such as setting the proper ID mask and ID filter in the FIFO. You can refer to the example provided as reference.

You may check the configuration of transmission process, the type of identifier for the message that will be transmitted should be something like this : TxHeader.IDE = CAN_ID_EXT;

Hope this helps!

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

GK2
Associate

i show live data while debugging it didn't receive any Message no IDE no EXT or anything when i send extended Message

FIFO level is all the time on 0

i Tryed some other CAN transmitter

i Tryed 3 Other Devices to send message (Probably possible sending device have problems)

but its still same

Standard message have no Problems

i will show the example to check if i forget anything.