Moving the common GPIO init outside the tasks is a better solution, I think.
Reading the code again I see that you’re also accessing the same GPIO peripheral and pin from both tasks. How should this work reliably ? Is there a (mutex) protection inside cyhal_gpio_write
? Otherwise when you write to the same GPIO (pin) from multiple tasks the resulting behavior will be random somehow.
And what’s your expected result and what’s the real behavior ? I still don’t understand what you try to achieve
Edit: Where are the global (and hopefully volatile
) variables adc_percent
and notify_temperature
set ?