Shop OBEX P1 Docs P2 Docs Learn Events
Is it normal for interrupt initialization to trigger the ISR? RESOLVED- Thanks — Parallax Forums

Is it normal for interrupt initialization to trigger the ISR? RESOLVED- Thanks

CarlCCarlC Posts: 29
edited 2006-02-01 06:18 in General Discussion
While stepping through in debug mode, I find that changing the mode register to set WKPEND causes a triggering of my ISR in my initialization segment.

mov W,#$19

I even tried initially biasing my pins high (pulled up pins not connected to ground) in case seeing a low pin right after activating interrupts was causing a problem without effect.

In normal operation, my ISR uses the state of the WKPEND register (swapped through W) to determine the cause of an interrupt. I have problems when the ISR is called outside of the normal means. I guess I could put in a work around by setting a flag in the main body so the ISR is skipped through if the main hasn't been reached yet, but I'm wondering if there's a proper way to avoid running the ISR after making interrupts available during initialization.

Post Edited (CarlC) : 2/1/2006 6:19:15 AM GMT

Comments

  • mojorizingmojorizing Posts: 249
    edited 2006-02-01 05:59
    Hi Carl,
    In your intialization code you need to clear the WKPEND register before you enable the wake ups following a sequence such as;


    ;------------------------ INITIALIZATION ROUTINE -----------------------
    
    Initialize
            ;Edge Detection Configuration
    
        [b]    mov     W,#$19            ;Allow Wake-Up Pending access
            mov     M,W
            mov    !rb,#%00000000        ;Clear Wake-Up Pending (WKPND_B)[/b]
    
            mov    W,#$1A            ;Allow Wake-Up Edge configuration
            mov    M,W
            mov    !rb,#%11111111        ;Set port B bits 0-7 to falling edge
    
            mov    W,#$1B            ;Allow Wake-Up Enable configuration
            mov    M,W
            mov    !rb,#%11110000        ;Set port B bits 4-7 to normal, bits 0-3 to Wake-Up Enable
    
            mov    W,#$1E            ;disAllow Pull-up configuration
            mov    M,W                
            mov    !rb,#%11111111        ;Port B bits 0-7 without pullups
    
            mov    W,#$1F            ;Allow Direction configuration
            mov    M,W
            mov    !rb,#%11111111        ;Set port B bits 0-7 to input direction
    
            mov    W,#$19            ;Allow Wake-Up Pending access
            mov    M,W
            mov    !rb,#%00000000        ;Clear Wake-Up Pending (WKPND_B)
    
    



    does this answer your question?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Bad spellers of the world untie!
  • CarlCCarlC Posts: 29
    edited 2006-02-01 06:18
    Thanks mojo,

    that was exactly my problem. I forgot to clear all the interrupt flags before enabling the interrupts.
Sign In or Register to comment.