Skip to main content
MQi.1
Senior II
Jan 20, 2021 6:54 AM UTC
Solved

Should these be these?

I found these prompt in my "main.c" of NonSecure generated by MX for NUCLEO L552ZE-Q:

 /* USER CODE BEGIN WHILE */
 while (1)
 {
 /* USER CODE END WHILE */
 
 /* USER CODE BEGIN 3 */
 }
 /* USER CODE END 3 */
}

should it be this?

 /* USER CODE BEGIN WHILE */
 while (1)
 {
/* USER CODE BEGIN 3 */
 
 /* USER CODE END 3 */
 }
 /* USER CODE END WHILE */
}

This topic has been closed for replies.
Piranha
PiranhaBest answer
Principal III
Jan 20, 2021 9:45 AM UTC

Except, if break is used. Or even goto... :)

4 replies

KnarfB
Super User
Jan 20, 2021 7:00 AM UTC

No. These are 2 user code blocks around the beginning and ending of the loop. Some additional software packs may generate code inbetween those (near line 5), do not use it for user code.

MQi.1
MQi.1Author
Senior II
Jan 20, 2021 8:15 AM UTC

So, if one need insert code behind while(), where should it be pasted?

KnarfB
Super User
Jan 20, 2021 8:40 AM UTC

You can add user code by inserting new lines between 1 and 2 (before while), 3 and 4 (inside while), 6 and 7 (inside while), or 7 and 8 (after while) as you like.

Code behind while(1) {...} is unreachable however.

Piranha
PiranhaBest answer
Principal III
Jan 20, 2021 9:45 AM UTC

Except, if break is used. Or even goto... :)