Hi Rob, that was a thought I had, but I didn't check what the compiler does if there's no interrupt service routine. Would it be smart to always waste five program words just to be sure not to accidentally restart the program? I.e., always put a RETFIE at position 0x0004 when there's no pragma interrupt?
Greets, Kiste Am Freitag, 1. Oktober 2021, 10:56:08 MESZ hat Rob Hamerling <[email protected]> Folgendes geschrieben: I think the cause of your problem is that you set INTCON_GIE = high, but have no ISR (Interrupt Service Routine). An interrupt (hardware jump to the interrupt vector at address 0x0004) becomes practically a restart of the program. Possible solutions: INTCON_GIE = low, or use an ISR to handle the IOC interrupt (but no delay in an ISR!) Regards, Rob. On 30/09/2021 17.51, vsurducan wrote: > According to the PIC12F1572 datasheet, rising edge IOC can be detected by enabling edge detection on input pins (IOCAPx or IOCANx) and reading the IOC flag (IOCAFx) or the INTCON_IOCIF, then clearing the flag for the next IOC detection. Seems it does not work. Any ideas? Thx. include 12lf1572 -- target PICmicro -- -- This program uses the internal oscillator at 4 MHz. pragma target clock 32_000_000 -- oscillator frequency -- pragma target OSC INTOSC_NOCLKOUT -- internal oscillator pragma target PLLEN DISABLED -- PLL off pragma target CLKOUTEN DISABLED -- no clock output pragma target WDT DISABLED -- watchdog pragma target BROWNOUT ENABLED -- brownout reset pragma target LVP DISABLED -- no low voltage programming pragma target MCLR INTERNAL -- internal reset -- -- OSCCON_SCS = 0 -- select primary oscillator OSCCON_IRCF = 0b1110 -- 8 MHz OSCCON_SPLLEN = ENABLED -- 4x PLL: 8 -> 32 MHz -- enable_digital_io() -- make all pins digital I/O include delay alias pin_RDY_IN is pin_A0 alias pin_RDY_IN_direction is pin_A0_direction pin_RDY_IN_direction = input alias pin_RDY_OUT is pin_A5 alias pin_RDY_OUT_direction is pin_A5_direction pin_RDY_OUT_direction = output pin_RDY_OUT = low OPTION_REG_WPUEN = 0 WPUA_WPUA0 = 0 ; pull-up disabled on RA0 -- main program -- ---------------------------------------------------------------------------- INTCON_GIE = high ; not necessary without interrupt routine INTCON_IOCIE = high ; enable interrupt on change, not necessary without interrupt routine IOCAP_IOCAP0 = high ; enable positive edge interrupt on change on RDY_IN forever loop ; if INTCON_IOCIF then if IOCAF_IOCAF0 then ; a positive edge interrupt on change on RDY_IN occured pin_RDY_OUT = high delay_1mS (20) pin_RDY_OUT = low IOCAF_IOCAF0 = low ; clear IOCAF0 flag ; INTCON_IOCIF = low else ; no interrupt occured pin_RDY_OUT = low end if end loop -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/CAM%2Bj4qvv6k0rGBYftBOhsT7HR4wJe8GrM8_vEGUPiTk3MVa%2B8Q%40mail.gmail.com. -- Rob Hamerling, Vianen, NL -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/dd13bf5c-9a69-5157-afa9-fa27d38ece98%40gmail.com . -- You received this message because you are subscribed to the Google Groups "jallib" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jallib/135907067.590815.1633102247578%40mail.yahoo.com.
