Count time after pushing button

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi,

   

I want to count 2 minutes after I push a button. I do it that way:

   

- I'm always checking the state of the button on the main loop, so that if it gets pressed I do "Timer_1_Start();".

   

- Timer1 is configured (Trigger mode none, Capture mode none, Enable mode Software only and Run mode Continouos).

   

- In the "tc" output of the Timer1 I connect a Interrupt component "isr_1", so that when timer1 is time out I do "Timer_1_Stop();" and other tasks.

   

Is there anyway to do this simplest ? Maybe configuring One shot Run mode on Timer1 ? 

   

Thank you !!

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The one shot needs a hardware reset signal to run again, so your solution is probably the simplest.

   

Only thing I can imagine is to set up an interrupt for the button's pin to avoid polling the button state.

   

 

   

Bob

View solution in original post

0 Likes
1 Reply
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The one shot needs a hardware reset signal to run again, so your solution is probably the simplest.

   

Only thing I can imagine is to set up an interrupt for the button's pin to avoid polling the button state.

   

 

   

Bob

0 Likes