Menu

interrupt configuration for PIC16F1709

Help
JANIS
2023-11-13
2023-11-13
  • JANIS

    JANIS - 2023-11-13

    Hello everyone, and first of all, I really wish everyone who has not donated to donate, so that GCB can exist and develop.
    I want to create an external (in my case port RA3 ) interrupt in my program that calls some subroutine. I don't understand, is only the subroutine created by PPS tools enough, or is configuration also required? I tried only a subprogram made with PPS tools, it didn't work for me. I attached only the part of my program that I want to use for interrupt, to understand where my mistake is.
    My attached part of the program has both what PPS tools created and the interrupt configuration I think might work. Could someone suggest and fix it?

     
  • Anobium

    Anobium - 2023-11-13

    Great question.

    Your block of code ( shown below ) - not all of it is required.

            INTF=0 '' bit 1 INTF: INT External Interrupt Flag bit
            '1 = The INT external interrupt occurred
            '0 = The INT external interrupt did not occur
            INTE=1 '' bit 4 INTE: INT External Interrupt Enable bit
            '1 = Enables the INT external interrupt
            '0 = Disables the INT external interrupt
            GIE=1 ''bit 7 GIE: Global Interrupt Enable bit
            ''1 = Enables all active interrupts
            ''0 = Disables all interrupts
            INTEDG=1 ' INTEDG: Interrupt Edge Select bit 6 ;; OPTION_REG: OPTION REGISTER_page_245
            ''1 = Interrupt on rising edge of INT pin
            ''0 = Interrupt on falling edge of INT pin
    

    I will explain.

    INTF=0 is clearing an event bit. This is completed/cleared automatically by GCBASIC within the interrupt handler.

    INTE=1 is setting the specific event. This is set ( = 1) automatically by GCBASIC when you specific the on interrupt ExtInt0 ... .

    GIE=1 is setting the Global event handler. This is set ( = 1) automatically by GCBASIC when you specific ANY on interrupt ... .

    To see the bits automatically set check the "Interrupts Tab" in PICINFO.

    INTEDG=1 is not set by the compiler. So, if you want to change the edge then use this bit.

    PICINFO/Interrupts shows the bit managed by GCBASIC.


    So, you only need

    INTEDG=1 ' INTEDG: Interrupt Edge Select bit 6 ;; OPTION_REG: OPTION REGISTER_page_245
    ''1 = Interrupt on rising edge of INT pin
    ''0 = Interrupt on falling edge of INT pin
    

    Not for Janis but for everyone who has not donated.

    Donate here

    Please donate to the operational costs of GCBASIC for the coming year - Thank you.

    paypal.me/gcbasic

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.