2024-07-26 05:54 AM
Hello,
My application is loaded via flash memory. Four threads are created and they seem to be generated correctly because when the board is connected to the computer, all the threads run well. But if I disconnect the power and then turn it back on, the threads no longer run.
Systick is used for ThreadX and TIM6 is used for HAL-Tick.
But the scheduler does not start the threads. I do not understand why. I am new to threads.
Has anyone encountered a similar problem and have solutions to suggest? Please
I am attaching the file app_thread.c
2024-07-26 06:14 AM - edited 2024-07-26 06:15 AM
Hi,
i think, this has nothing to do with threads.
Just make a simple test program, just flashing a LED (if you have one there on a pin). no RTOS/thread .
Use same clock tree setting and flashing mode.
Then check: is this program running after power cycle ?
2024-07-26 06:36 AM
Thanks for your reply.
Before calling MX_ThreadX_Init();
void MX_ThreadX_Init(void)
{
/* USER CODE BEGIN Before_Kernel_Start */
/* USER CODE END Before_Kernel_Start */
tx_kernel_enter();
/* USER CODE BEGIN Kernel_Start_Error */
/* USER CODE END Kernel_Start_Error */
}
in the main.c file, I make the leds blink and on startup it does. But after MX_ThreadX_Init(), nothing happens
2024-07-29 01:30 PM
That is to be expected as tx_kernel_enter() never returns if it starts correctly. Note the comments for user code after tx_kernel_enter(). It is only reached if there is an error starting the kernel.
One thing to try in your threaded application is to blink a LED in the Kernel_Start_Error section to indicate an error starting the kernel.
How is the board powered when it is disconnected from the computer?
2024-08-01 12:31 AM
I placed the code to make the LED blink in the section /* USER CODE BEGIN Kernel_Start_Error */ and the LED does not blink when powered on. Therefore, the kernel startup is functioning properly.
The board is powered by mains (it is an internal development board for the company). BOOT0 is set to 0.
Do you have any other troubleshooting suggestions?please
2024-08-01 01:16 AM
Ok,
so
1. make a simple test program, no rtos, as i wrote. Just blink the LED...success ?
2. with htos, put the simple LED-blink in a thread, maybe the first that rtos gives you as your new "main" .
In both cases you should get the same : LED blinking.
Just using for the delay HAL_delay() for simple test without rtos , but the delay for your rtos , maybe like this:
for( ;; )
{
/* Simply toggle the LED every 500ms, blocking between each toggle. */
ToggleLED();
tx_thread_sleep(50);
}
2024-08-01 03:43 AM - edited 2024-08-01 04:00 AM
@AScha.3 : I did the two tests, and in both cases, it works really well when powered on.
In my situation, I want to manage 4 threads. So, after conducting the tests you recommended on one thread, I tried doing the same on all 4 threads, and it also worked. Therefore, the problem must be related to what I am doing inside the threads. However, I don't understand why it doesn't work upon powering on without having to re-upload the code.
2024-08-01 04:07 AM - edited 2024-08-01 04:10 AM
I am waiting for data from UART9 using HAL_UART_Receive_DMA(), and this data is processed within the threads. Now, I am starting to think that the interrupt system is not active after powering on.
Would you like me to provide a potential troubleshooting approach or steps to diagnose and fix this issue?
/* USER CODE BEGIN 2 */
HAL_UART_Receive_DMA(&huart9, rx_data, 1);
HAL_TIM_PWM_Start(&htim1, TIM_CHANNEL_1);
HAL_TIM_Base_Start(&htim2);
/* USER CODE END 2 */
MX_ThreadX_Init();
2024-08-01 04:38 AM
To make it work, I replaced
HAL_UART_Receive_DMA(&huart9, rx_data, 1);
with
HAL_UART_Receive_IT(&huart9, rx_data, 1);
and now it works very well.
I don't understand why using DMA on power-up causes the UART not to activate. Do you have any idea?
2024-08-01 04:40 AM
>I did the two tests, and in both cases, it works really well when powered on.
GOOD !
+
>that the interrupt system is not active after powering on
If you dont stop it - it IS active .
--- as you set it in Cube -> nvic settings (priority, active or not ---check this. )
Just make the priority ranking with some sense - and the Azure sys timer is handeled by itself, you cannot change its settings. (TIM6 or whatever you give it...)