Strange happenings PBP and 12F683


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    973


    Did you find this post helpful? Yes | No

    Default

    Wouldn't this work? You have it in Erase already.
    Code:
    MAIN:   IF TRIGR=1 THEN     
                PAUSE 10
                GOSUB PLAY
                while TRIGR=1:wend                   'block till the key is released
                ENDIF
            IF CONTROL=0 THEN   
                PAUSE 10
                GOSUB RECORD
                while CONTROL=0:wend                   'block till the key is released
                ENDIF
            IF ACTIVE=0 THEN    
                PAUSE 10
                GOSUB MANUAL
                while ACTIVE=0:wend                   'block till the key is released
                ENDIF
            GOTO MAIN
    Last edited by Jerson; - 7th February 2009 at 13:32. Reason: formatting with [code]

  2. #2
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Lightbulb I think I solved it . . .

    Thanks, Jerson and Alain. I'll keep both of those ideas in mind.

    What I ended up doing that worked: Inspired by part of what Charles said, I check the condition of the switch in the interrupt handler and set a flag if the switch is closed. Then I check the flag during the MAIN loop. If it and another flag are both set, it kicks to a subroutine.

    But nothing yet explains why I couldn't dependably perform simple conditionals on that input in the MAIN loop. It's a mystery.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  3. #3
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Still an occasional problem

    I've attached the most recent version.

    Once in a while, for no apparent reason, or after a RECORD cycle, when TRIGR is activated (with MFLAG set to 0), the program appears to jump directly to NOTCLR.

    How long does the interrupt service in TIMER take? I'm sure it's a matter of microseconds, but how many using DT_INTS-14?

    Is it possible that, if TRIGR goes high during the very short time while the interrupt is being serviced, the routine is going to skip going to PLAY and instead will go to NOTCLR?

    And, if so, what is the best solution?
    Attached Images Attached Images
    Last edited by RussMartin; - 9th February 2009 at 22:56.
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

  4. #4
    Join Date
    Aug 2006
    Location
    Omaha, Nebraska USA
    Posts
    263


    Did you find this post helpful? Yes | No

    Default Still a glitch . . .

    The problem still occurs and I seem unable to predict when.

    Sometimes, execution seems to go directly to NOTCLR.

    I attached the full program (slightly earlier version) to my prior post.

    The only changes have been in MAIN, PLAY, NOTCLR, and TIMER, shown below.

    Can someone point out where I'm going wrong?

    Code:
    MAIN:   IF TRIGR=1 THEN                 ' Selects "playback"
                PAUSE 9                     ' Pause ~10 milliseconds for debounce
                GOSUB PLAY
                ENDIF                                       
            IF MFLAG=0 AND KEYCHK=1 THEN    ' If mode selection prohibits continuous
                GOSUB NOTCLR                '  switch closure, Await switch opening
                ENDIF            
            IF CONTROL=0 THEN               ' Selects "record"
                PAUSE 9                     ' Pause ~10 milliseconds for debounce
                GOSUB RECORD
                ENDIF
            IF ACTIVE=0 THEN                ' Manual override when idle       
                PAUSE 9                     ' Pause ~10 milliseconds for debounce
                GOSUB MANUAL
                ENDIF
            GOTO MAIN
    
    -----
    
    PLAY:   CYCLE=0 : FLASH=8 : FLASH2=5    ' Status LED indicates "playback"
            CLOCK=0                         ' Reset the clock for read
    PLOOP:  IF FRAME=248 THEN GOTO PLEXIT   ' If top of data is reached, exit
            READ FRAME,STATE                ' Read the frame from data memory
            IF STATE=$FF THEN GOTO PLEXIT   ' If end-of-data marker is read, exit
            IF STATE=1 THEN                 ' For state 1,
                RELAY=1 : ALED=1            '  turn the relay and activity LED on,
                ENDIF                       '  otherwise,
            IF STATE=0 THEN                 '  for state 0,
                RELAY=0 : ALED=0            '  turn the relay and activity LED off
                ENDIF 
            GOTO PLOOP                      ' Repeat until an exit condition occurs
    PLEXIT: CYCLE=0 : FLASH=16 : FLASH2=9   ' Status LED indicates "idle"
            RETURN
    
    -----
    
    NOTCLR: CYCLE=0 : FLASH=2 : FLASH2=2    ' Status LED indicates "attention!"
            WHILE KEYCHK=1 OR TRIGR=1       ' While the trigger input is active,
                WEND                        '  further execution is prevented
            PAUSE 9                         ' Pause ~10 milliseconds
            CYCLE=0 : FLASH=16 : FLASH2=9   ' Return to the idle state
            RETURN
    For some reason, this won't allow me to include TIMER in the above without dropping statements, so I'll do that one this messy way. Note: FRAME above is the low byte of ADDRS below.

    TIMER: CYCLE=CYCLE+1
    IF CYCLE<FLASH2 THEN
    SLED=1
    ELSE
    SLED=0
    ENDIF
    IF CYCLE>FLASH THEN CYCLE=0
    ADDRS=CLOCK>>1
    CLOCK=CLOCK+1
    IF TRIGR=1 THEN
    KEYCHK=1
    ELSE
    KEYCHK=0
    ENDIF
    @ INT_RETURN
    Last edited by RussMartin; - 10th February 2009 at 19:32. Reason: TIMER text corrupted when put within code tags
    Russ
    N0EVC, xWB6ONT, xWN6ONT

    "Easy to use" is easy to say.

Similar Threads

  1. How to use LM34 to full range with PBP
    By polymer52 in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 9th January 2010, 14:43
  2. New to PBP
    By GoldStar in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th May 2009, 17:24
  3. New project help rapidfire on 12f683
    By thm ov3rkill in forum mel PIC BASIC Pro
    Replies: 27
    Last Post: - 27th December 2008, 20:59
  4. 12F683 HPWM Usage
    By MARAD75 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2007, 03:16
  5. upgrade to PBP 2.46 and using 12F683
    By peterdeco1 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd March 2005, 08:13

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts