cancel
Showing results for 
Search instead for 
Did you mean: 

Test the UIF Flag

HThak.2
Associate

I am newbie getting lost in the HAL functions/features to use. I use STM32CubeMx to generate the code and use Keil uvision5 for development. I use STM32G071 Nucleo-64 development kit.  

I wish to measure a ‘start’ pulse of a proprietary protocol. The pulse, if low for 55 microseconds is considered start pulse.

A port pin has been configured as input. Idea is to poll the line and when a low level is detected, measure the time for how long pulse remains low.

I have used timer 3 with no prescalar, in up counting mode. The ARR count is 3520@64MHz. So far, I have not used any interrupt.

After a low level is detected, the timer is started by

HAL_TIM_Base_Start(&htim3);

As a next step, I wish to poll the UIF flag to check whether the time has elapsed.

I do not know which HAL function or what should I use to check the status of the flag.

Once detected I will need to clear it as well

1 ACCEPTED SOLUTION

Accepted Solutions
HThak.2
Associate

I wished to delete the post since I did manage to find the answer but my rights were disabled by administrator.

__HAL_TIM_GET_FLAG(&htim3, TIM_FLAG_UPDATE) - gave me option to poll the flag.

__HAL_TIM_CLEAR_FLAG(&htim3, TIM_FLAG_UPDATE); - clears the flag

Bit silly to ask but I am still learning.

View solution in original post

2 REPLIES 2
HThak.2
Associate

I wished to delete the post since I did manage to find the answer but my rights were disabled by administrator.

__HAL_TIM_GET_FLAG(&htim3, TIM_FLAG_UPDATE) - gave me option to poll the flag.

__HAL_TIM_CLEAR_FLAG(&htim3, TIM_FLAG_UPDATE); - clears the flag

Bit silly to ask but I am still learning.

Imen.D
ST Employee

Hello @HThak.2​  and welcome to the STM32 Community :)

Please don't delete your post, it is better to keep your problem and solution as well.

I marked your answer as Best Answer, as this can be very helpful for Community users to find this solution more quickly.

Imen

When your question is answered, please close this topic by clicking "Accept as Solution".
Thanks
Imen