Searching \ for 'Some I/O timimg questions...' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/ios.htm?key=i%2Fo
Search entire site for: 'Some I/O timimg questions...'.

Truncated match.
PICList Thread
'Some I/O timimg questions...'
1995\08\30@050901 by Dennis Velthuis

flavicon
face
Hi all.
I have some I/O timing questions.
I am using a PIC 16c84 4Mhz version using XT mode with 4mhz xtal and 15pf
caps.
I want to be able to monitor a pulse on a input pin (rb0) which only lasts
5 us.
For example with the following code:

loop
    btfss port_b, 00h    ; check rbo status
    goto  loop           ; rbo is low so loop again
    ............         ; rbo is high, take further actions

So my question is, is this possible?
Should I use interrupt?
Or better, use a faster pic version? (20mhz)
I don't have an oscillopscope but I have the data hand book 95/96

Another question...
Let's say I have an instruction which sets an ouptut high.
How long does this take in us/ns terms? Yes minmal one instruction cycle
but I expect that the rise to 5v of the output pin also takes some time..
So the total time will be 1 us + some rising time I expect.
I looked in the databook, couldn't find the information.

Last one...
What is the minimal input pulse duration I can monitor on a 20 mhz version?
So that when the input is high an action is taken and when it becomes low
again some other action is taken.

I hope someone can give me the details, thanks in advance.

D. Velthuis

1995\08\31@105817 by Mike Schreck

flavicon
face
All,
       My thanks to Andrew Warren <spam_OUTfastfwdTakeThisOuTspamix.netcom.com> for a sanity
check on my comments below. Andy's thoughts are indented.

mjps_

>PIC 16c84 4Mhz [snip] monitor a pulse which only lasts 5 us.
>loop
>     btfss port_b, 00h    ; check rbo status
>     goto  loop           ; rbo is low so loop again
>     ............         ; rbo is high, take further actions
>So my question is, is this possible?

I'm not an engineer, but I'll take a stab at this one. The loop
takes up 3 processor cycles which at 4Mhz (internally divided by 4)
is 3us. this doesn't give you any time to do anything meaningful in
"further actions".

       If he JUST misses the rising edge with his BTFSS, he'll be four
       cycles into the 5-microsecond pulse before the instruction after the
       GOTO is executed (two cycles for the GOTO, then two more for the
       BTFSS when the branch is taken).  THAAT instruction will take at
       least one cycle, so the falling edge of the pulse will have happened
       before he gets around to checking for it.

>Should I use interrupt?
Interrupts have a 4 clock cycle overhead just to start, then you
need to save W and status registers, "take further actions", clear
the inturrupt, restore W and status registers and return. Too much
overhead for a 5us pulse.

       Not too much overhead to see the rising edge, but definitely too
       much to also see the falling edge.

Go with the faster clock.

>Let's say I have an instruction which sets an ouptut high.
>How long does this take in us/ns terms?
Electricity and Light travel at about 1 foot in 1 nanosecond.
At 4Mhz it seems to me that the rise time is insignificant. If the pin
is connected to a very long wire, the capacitance of the transmission line
and the rise times can be a problem.

>What is the minimal input pulse duration I can monitor on a 20 mhz
>version? So that when the input is high an action is taken and when
>it becomes low again some other action is taken.
(my answer missed the mark, so I omitted it. Here's Andy's)

       I may be misunderstanding the guy's question, but it sounds to
       me as though he wants to do one thing on the leading edge, then
       another on the falling edge.  You may want to suggest something like
       this:

       wait4hi btfss   portb,0         ;wait for rising edge.
               goto    wait4hi         ;

       ; signal is high.

               ....                    ;do something.  this code must
               ....                    ;execute in fewer than 21 cycles.

       wait4lo btfsc   portb,0         ;wait for falling edge.
               goto    wait4lo         ;

       ;signal is low.

               ....                    ;do something else.  because of the
               ....                    ;GOTO, below, THIS code must execute
               ....                    ;in fewer than 19 cycles (if the pulse
               ....                    ;will only be low for 5 us -- if it'll
               ....                    ;be low longer, this code can take longe
r).

               goto    wait4hi         ;loop back and do the whole silly thing
again.

mjps_

1995\08\31@155057 by Kenny Baby

flavicon
picon face
how long between each 5uS pulseI've seen things you people wouldn't believe.
Attack ships on fire off the sholder of Orion.
I watched C-beams glitter in the darkness at Tan Hauser Gate.
All those moments will be lost in time,
like tears in rain.
Time to die.

Remember now, watch out for the Fairies......!


'Some I/O timimg questions...'
1995\09\01@051717 by Bill Cornutt
flavicon
face
----------

5us is a long time if you're waiting on the corner for
the light to change.

Bill C.

More... (looser matching)
- Last day of these posts
- In 1995 , 1996 only
- Today
- New search...