STM32CO11 DELAYS NOT WORKING
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 4:31 AM
if(Mains>0.1)
{
if((Mains<1) &&(Vbat>0.9))
{
TIM1->CCR4=TIM1->ARR;
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_4);
Set_LED(0);
Batt_Chrge(0);
HAL_Delay(1000);
}
else
{
TIM1->CCR4=0;
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_4);
Batt_Chrge(0);
}
if((Mains<0.1)&&(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6)==GPIO_PIN_SET))
{
TIM1->CCR4=TIM1->ARR/2;
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_4);
Batt_Chrge(0);
}
else if((Mains<0.1)&&(HAL_GPIO_ReadPin(GPIOA,GPIO_PIN_6)==GPIO_PIN_RESET))
{
TIM1->CCR4=TIM1->ARR;
HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_4);
Batt_Chrge(0);
}
}
/*REST OF MY CODE*/
if((Mains<0.1)&& (TIM1->CCR4 == 0))
{
count++;
if(count>=50)
{
Enter_sleep();
}
}
hi can anyone please let me what is wrong ,these code should be worked only detecting the mains as after Mains>0.1 if interruptions occur it should start again only after mains>0.1.I have also configured SYSTICK but I am not sure why my delay is not working .
- Labels:
-
STM32C0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 5:22 AM
What isn't working about the code in particular? Perhaps break it into smaller sections and try those. If delay isn't working, move that logic into a simpler block.
Consider debugging and stepping through the code to find out what isn't working as expected and why.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-09-18 5:34 AM
Lacking a lot of context here.
Are you doing this in an interrupt/callback ? Going to be priority/preemption issues there if relying on SysTick, etc, to advance the software tick counter.
You'd need to differ execution using other methods, so you can leave the callback immediately.
Up vote any posts that you find helpful, it shows what's working..
