2016-02-19 01:45 AM
Hello!
I am using a stm32f302rE custom made board. My codes keep getting stuck in the waiting for acknowledge portion in HAL_CAN_INIT:/* Wait the acknowledge */
while((hcan->Instance->MSR & CAN_MSR_INAK) == CAN_MSR_INAK)
{
if((HAL_GetTick()-tickstart) > INAK_TIMEOUT)
{
hcan->State= HAL_CAN_STATE_TIMEOUT;
return HAL_TIMEOUT;
}
}
I have configured my clock as follows:
RCC_OscInitTypeDef RCC_OscInitStruct;
RCC_ClkInitTypeDef RCC_ClkInitStruct;
RCC_PeriphCLKInitTypeDef PeriphClkInit;
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_LSI|RCC_OSCILLATORTYPE_HSE;
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
//RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
RCC_OscInitStruct.PLL.PREDIV = RCC_PREDIV_DIV1;
// RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV16;
RCC_OscInitStruct.LSIState = RCC_LSI_ON;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL5;
// RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL2;
HAL_RCC_OscConfig(&RCC_OscInitStruct);
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV2;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0);
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_TIM15|RCC_PERIPHCLK_TIM16
|RCC_PERIPHCLK_TIM17;
PeriphClkInit.Tim15ClockSelection = RCC_TIM15CLK_HCLK;
PeriphClkInit.Tim16ClockSelection = RCC_TIM16CLK_HCLK;
PeriphClkInit.Tim17ClockSelection = RCC_TIM17CLK_HCLK;
HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit);
HAL_RCC_MCOConfig(RCC_MCO, RCC_MCOSOURCE_SYSCLK, RCC_MCO_DIV1);
__SYSCFG_CLK_ENABLE();
I have already enabled CAN clock.
Any suggestions on how to solve this?
#looking-in-the-wrong-place #selective-cut-n-paste
2016-02-19 03:54 AM
Any suggestions on how to solve this?
Zoom out a couple of levels. Are ANY of the registers in the CAN peripheral non-zero?2016-02-22 07:54 PM
Hi Clive,
I have checked the MSR register. I noticed the last for bits in the register are 1001. According to the register bit assignment, these bits correspond to: 1 - wake up interrupt 0 - error interrupt 0 - Sleep acknowledge 1 - initialisation acknowledge Any suggestions how to solve this??2016-02-23 03:56 AM
Dear ms.shasha,
How did you debug your clock configuration. Check if it is configured accurately what you need.Only after that you should debug your CAN.