Shop OBEX P1 Docs P2 Docs Learn Events
Sx28ac external interrupts (port b) — Parallax Forums

Sx28ac external interrupts (port b)

ron@rs485.comron@rs485.com Posts: 1
edited 2007-08-06 03:14 in General Discussion
I am trying to enable an external interrupt on port pin B7 on an SX28AC processor. I have tried several combinations of instructions but cannot "prime" the input for operation. I only require one interrupt and do not need to parse the pending interrupts because there will only be one. Any help would be appreciated.

Thanks,

Ron Smith
ron@rs485.com
513-874-4796

Comments

  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-31 21:01
    Ron,

    This is not tested. It is just what I have in my head. I think you will want to do something like this:

    ‘ Set the Port B Edge Detection
        WKED_B = %1000_0000
    
        ' Set Interrupt Triggered Pin (B7)
        WKEN_B = %0111_1111            ' Enable Interrupt triggering on the selected pin.
    
        ' Enable Port B Interrupts
        WKPND_B = %0000_0000                ' Clear the Pending register to enable 
                                            '   interrupt triggering.
    


    You did not specify the edge detection you desired so you may need to change it from what I have shown. Also, be sure to clear WKPND_B every time in your ISR so that the next interrupt will be processed.

    - Sparks
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-07-31 21:04
    This file I included was a recent try at the same thing, to trigger the dwell time for an ignition coil. I had no problem with this code to get the Interrupt, But I didn't figure out how to reset the Pin in SX/B, so that the interrupt could happen over and over.

    There is Material on this subject in the SX-Key Manual and examples, but they are in Assembly.

    Bill
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-31 21:16
    I think that when you have an edge-triggered interrupt on one of the port B pins the associated bit of the WKPEN_B register is set to indicate which pin generated the interrupt. Once this pending bit is set, I think no further triggers for that pin occur until that pin’s bit in the WKPEN_B register is cleared again.

    - Sparks
  • BeanBean Posts: 8,129
    edited 2007-07-31 21:21
    Ron,
    You can just use:

    Sensor PIN RB.7 INPUT INTR_RISE

    This will setup the registers for you. All you need is the interrupt routine.

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Teacher: What is the difference between ignorance and apathy ?
    Student: I don't know and I don't care
    Teacher: Correct !
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Sparks-R-FunSparks-R-Fun Posts: 388
    edited 2007-07-31 21:29
    Wow, Bean…

    Way to take all the complication out of it! lol.gif

    I like learning from other people’s posts. smile.gif

    - Sparks
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-08-05 05:41
    I am trying to find out how to clear the bit after each interrupt. So the interrupt will repeat itself,·over and over again. I have tried the SX-Key manual example with no success and niether has any SASM or SX/B attempt.
  • Guenther DaubachGuenther Daubach Posts: 1,321
    edited 2007-08-05 08:40
    In Assembly:

    mode $09
    clr w
    mov !RB, w

    With the MODE register set to $09, the mov !RB, w actually swaps the contents of w and the wake-up pending register, so after this instruction, all bits in the register are cleared, and in w, the bit is set which caused the recent. It is important to execute this sequence somewhere inside the interrupt routine before returning. If you don't do it, the interrupt will be immediately re-triggered again, no matter if a new edge at the rb port was detected or not.

    It is also a good idea to execute this code once before the WKPEN_B register is configured, just to make sure that no "glitches" have set bits in the WKPND_B register.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Greetings from Germany,

    G
  • BeanBean Posts: 8,129
    edited 2007-08-05 13:18
    In SX/B just use:

    WKPND_B = 0

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Teacher: What is the difference between ignorance and apathy ?
    Student: I don't know and I don't care
    Teacher: Correct !
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • Capt. QuirkCapt. Quirk Posts: 872
    edited 2007-08-06 03:14
    Thanks Gentleman,

    I thought I needed to clear out "WKED_B" or mode $0a directly and that $09 was only worked once and only in sleep. Now I see there is a process that starts with $09 and is fine tuned with WKED_B & WKEN_B, thats correct right?.
    It is also a good idea to execute this code once before the WKPEN_B register is configured, just to make sure that no "glitches" have set bits in the WKPND_B register.
    I just need to start the program,·while the Hall Sensor that creates the·interrupt·isn't aligned to the magnet, right? or would it be better not to use the simplified SX/B version of declaring it at the PIN statement area and initialize it @ Start: portion of the program in a short SASM statement?

    Thanks again

    Sincerely

    Bill M.

    Post Edited (Capt. Quirk) : 8/6/2007 3:21:18 AM GMT
Sign In or Register to comment.