Shop OBEX P1 Docs P2 Docs Learn Events
Why won't this quit? — Parallax Forums

Why won't this quit?

edited 2005-12-02 19:41 in BASIC Stamp
aux_pin0 VAR Bit
AUXIO
  POLLIN 0,0
  POLLOUT 15,1
MAINIO
  POLLOUT 15,1
POLLMODE 4
AUXIO
aux_pin0 = IN0
DO
  DEBUG "I am still waiting" , TAB , DEC aux_pin0, CR
  AUXIO
  aux_pin0 = IN0
  MAINIO
  IF   aux_pin0 = 0 THEN
    MAINIO
    POLLMODE 7
    AUXIO
    POLLMODE 7
    aux_pin0=0
    EXIT
    STOP
  ENDIF
LOOP

MAINIO
POLLMODE 7
AUXIO
POLLMODE 7
IOTERM 0
OUTS = %0000000000000000 'All logic low
IOTERM 1
OUTS = %0000000000000000 'All logic low
DEBUG "I'm finished"

This is pretty frustrating. Is it because I am using polling? The program simply pauses if I ground the input pin. I thought it was supposed to stop.





▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Freeing smoke from wire and IC captivity since 1972

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-11-30 22:45
    Smoke -

    Fiirst, you DO ... LOOP has no exit condition supplied, so it becomes an infinte loop. Thus, you must exit by some means from within that code segment. The ONLY exixt feasible, ONLY occurs:

    IF aux_pin0 = 0 THEN

    Now, aux_pin0 = In0 subordinate to an AUXIO, thus it's pin port 0 of the auxilliary set, which maps to physical pin 21. Is there anything attached to physical pin 21? If so, does the state of pin 21 ever change?


    Regards,

    Bruce Bates
  • edited 2005-11-30 23:19
    The physical pin 24 is switched through a resistor either to DC+5v or to ground. when it goes to ground, the if statement should be executed. Within this conditional statement, I have put in an EXIT command which should drop the program out of the loop and effectively ending the program.

    When PP24 goes low, the Stamp seems to go into a wait and see kind of operation and the lines after the LOOP statement never get executed. When I set the physical pin 24 to high again, the program restarts.

    Is this behavior due to the use of the poll commands? What else could cause it? When I write a similiar program w/o polling, the Stamp works like expected.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Freeing smoke from wire and IC captivity since 1972
  • edited 2005-12-02 14:39
    Is my assumption in my last request correct?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Freeing smoke from wire and IC captivity since 1972
  • edited 2005-12-02 15:40
    Is this behavior due to the use of the poll commands? What else could cause it? When I write a similiar program w/o polling, the Stamp works like expected.

    Anyone please respond.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Freeing smoke from wire and IC captivity since 1972
  • edited 2005-12-02 16:41
    I think I am getting it.

    In the Basic Stamp Manual, it makes refernce running continuously on page 308 and going back to the start of the program.

    So it was because of the pollmode that made it continuosly run. I'll now work on how to make it run as expected.



    Always looking for feedback...

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Freeing smoke from wire and IC captivity since 1972
  • edited 2005-12-02 17:08
    The culprit has been found... It is indeed the pollmode commands.
    'discovery0.bsp
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    aux_pin0 VAR Bit
    MAINIO
    aux_pin0 = IN0
    DEBUG "I'm preparing to start..." , TAB, DEC aux_pin0, CR
    
    MAINIO
      POLLIN 0,1
      POLLOUT 15,1
    AUXIO
      POLLOUT 15,1
    POLLMODE 4
     
    DEBUG "I'm starting...", TAB, DEC aux_pin0, CR
    DO WHILE (aux_pin0= 1)
      MAINIO
        aux_pin0 = IN0
      DEBUG "I'm still waiting...",TAB, DEC aux_pin0, CR
      IF aux_pin0=0 THEN
        POLLMODE 0
        EXIT
      ENDIF
    LOOP
     
    IOTERM 0
    OUTS = %0000000000000000 'All logic low
    IOTERM 1
    OUTS = %0000000000000000 'All logic low
    DEBUG "I'm finished"
    
    

    I simply needed to change the pollmode inside the loop to pollmode 0. I had been trying to keep the pollmodes the same in the first section and in the loop.

    Anyway. Thanks for the help. I'm sure I'll post some more.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Freeing smoke from wire and IC captivity since 1972
  • John R.John R. Posts: 1,376
    edited 2005-12-02 19:27
    Smoke;

    It was interesting to see you work your way throught the problem, even if much of the conversation was between yourself.

    Thanks for taking the time to post your solution.



    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    John R.

    8 + 8 = 10
  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-12-02 19:41
    Yes, Im impressed with your self determination on figuring it out, refreshing change to the "demand an answer" approach. Ill be happy to help you with your questions, I just didnt have an answer for this one.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ·1+1=10
Sign In or Register to comment.