hi
how make loop for specific time? i am using pic 16f627 with 4MHZ
thanks
how make loop for specific time?
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: how make loop for specific time?
Hi hertz89,
You not stated how long you would like the loop to last for, so I have created a loop to last for 500ms.
There are several ways.
Here are two that I can think off:
One way is: Another is to use a timer interrupt.
Within the loop you can get it to exit only when a variable say TimerFlag is set to 1.
Just before the start of the loop, set timer TimerFlag to 0.
Allow the timer to count specific time period, then when this time period has elapsed then set TimerFlag to 1.
Then loop will automatically exit.
If you get stuck then if you post your flowchart we can see if we can help you out.
Martin
You not stated how long you would like the loop to last for, so I have created a loop to last for 500ms.
There are several ways.
Here are two that I can think off:
One way is: Another is to use a timer interrupt.
Within the loop you can get it to exit only when a variable say TimerFlag is set to 1.
Just before the start of the loop, set timer TimerFlag to 0.
Allow the timer to count specific time period, then when this time period has elapsed then set TimerFlag to 1.
Then loop will automatically exit.
If you get stuck then if you post your flowchart we can see if we can help you out.
Martin
Martin
-
- Matrix Staff
- Posts: 9521
- Joined: Sat May 05, 2007 2:27 pm
- Location: Northamptonshire, UK
- Has thanked: 2585 times
- Been thanked: 3815 times
- Contact:
Re: how make loop for specific time?
Hi hertz89,
You're welcome.
So long as the solution helps.
Out of curiosity did you have a particular time in mind?
Martin
You're welcome.
So long as the solution helps.
Out of curiosity did you have a particular time in mind?
Martin
Martin