cancel
Showing results for 
Search instead for 
Did you mean: 

Changes in ioc file not updating the code.

Gladson
Associate III

I am working on STM32F103 for a project with CAN. While working I set the CAN Test mode to Loopback in the ioc file, afterwards I set the test mode back to normal mode. but this change was not updated in the main.c file. In main.c file, the line in MX_CAN_Init(void) function still is as following.

 

hcan.Init.Mode = CAN_MODE_LOOPBACK;

 

 I cleaned the project and then again built the project, still it is same, I tried to change the test mode multiple times, but every time it asks if code should be generated and I select yes, still the code is not changing. Why is this happening?

 

CAN configuration:

Gladson_0-1712912318500.png

Generated code

 

static void MX_CAN_Init(void)
{

  /* USER CODE BEGIN CAN_Init 0 */

  /* USER CODE END CAN_Init 0 */

  /* USER CODE BEGIN CAN_Init 1 */

  /* USER CODE END CAN_Init 1 */
  hcan.Instance = CAN1;
  hcan.Init.Prescaler = 16;
  hcan.Init.Mode = CAN_MODE_LOOPBACK;
  hcan.Init.SyncJumpWidth = CAN_SJW_1TQ;
  hcan.Init.TimeSeg1 = CAN_BS1_2TQ;
  hcan.Init.TimeSeg2 = CAN_BS2_1TQ;
  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();
  }
  /* USER CODE BEGIN CAN_Init 2 */

  /* USER CODE END CAN_Init 2 */

}

 

Code Generator settings

Gladson_1-1712912403244.png

 

 

 

13 REPLIES 13

@Gladson wrote:

 Is there anything else that I could have messed up? 


Have you (accidentally) messed with any of the USER CODE BEGIN and/or USER CODE END comments?

If they go wrong, then CubeMX might be thinking that its code is now within one of the USER sections - therefore won't update it ... ?

I tried after closing all the projects and files in CubeIDE, still not working,
I am using windows 10.

I checked for the USER CODE BEGIN and USER CODE END, All the USER CODE BEGIN does have a USER CODE END, I also checked the difference with git but I did not find any changes to those comments. Is there a better way to check this so I can be sure that I did not mess that up?

Hello,

Could you please attach your project in a zip file?

 

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.