Shop OBEX P1 Docs P2 Docs Learn Events
Pulse generator issue — Parallax Forums

Pulse generator issue

bmentinkbmentink Posts: 107
edited 2010-03-05 20:28 in Propeller 1
Hi All,

In the following code I have a problem.

The pulse works fine(I get my pre-pulse delay, then the pulse delay and the output is high during the pulse), but after that the cnt overflows and the output goes back high, then low again on the next overflow.
Can someone look at the code and let me know what I should do to fix this .. thanks.


PUB Pulse(Pin, DelayuS, PulseuS)
{{Pulse Pin high for PulseuS after delay of DelayuS.}}

  ctra[noparse][[/noparse]30..26] := %00100                     ' Configure Counter A to NCO
  ctra[noparse][[/noparse]5..0] := Pin                             
  frqa := 1
  dira[noparse][[/noparse]Pin]~~                                ' Make output
  
  if DelayuS > 0
      waitcnt((80_000_000/1_000_000 * DelayuS) + cnt) ' Wait for Delay uS

  phsa := -(clkfreq / 1_000_000 * PulseuS)             ' Send the pulse



Post Edited (bmentink) : 3/5/2010 6:23:54 AM GMT

Comments

  • MagIO2MagIO2 Posts: 2,243
    edited 2010-03-05 07:11
    Of course, because you don't switch off the counter. So it will continue to count and generate a signal.

    If you want a single shoot pulse, you have to wait until the pulse is finished and switch off the counter.
  • bmentinkbmentink Posts: 107
    edited 2010-03-05 20:28
    True .. thanks.
Sign In or Register to comment.