Page 1 of 1

Port bit test during a time delay

Posted: Sat May 05, 2007 2:58 pm
by medelec35
Running Flowcode V3 with 12F675.

I have the following working routine:

Read ADC channel 0 (0 to 255)
Convert ADC to time delay (1 to 10 Min's)
Run macro A
Start again.

I would like to know how to do bitwise test of a port (it Could be a port without an interrupt) during timing period, and if port is high then immediately stop timing and call a macro.

This is what I would like:

Read ADC channel 0 (0 to 255) e.g. 127
Convert ADC to time delay (1 to 10 Min's) e.g 5 Min's
Run macro A if port a2 has just gone high but still got 2 Min's delay left.
Run macro B if full delay ran since port a2 has stayed low e.g After 5 Min's
Start again.


Thank you.

Posted: Tue May 08, 2007 10:53 am
by Steve
You could use the timer interrupt with a count variable to create the appropriate time delay - this would free up the processor to look at the i/o line.

Alternatively, use a count variable with a loop and a small delay (10 ms?) to generate your large delay times, and look at the input within this loop.