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

 

 

 

15 REPLIES 15

@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.
LSZ
Associate

Hello Gladson

Im here because now i have the same problem of you. I don't know if you could resolve the problem but in my case, i receive this message from the software when i tried to create a new project.Problem_generation_code.png

I hope this can be helpful.

Hello @LSZ and welcome to the community,

As the OP was not replying since awhile, it's better to open a new thread and describe extactly what you have done.

See tips on how to post a 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.