Interruptions PCINT
bonjour à tous.
j'ai lu le tuto sur les interruptions et pour me familiarisé, j'ai fait le programme suivant
l'interruption sur la broche 8 fonctionne correctement, j'ai voulu utiliser la broche 9 suivant le programme suivant mais sans succès
l'un d'entre vous peux-t-il me dire ou est mon erreur.
cordialement.
marc.
 							j'ai lu le tuto sur les interruptions et pour me familiarisé, j'ai fait le programme suivant
code: [select]
// 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
code: [select]
// 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.
hello
dans ton 2ème prg, il faut aussi
isr (pcint0_vect) // interruption sur changement d'état
{
commande_led = 1;
}
la doc atmel porte à confusion
il n'y pas un vecteur d'interruption par bit mais par port.
le port b, c'est le vecteur 0
 							dans ton 2ème prg, il faut aussi
isr (pcint0_vect) // interruption sur changement d'état
{
commande_led = 1;
}
la doc atmel porte à confusion
il n'y pas un vecteur d'interruption par bit mais par port.
le port b, c'est le vecteur 0
            						 					Arduino Forum  						 						 							 >   					International  						 						 							 >   					Français  (Moderators: jfs, Snootlab)  						 						 							 >   					Interruptions PCINT  						 					
arduino
 
  
Comments
Post a Comment