Hi Vasile,

I have used it in the past but sometimes it did not detect interrupt and once 
you miss one interrupt it will never be detected. Maybe because I accessed the 
port in the wrong way.

The datasheet states that you should AND the data with the port in order not to 
miss an interrupt. As said, if you miss an interrupt by not accessing the port 
in the right way it will never generate an interrupt anymore.

Hope this helps.

Kind regards,

Rob


________________________________
Van: [email protected] <[email protected]> namens vsurducan 
<[email protected]>
Verzonden: donderdag 30 september 2021 17:51
Aan: [email protected] <[email protected]>
Onderwerp: [jallib] interrupt on change issue


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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/CAM%2Bj4qvv6k0rGBYftBOhsT7HR4wJe8GrM8_vEGUPiTk3MVa%2B8Q%40mail.gmail.com<https://groups.google.com/d/msgid/jallib/CAM%2Bj4qvv6k0rGBYftBOhsT7HR4wJe8GrM8_vEGUPiTk3MVa%2B8Q%40mail.gmail.com?utm_medium=email&utm_source=footer>.

-- 
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/VI1PR07MB625693D87AF06DE7D02B8AB0E6AA9%40VI1PR07MB6256.eurprd07.prod.outlook.com.

Reply via email to