Hi Michel,

Sorry for the spam but I saw that you did not enable the external interrupt in 
INTCON0. I was confused because you mentioned "An interrupt on A2 changing 
should start the process but that doesn't work."

But the statement about hanging in the interrupt routine still stands.

You have to change the code in your interrupt routine into the following:

procedure changeLuminosite() is pragma INTERRUPT
  if PIR1_CMIF then     --changement de luminosité détecté
     PIR1_CMIF = FALSE
    changeLum = TRUE
  end if
end procedure

Otherwise the PIC will re-enter the interrupt routine as soon as it has left it.

Kind regards,

Rob



________________________________
Van: [email protected] <[email protected]> namens Rob CJ 
<[email protected]>
Verzonden: dinsdag 28 juli 2020 19:10
Aan: [email protected] <[email protected]>
Onderwerp: Re: [jallib] PIC12F675 INTERRUPT WITH COMPARATOR OUTPUT CHANGING 
doesn't work

Hi Michel,

Sorry missed that one. Then your problem may be the following.

I do not see that you service the external interrupt. This will result in the 
PIC being continuous in the interrupt routine since the INTF flag remains set.

It then appears as if the PIC hangs (believe me I have also run into this 
issue).

So you have to least service the external interrupt otherwise it will not work.

Kind regards,

Rob

________________________________
Van: [email protected] <[email protected]> namens Michel MORICE 
<[email protected]>
Verzonden: dinsdag 28 juli 2020 17:57
Aan: [email protected] <[email protected]>
Onderwerp: Re: [jallib] PIC12F675 INTERRUPT WITH COMPARATOR OUTPUT CHANGING 
doesn't work

Hi Rob,
Thank you for trying to help me.
Yes it's necessary to enabling INTCON_PEIE. It is what I did with INTCON = 
0b_1100_0000.
The mystery is elsewhere

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
  Garanti sans virus. 
www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

Le lun. 27 juil. 2020 à 21:42, Rob CJ 
<[email protected]<mailto:[email protected]>> a écrit :
Hi Michel,

Maybe I was too quick. You mentioned that you have connected something to A2 so 
I assume you use the external interrupt.

Next to that you are using a comparator which is a peripheral device.

This means that you also have to enable interrupts from peripheral devices by 
enabling those interrupts with: INTCON_PEIE = TRUE

Kind regards,

Rob

________________________________
Van: Rob CJ <[email protected]<mailto:[email protected]>>
Verzonden: maandag 27 juli 2020 21:38
Aan: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>>
Onderwerp: Re: [jallib] PIC12F675 INTERRUPT WITH COMPARATOR OUTPUT CHANGING 
doesn't work

Hello Michel,

If you want to use the external interrupt you have to enable it by: INTCON_INTE 
= TRUE

Initially it is disabled by default.

Kind regard,

Rob

________________________________
Van: [email protected]<mailto:[email protected]> 
<[email protected]<mailto:[email protected]>> namens Michel MORICE 
<[email protected]<mailto:[email protected]>>
Verzonden: maandag 27 juli 2020 12:06
Aan: jallib <[email protected]<mailto:[email protected]>>
Onderwerp: [jallib] PIC12F675 INTERRUPT WITH COMPARATOR OUTPUT CHANGING doesn't 
work

Hi
On a PIC12F675 I use A0 and A1 as analogic input to control the light of the 
day to open/close a door
A2 as logic output with a led to control the right operating.
An interrupt on A2 changing should start the process but that doesn't work.
Hereafter a little program to try the function.
Thanks for helping me.

--************************************************************************
--****** Programme POULE2  -Ouverture crépusculaire du poulailler ********
--***************************************Michel MORICE 16 juillet 2020****
include 12f675
pragma target clock 4_000_000
pragma target OSC INTOSC_NOCLKOUT  -- horloge interne à 4 MHz
pragma target MCLR internal        -- make MCLR pin A3 available as I/O
pragma target WDT disabled
--conditionnement du PIC
ANSEL  = 0b_0000_0011  --ports 0 et 1 en analogique, entrées du comparateur
TRISIO = 0b_0000_1011  --ports 0, 1, 3 en input, 2, 4 et 5 en output
CMCON  = 0b_0000_0001  --comparateur + en 0, - en 1, sortie en 2
PIE1   = 0b_0000_1000  --comparateur enable bit
INTCON = 0b_1100_0000  --global interrupt et peripheral interrupt
--paramétrage des portes
alias COMPS is pin_A2   --sortie du comparateur
alias ILS is pin_A3     --ILS contrôlant la fermeture de porte
alias OUVRE is pin_A4   --commande l'ouverture
alias FERME is pin_A5   --commande la fermeture
--paramétrage général
--ON OFF TRUE FALSE définis par include 12f675 et constants_jallib
const dword seconde = 1_000_000
const bit OUVERTE = ON
const bit FERMEE  = OFF
var bit changeLum = FALSE
--***************************************************************
--****************************************************************
procedure changeLuminosite() is pragma INTERRUPT
  if PIR1_CMIF then     --changement de luminosité détecté
    changeLum = TRUE
  end if
end procedure
--****************************************************************
--programme principal
forever loop
  if changeLum then
    PIR1_CMIF = OFF
    INTCON_GIE = OFF
    OUVRE = ON
    _usec_delay(seconde * 3)
    OUVRE = OFF
  end if
  INTCON_GIE = ON
  changeLum = FALSE
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/cdf66d12-1e34-4563-9d26-345617726af0o%40googlegroups.com<https://groups.google.com/d/msgid/jallib/cdf66d12-1e34-4563-9d26-345617726af0o%40googlegroups.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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/AM0PR07MB6241E981A94CAD71E293ABCFE6720%40AM0PR07MB6241.eurprd07.prod.outlook.com<https://groups.google.com/d/msgid/jallib/AM0PR07MB6241E981A94CAD71E293ABCFE6720%40AM0PR07MB6241.eurprd07.prod.outlook.com?utm_medium=email&utm_source=footer>.

[https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
  Garanti sans virus. 
www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>

--
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/CAD9DK3KRQ%3DwE4NuYqB_h4qWFUCbDjGOej9s3qGHd3EJ7my_-sQ%40mail.gmail.com<https://groups.google.com/d/msgid/jallib/CAD9DK3KRQ%3DwE4NuYqB_h4qWFUCbDjGOej9s3qGHd3EJ7my_-sQ%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]<mailto:[email protected]>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/AM0PR07MB624194A0ECB1FA0C696F7E9BE6730%40AM0PR07MB6241.eurprd07.prod.outlook.com<https://groups.google.com/d/msgid/jallib/AM0PR07MB624194A0ECB1FA0C696F7E9BE6730%40AM0PR07MB6241.eurprd07.prod.outlook.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/AM0PR07MB62411E45F1DBD56F30C83C29E6730%40AM0PR07MB6241.eurprd07.prod.outlook.com.

Reply via email to