Menu

Interrupt on PIC12F675

sfyris
2015-12-01
2015-12-05
  • sfyris

    sfyris - 2015-12-01

    After proper port and variable inits, I use this code where it is supposed that if something changed on the pins setup for input the variable RXON have to be 1 thus ending the Do While loop. But....sadly this never hapens. Any ideas?

    ;Interrupt Handlers
    On Interrupt GPIOChange Call receiverON

    RXON = 0

    Do while RXON = 0
    repeat 5
    PulseOut GLOWALARM, 50 ms
    Wait 50 ms
    end repeat
    Loop

    Sub receiverON
    RXON = 1
    End Sub

     
    • kent_twt4

      kent_twt4 - 2015-12-01

      It is a little more complicated than that.

      Need to setup which pin is to be used by the GPIO change interrupt (IOC register). Choose weak pullup for pin (WPU register) or external pullup (MCLR pin) for input pin button/switch. Some of the older midrange devices have no way of knowing which change has occurred (i.e. positive to negative going or vice-versa), so discard whichever pulse you wish not to use. Also the button/switch must be debounced.

      Here is an example of a 12f683 with all the foregoing parameters accounted for. An external resistor pullup was used on the MCLR in this instance, and therefore a positive to negative event is tested in the debounce routine, while rejecting the negative to positive event.

      https://sourceforge.net/p/gcbasic/discussion/579126/thread/4e3de6de/#8d00

       
      ❤️
      1
  • Anobium

    Anobium - 2015-12-01

    Also, if you look in the demo folder of your installation you will find interrupt demo's. A series of demos show how for a 'Interrupt Switch Counter'.

     
  • sfyris

    sfyris - 2015-12-01

    Thank you guys. Kent the pin has no buttons but it is driven with pulses and thus there is no debounce need. With a simple code it is reading the pulses well, but when it goes to interrupt it seems not working. Anobium I will take a look at the demos, but Is it the same thing reading buttons or pulses?. And I have one more question. When executing the interrupt routine, the pin caused the interrupt remains in its state when the pulse goes low or it follows the state of the pulse? Thanks again.

     

    Last edit: sfyris 2015-12-01
  • Anobium

    Anobium - 2015-12-01

    Post again if you cannot figure it out.

     
  • sfyris

    sfyris - 2015-12-01

    Yeah guys thats great!!! Just implemented the Kents IOC3 solution and now I jump arround in my room full of enjoyment. It works guys! Kent very very thanks man!

     

    Last edit: sfyris 2015-12-01
  • kent_twt4

    kent_twt4 - 2015-12-01

    Heh, heh, easy does it, glad to be of help. Hope GCB, and it's knowledge base, proves useful to you in your future projects.

     
    👍
    1

Log in to post a comment.