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

how to count rising edges of a pulse in ADUC842

Hello,

I am using ADUC842.

Continuous pulse is being fed at port P2.6

I need to calculate rising edges of the pulse for 10ms time interval..

how should i proceed?

pls help.

Regards
Mayuri

Parents
  • counter in 8051 takes high to low transition...

    ...

    i just want to count high to low transitions....

    So, the timer counts the falling edge, and you want to count the falling edge. But you do not think the timer is the way to go?

    Whatever. You can use the INTx pin to count. Another solution would be pulling:

      pulse_counter += ((port_prev ^ port_now) & port_prev)?1:0;
    

    If any of the pins on the port has a falling edge, pulse_counter is incremented. You can mask it to just count certain pins (or a single pin).

      pulse_counter += ((port_prev ^ port_now) & port_now)?1:0;
    

    counts the rising edge, in case you want.

Reply
  • counter in 8051 takes high to low transition...

    ...

    i just want to count high to low transitions....

    So, the timer counts the falling edge, and you want to count the falling edge. But you do not think the timer is the way to go?

    Whatever. You can use the INTx pin to count. Another solution would be pulling:

      pulse_counter += ((port_prev ^ port_now) & port_prev)?1:0;
    

    If any of the pins on the port has a falling edge, pulse_counter is incremented. You can mask it to just count certain pins (or a single pin).

      pulse_counter += ((port_prev ^ port_now) & port_now)?1:0;
    

    counts the rising edge, in case you want.

Children
No data