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].
To view this discussion on the web visit
https://groups.google.com/d/msgid/jallib/cdf66d12-1e34-4563-9d26-345617726af0o%40googlegroups.com.