Port b output whilst reading porta.

Status
Not open for further replies.

ukmxer

New Member
I am a Noob but I am trying to learn from the datasheet and strugling.

I want to read in 5 pulses and then output one pulse for 1.5 seconds.
I can do both myself but I can not do them simultaneous. My program is a right mess now so I am going to start again. I have not used tmr0 yet but I am wondering if that is how I do it.
Currently I have F84 and F628 to choose from.

1....Count in five pulses
2....Now output a 1.5 sec high
3....Go back and read in five pulses but carry on output until 1.5 secs ends.
4....If five pulses are in before 1.5secs are over then refresh output back to 1.5secs and start output again.

My main problem is that I do not know how to carry on running my program whilst outputting and checking output to see if the 1.5secs are over.


Thank you
 
I have not used tmr0 yet but I am wondering if that is how I do it.
Yes, use one of the timers to trigger an interrupt routine at a set rate; say 0.1 second. Then have a variable called COUNTER that you set to 15 (decimal) in your main routine when a string of 5 pulses is detected.
In your interrupt routine you'd decrement COUNTER if it is not zero and also output a "high" for the pulse. If COUNTER is zero, you'd just output a "low" for the end of the pulse (no decrementing COUNTER) and exit.
 
Thank you for your guidance.

Is an interrupt routine something you code yourself or is it something you call that is already resident in the chip.

Going to work now so hope to read this later.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…