Shop OBEX P1 Docs P2 Docs Learn Events
The inner workings of PULSIN? — Parallax Forums

The inner workings of PULSIN?

basicstampedebasicstampede Posts: 214
edited 2007-01-28 02:56 in BASIC Stamp
When you program PULSIN,·what exactly does the BS do?
I'm asking about the inner workings of the PIC micro. (not how it works at high level).
Does it use Capture and Compare module?·
If anyone has some good understanding of what exactly the PIC on BS does, I would appreciate it.

·

Comments

  • PJAllenPJAllen Banned Posts: 5,065
    edited 2007-01-27 04:00
    It waits for a transition from LO to HI (so if you·come in·during the middle of·some pulse, then·another will have to come along before PULSIN will begin working),·where it starts timing [noparse][[/noparse]counting like] and terminates with a transition from HI to LO.

    Update -- This when State is = 1.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2007-01-27 08:07
    Gents -

    PULSIN will also timeout when the user specified maximum time is exceeded. There is no need for capture-compare, as far as I can see. Two timed loops would be sufficient.

    Regards,

    Bruce Bates

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    <!--StartFragment -->
  • basicstampedebasicstampede Posts: 214
    edited 2007-01-27 23:21
    I was wondering if the PULSIN makes use of the CCP module inside the PIC.
    I'm assuming that it starts by putting 0 to a 16 bit timer (which is free-running)·when it sees a 0 to 1 transition (or 1 to 0 transition).· Then, when it sees 1 to 0 (or 0 to 1) transition, it stops the 16 bit internal timer.· Then, knowing the internal frequency of PIC, it can calculate the duration.

    Can someone from Parallax say with authority if above scenario is close?

    ·
  • Tracy AllenTracy Allen Posts: 6,662
    edited 2007-01-28 02:56
    The Stamp II was originally designed around the PIC15C5x, which does not have a CCP module. It has only the single 8 bit timer module. I don't think the Stamp uses that timer either, but I can't say so with authority. I believe or guess that the timing is all done by counting clock cycles in the main tread of code. The independent timer would not be necessary, because the Stamp is single tasking.

    The Stamp certainly does not use the single external timer input pin (RTCC). Every single pin of the Stamp can do PULSIN. The more recent Stamps are based on the SX28 or SX48 chip (Parallax aka Ubicom aka Scenix), but the code for those was kept backward compatible to a large degree with the original Stamp II.

    The PIC or SX prescaler is in the Stamp assigned to the Watchdog function, which is used for timing the NAP and SLEEP commands.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Tracy Allen
    www.emesystems.com
Sign In or Register to comment.