This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

measuring time between two pulses

Hi all,

first time posting here. Ive got a most simple goal, measure the time between a bit going low and a second bit going low.

I can only use P1, so Im assuming

loop
while p1.0 = 1

p1.0 = 0?

start a timer, could count up to 10 seconds

now loop waiting for p1.1 = 0

p1.1 = 0?

stop the timer, calculate how many seconds

display the result. Im using an HTE SDK8032 board, there is a monitor routine to display text, it interfaces to hyperterminal. if I can just get that "seconds" value, I could convert as needed and print it.

simple. what happens? nothing.

now Im trying to use C and a 32bit long as the timer int, maybe decrement, jump not zero or ?

but figuring out time from the 11.05 Mc crystal (used for baud rates) is just not making sense right now, any help is appreciated.

Parents
  • thanks!

    reading it again..nothing happens?? I meant the program doesnt work.

    it only took several hours to figure out how to make hyperterm work.

    Im having trouble with 2 things: interrupt routine, and calculating the timer.

    the interrupt routine, a jmp at the 000Bh to my routine, never happens.

    now what Im trying to do is use a 32bit variable to count timer ticks; problem? my Keil c51 eval compiler chokes when I try anything with my variables

    long x = 0; //this is ok
    long y;

    int main void {

    x = 1; //chokes, *** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
    EXCEPTION 0021H: PATH OR FILE NOT FOUND
    FILE: C:\KEIL\C51\LIB\C51FPS.LIB

    until now, Ive been coding this x51 project in assembly/machine. presently microsoft visual basic.net is easier to use, but it wont translate (will it?)

    Ive got Intel AppBuilder to help with constructing asm, but am new to compiling C for the x51 target so I could be overlooking something simple.

    thanks

Reply
  • thanks!

    reading it again..nothing happens?? I meant the program doesnt work.

    it only took several hours to figure out how to make hyperterm work.

    Im having trouble with 2 things: interrupt routine, and calculating the timer.

    the interrupt routine, a jmp at the 000Bh to my routine, never happens.

    now what Im trying to do is use a 32bit variable to count timer ticks; problem? my Keil c51 eval compiler chokes when I try anything with my variables

    long x = 0; //this is ok
    long y;

    int main void {

    x = 1; //chokes, *** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
    EXCEPTION 0021H: PATH OR FILE NOT FOUND
    FILE: C:\KEIL\C51\LIB\C51FPS.LIB

    until now, Ive been coding this x51 project in assembly/machine. presently microsoft visual basic.net is easier to use, but it wont translate (will it?)

    Ive got Intel AppBuilder to help with constructing asm, but am new to compiling C for the x51 target so I could be overlooking something simple.

    thanks

Children
  • The compiler is tryin to link to the floating pint library, which is not supplied in the evaluation version. I don't see why this is happening, as you only appear to be using integer variables.

    It is easier to get code working without interrupts to start with. I would suggest you try just outputting a message when signal 1 goes low, then a different message when signal 2 goes low. When this is working, then try to time the period between the two transitions.


    When programming embedded systems, it is usual for your main procedure to be declared as

    void main(void)
    , as it does not accept any arguments, and should never exit.

    Forget about MS VBNET. You can only use tools expressly designed for a microcontroller.

  • "I meant the program doesnt work."

    That could still mean anything from "the program does nothing at all." to "the program doesn't quite do what I expected"

    *** FATAL ERROR L210: I/O ERROR ON INPUT FILE:
    Note that this is a Linker error - not a compiler error.

    Have you used anything anywhere in your source code that would require floating point? NB: that could include printf!