Bonjour à tous.
J'ai lu le tuto sur les interruptions et pour me familiarisé, j'ai fait le programme suivant
// ARDUINO UNO
volatile int Commande_LED = 0;
void setup()
{
// port de sortie
DDRB |=(1<<DDB5); // PB5 HIGH en sortie : broche 13
PORTB &= ~(1<<PORTB5); // PB5 LOW : broche 13
noInterrupts(); // Interruption non autorisées
//Interruption broche 8
DDRB &=~(1<<DDB0); // pin en Entrée = 0
PORTB |=(1<<PORTB0); // pin HIGH : PULLUP Activée
PCICR |=(1<<PCIE0); // Sélection du port 0 = B, C = 1, D = 2
PCMSK0 |=(1<<PCINT0); //
interrupts(); // Interruption autorisées
}
//**************************************************************
ISR (PCINT0_vect) // Interruption sur changement d'état
{
Commande_LED = 1;
}
//******************************************************************
void loop()
{
if(Commande_LED == 1)
{
PORTB |= (1<<PORTB5); // pin 13 HIGH
delay(500);
Commande_LED = 0;
PORTB &= ~(1<<PORTB5); // pin 13 LOW
}
}
L'interruption sur la broche 8 fonctionne correctement, j'ai voulu utiliser la broche 9 suivant le programme suivant mais sans succès
// ARDUINO UNO
volatile int Commande_LED = 0;
void setup()
{
// port de sortie
DDRB |=(1<<DDB5); // PB5 HIGH en sortie : broche 13
PORTB &= ~(1<<PORTB5); // PB5 LOW : broche 13
noInterrupts(); // Interruption non autorisées
//Interruption broche 9
DDRB &=~(1<<DDB1); // pin en Entrée = 0
PORTB |=(1<<PORTB1); // pin HIGH : PULLUP Activée
PCICR |=(1<<PCIE0); // Sélection du port 0 = B, C = 1, D = 2
PCMSK0 |=(1<<PCINT1); //
interrupts(); // Interruption autorisées
}
//**************************************************************
ISR (PCINT1_vect) // Interruption sur changement d'état
{
Commande_LED = 1;
}
//******************************************************************
void loop()
{
if(Commande_LED == 1)
{
PORTB |= (1<<PORTB5); // pin 13 HIGH
delay(500);
Commande_LED = 0;
PORTB &= ~(1<<PORTB5); // pin 13 LOW
}
}
L'un d'entre vous peux-t-il me dire ou est mon erreur.
Cordialement.
Marc.