2022-12-29 11:40 PM
Hi , may I know why when I put my code under while(1), it doesn't execute my code?
2022-12-30 12:02 AM
Look for the reason before the code which is not executed. Use the debugger to catch the problem.
2022-12-30 12:42 AM
Hello @Angle
Could you please provide more details about the product name
Also provide more details on the issue: which MX version are you using? at which level exactly the error is faced?
I suggest to s start with an example using UART.
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.
2022-12-30 12:55 AM
Hi, my using the STM32H750XBH-DK touchgfx.
I also don't know why it doesn't execute my code when I put it in while(1) in user begin 3. I think there is no problem with my code since I also try to executed by putting my code at user begin 2 and it working.
This is one is when I put my code in in user begin 2, my code can be executed but I need to add the while(1) since I need to use the loop. I can read the data display
2022-12-30 12:57 AM
btw I already start with the very simple basic UART
2022-12-30 01:37 AM
Doesn't get there due to already having transferred to task started by the scheduler?
Perhaps stop in the debugger and see what code it IS executing..
2022-12-30 01:40 AM
--- and if you put code in "normal" intended position :
2022-12-30 02:18 AM
So, you skipped few "minor details" from your problem description. The processor never enters the loop, you are starting the operating system scheduler before the loop and the processor is "stuck" in the operating system and the tasks run by it. By definition it should never return from OS start routine.
Can you see the comment "We should never get there as control is now taken by the scheduler"?
2022-12-30 02:47 AM
You can't use the while loop in main.c as the code never reaches it because the scheduler takes over.
Instead you'll have to use the default task or create a new task in FreeRTOS. But if you use the default task then call some Polling functions in a different file. In main.c you should find a function called StartDefaultTask
/* USER CODE BEGIN Header_StartDefaultTask */
/**
* @brief Function implementing the defaultTask thread.
* @param argument: Not used
* @retval None
*/
/* USER CODE END Header_StartDefaultTask */
void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
PollingInit();
for(;;)
{
PollingRoutine();
osDelay(0);
}
/* USER CODE END 5 */
}
I'm calling PollingInit() that is function that has initializing tasks. This is only called once. Then the PollingRouting() is in the for(;;) loop. So the PollingRoutine is where you'll do you own tasks outside of the TouchGFX tasks.