PDA

View Full Version : please help with Polling with 2p



basicstampede
01-24-2007, 12:19 AM
I have several specific questions. So I'll get right to them.

1. Pg. 326 of BS Manual 2.2, Table 5.74. I believe the chart is wrong.
If inputs are 0 and 0, the outputs should be 1 and 1
If inputs are 1 and 1, the outputs should be 0 and 0.
Is my understanding correct?

2. Pg. 323. Table 5.77. Location 127. It says "Bits 0-3, Active program slot #, Bits 4-7, program slot for READ and WRITE operations."
Wouldn't bits 4-7 always be same as bits 0 to 3?
How can those two nibbles be different?
Please illustrate via short example.

3. Pg. 328. It shows a "clever trick with pollout".
Second last statement of program is
POLLMODE 10

Why is this pollmode 10 statement necessary?

More specifically,
a. If this mode is similar to mode 2 (except for latch), then polling should never have been disabled at any time. Thus I don't understand why this needs to be activated again.

b. Is this needed to reset the latch? But the pollmode chart on pg. 320 does not mention that mode 10 resets the latched poll conditions.

4. How does one put a program into a different slot for BS2p (other than default slot 0)?
What page is that mentioned in the manual?

Thank you.

Tracy Allen
01-24-2007, 01:35 AM
1) I think your're right about the chart. Both outputs will be HIGH when either input is LOW.

2)
RUN 5 ' program in bank 5 will run

' here is the program in bank 5
GET 127, b0
DEBUG HEX2 b0, "R/W RUN" ' $55 is in spram 127
STORE 7 ' change bank for read/write
GET 127, b0
DEBUG HEX2 b0, "R/W RUN" '$75 is in spram 127

this is very useful for storing parameters and data anywhere in the Stamp eeprom, accessible from any RUN bank.

3) pollmode 10 is a latching mode. If there is a brief event on the POLLIN pin, the POLLOUT will latch it, so the program will be able to detect the occurance of a relatively narrow pulse. In POLLMODE 2, the output pin simply follows the input pin(s), not latch. You can also examine the pin state bits in the SPRAM locations 128-121 to do much the much same thing, with more flexibility if you have multiple input sources to detect.

redoing pollmode resets the latch. Right, it does not seem to be explicitly documented.

I have a tutorial on some of the POLLing capabilities at this URL:
www.emesys.com/BS2poll.htm (http://www.emesys.com/BS2poll.htm)

4) Look up the $STAMP directive. In slot 0, you will have that in a line that looks something like this:
' {$STAMP BS2p, myProg1.bsp, myProg2.bsp} can be up to myProg7.bsp
' {$PBASIC 2.5}

You write your program, myProg1.bsp ,and so on, and when you open the slot zero program, it sees the directive and will link up with the other programs. All of them will open at once in your editor and when youu run them they will all be downloaded to your Stamp. Also, when you press CTRL-M to look at the memory map, it checks for all the programs in the link. You will probably want to keep each set of project files together in their own folder or directory.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)

basicstampede
01-24-2007, 02:17 AM
Thanks Tracy,

But I don't see that directive. This is an example of my entire program.

How can I get that directive (so I can modify it)?

' {$STAMP BS2p}
' {$PBASIC 2.5}

alarm VAR OUT0
idx VAR Byte
pgmslot VAR Byte

setup:
POLLOUT 0, 1
POLLIN 0, 0
POLLMODE 10

Work:
FOR idx = 1 TO 25
GET 127, pgmslot
DEBUG "running program # ", DEC pgmslot.LOWNIB, " "
DEBUG "read/write slot # ", DEC pgmslot.HIGHNIB, CR
NEXT
IF (alarm = 0) THEN Work

Respond:
DEBUG CR, "The alarm was tripped", CR
PAUSE 1000
POLLMODE 10

GOTO Work

basicstampede
01-24-2007, 03:42 AM
So how does one put a program in another slot? I don't see it in the manual anywhere.

Thanks in advance.

Tracy Allen
01-24-2007, 04:55 AM
Read the manual v2.2 on "advanced compilation techniques", which begins on page 68 in the printed version or on page 72 in the on screen pdf version. Also look at the discussion around the RUN command.

You write the program that will go into the other slot, and give it a file name. Then you enter that name in the list of files that follows the $STAMP directive in the slot zero program. That is what links the files together into one project. Subsequently when you open the slot 0 program, all of the associated project files will open into a set of tabs in the editor. Does that make sense? You can have individual slot files that are associated with several different projects.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com (http://www.emesystems.com)