cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F2 CAN no TX

Ivan Ladygin
Associate
Posted on July 06, 2018 at 16:30

Cube generated Keil project with CAN

I have developing own SW for third-party HW, original SW working with CAN interface and CAN works good - so HW is OK. My startup initiate CAN with 500kb, and RX0 interrupt working good - I am able to receive CAN message, BUT! only if there is one more(3-rd) workable device in CAN BUS. And if there is only my Device and CAN transmitter (I have IXXAT usb2CAN) transmitter(IXXAAT) say's: CAN ERROR. My STM32F205 device receiving CAN message properly (when 3-rd device is on bus) so baudrate and filters setup is correct, right? My STM32F205 device NOT SEND anything when I use HAL_CAN_Transmit_IT, and there is TIMEOUT ERROR when I use HAL_CAN_Transmit. So I believe I have some initialization trouble. I think there is no ACK handshake - that is why without 3-rd party device in CAN i can't even receive. All Init functions are CUBE generated, and I don't know where to look.... Any Idea's will be appreciated

void SystemClock_Config(void)
{
 RCC_OscInitTypeDef RCC_OscInitStruct;
 RCC_ClkInitTypeDef RCC_ClkInitStruct;
 /**Initializes the CPU, AHB and APB busses clocks 
 */
 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 = 10;
 RCC_OscInitStruct.PLL.PLLN = 200;
 RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
 RCC_OscInitStruct.PLL.PLLQ = 5;
 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
 /**Initializes the CPU, AHB and APB busses 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_DIV4;
 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2;
 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_3) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
 /**Configure the Systick interrupt time 
 */
 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000);
 /**Configure the Systick 
 */
 HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK);
 /* SysTick_IRQn interrupt configuration */
 HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0);
}
/* CAN1 init function */
static void MX_CAN1_Init(void)
{
 hcan1.Instance = CAN1;
 hcan1.Init.Prescaler = 5;
 hcan1.Init.Mode = CAN_MODE_NORMAL;
 hcan1.Init.SJW = CAN_SJW_1TQ;
 hcan1.Init.BS1 = CAN_BS1_6TQ;
 hcan1.Init.BS2 = CAN_BS2_5TQ;
 hcan1.Init.TTCM = DISABLE;
 hcan1.Init.ABOM = ENABLE;
 hcan1.Init.AWUM = ENABLE;
 hcan1.Init.NART = ENABLE;
 hcan1.Init.RFLM = DISABLE;
 hcan1.Init.TXFP = DISABLE;
 if (HAL_CAN_Init(&hcan1) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 }
}�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

0 REPLIES 0