cancel
Showing results for 
Search instead for 
Did you mean: 

stm8 using AWU/HALT/EXTI

mag1_eng
Visitor

I am building time lag switch

- i have at42q1010 touch ic connected to PA3
- i have stm8s003f3 mcu
- Using latching relay to conserve power
- timeout is my pot value
- Exti on at42q1010 rising edge exti_cr1 =0x01; ( the ic reads low when no touch and when touched it goes high for as long as touch pad is touched)
so basic is
// debounced touch in is my touch ic pin pa3
if (debounced_touch_in) touch_hold_count++;
if (touch_hold_count>=10){ timer_flag=1; device_relay_on();(this is done in my touch_sensor() function)
then inside my 1ms interrupt routine i am
if (timer_flag){
timeout_counter++;
}
if (timeout_counter >=timeout && timer_flag){
relay_off();
timeout_counter=0
touch_hold_count=0
timer_flag=0;
}

so in my 1ms i am doing
touch_in_flag=1; (initiailly this flag is zero) so after setting it to 1 then in my touch_sensor func i am
if (debounced_touch_in && touch_in_flag) touch_hold_count++;

ok so i want awu in it my awu func has:

awu setup is as
awu_csr1=0;
awu_tbr=0x0E
awu_apr = 0x17
awu_csr1=1;


so now what i want is

1- AWU should wakeup mcu for 1sec and then go back to halt()when timer_flag basically when my timer is running and timeout_counter is inc
and in between if touch pin is touched (EXTI) it must exit awu and perform whatever task it is supposed to like
- resetting timeout_counter or device relay off();

2- Only enter halt when relay is off ; timer_flag =0 ; timeout_counter =0;
It must wake up only on exti0 or when touch pad is touched

 

0 REPLIES 0