View Full Version : The inner workings of PULSIN?
01-27-2007, 08:33 AM
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.
01-27-2007, 11:00 AM
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 [counting like] and terminates with a transition from HI to LO.
Update -- This when State is = 1.
01-27-2007, 03:07 PM
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.
01-28-2007, 06:21 AM
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?
01-28-2007, 09:56 AM
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.