Question
Removing delay for escaping blocking in my code
Hi all, i have a function that changes the PWM value over some time.. the issue is it get blocked by HAL_Delay.. what's the way to replace it with some non blocking method ?
void heartBeat_loop(uint8_t initial_val, uint8_t end_val, uint8_t n)
{
int delayl = 0;
HAL_GPIO_WritePin(RING_B_GPIO_Port, RING_B_Pin, GPIO_PIN_SET);
//only run this loop when the initial value max = 40
if(n==0) // when light ramp down slope
{
for(uint8_t x = initial_val; x>=end_val;) // 0- 100 in 2 sec
{
TIM16->CCR1= x;
x = x - 1;
//Detect 13 times 10ms of TIM6 has elapsed.
delayl = 1000/(initial_val-end_val);
HAL_Delay(delayl);
//Create a delay of 130ms
//loop will end with PWM val = 10 so 25% brightness
}
}