cancel
Showing results for 
Search instead for 
Did you mean: 

F469i-Disco CAN receive issues

Frederik_vonBaeyer
Associate

Hello dear ST community,

 

we want to use the STM32F469i as a Dashboard in our Formula Student car but we are having trouble receiving any can data whilst transmitting works just fine. We tried allot allready but nothing has worked for us so far.
We are using a PCAN-USB adapter and a TLV7251V CAN-Transeiver for our test setup. We tried to follow the can example for the F469eval board as close as possible (as there is no can example for the f469i-disco) but in normal mode not loopbackmode.

 
We tried receiving via polling and interrupt without success and we aim to make it work with interrupts.We activated the interrupts for RX0 and RX1 (we also tried using only one of them). We setup the Callback but it doesnt seem to trigger.

 

Here is some of our code (the rest is just the generated stuff from MX):

 

 

 

 

void HAL_CAN_RxFifo0MsgPendingCallback(CAN_HandleTypeDef *hcan)
{
  if (HAL_CAN_GetRxMessage(hcan, CAN_RX_FIFO0, &RxHeader, RxData) != HAL_OK)
  {
    Error_Handler();
  }

  HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, 0);

}

 

 

 

Here is our polling attempt:

 

 

 

if(HAL_CAN_GetRxFifoFillLevel(&hcan2, CAN_RX_FIFO0)>=1)
{
  HAL_CAN_GetRxMessage(&hcan2, TxMailbox, &RxHeader, RxData);
 
  memcpy(TxData,RxData, sizeof(RxData));
 
  HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, 0);
}

 

 

 

 

 

Here are our system clock settings (we heard they are important for the interrupts to work properly so we only changed as little as possible):

 

 

 

void SystemClock_Config(void)
{
  RCC_OscInitTypeDef RCC_OscInitStruct = {0};
  RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};

  /** Configure the main internal regulator output voltage
  */
  __HAL_RCC_PWR_CLK_ENABLE();
  __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE3);

  /** Initializes the RCC Oscillators according to the specified parameters
  * in the RCC_OscInitTypeDef structure.
  */
  RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
  RCC_OscInitStruct.HSEState = RCC_HSE_ON;
  RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
  RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
  RCC_OscInitStruct.PLL.PLLM = 4;
  RCC_OscInitStruct.PLL.PLLN = 80;
  RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
  RCC_OscInitStruct.PLL.PLLQ = 6;
  RCC_OscInitStruct.PLL.PLLR = 6;
  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_DIV2;

  if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
  {
    Error_Handler();
  }
}

 

 

 

 

Here is a picture of our clock setup graph:

Bild (5).png

 

We attached the full project (only changes in main.c where made) in case that helps.


We are very thankfull for every tip that you might have.

1 ACCEPTED SOLUTION

Accepted Solutions
SofLit
ST Employee

Hello,

You have an issue with the filter configuration:

You're using CAN2 and FilterBank = 0 with SlaveStartFilterBank = 14! This can work with CAN1 but not with CAN2:

  /* USER CODE BEGIN CAN2_Init 2 */
  	sFilterConfig.FilterBank = 0;
    sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
    sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
    sFilterConfig.FilterIdHigh = 0x446<<5;
    sFilterConfig.FilterIdLow = 0x0000;
    sFilterConfig.FilterMaskIdHigh = 0x446<<5;
    sFilterConfig.FilterMaskIdLow = 0x0000;
    sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
    sFilterConfig.FilterActivation = ENABLE;
    sFilterConfig.SlaveStartFilterBank = 14;

You need to set SlaveStartFilterBank = 0.

See this thread.

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.

View solution in original post

2 REPLIES 2
SofLit
ST Employee

Hello,

You have an issue with the filter configuration:

You're using CAN2 and FilterBank = 0 with SlaveStartFilterBank = 14! This can work with CAN1 but not with CAN2:

  /* USER CODE BEGIN CAN2_Init 2 */
  	sFilterConfig.FilterBank = 0;
    sFilterConfig.FilterMode = CAN_FILTERMODE_IDMASK;
    sFilterConfig.FilterScale = CAN_FILTERSCALE_32BIT;
    sFilterConfig.FilterIdHigh = 0x446<<5;
    sFilterConfig.FilterIdLow = 0x0000;
    sFilterConfig.FilterMaskIdHigh = 0x446<<5;
    sFilterConfig.FilterMaskIdLow = 0x0000;
    sFilterConfig.FilterFIFOAssignment = CAN_RX_FIFO0;
    sFilterConfig.FilterActivation = ENABLE;
    sFilterConfig.SlaveStartFilterBank = 14;

You need to set SlaveStartFilterBank = 0.

See this thread.

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.

Thank you so much, it works now!!!