Diferencia entre revisiones de «PCINT»
De ArduWiki
(→Comentarios) |
(→Referencias externas) |
||
(No se muestran 6 ediciones intermedias del mismo usuario) | |||
Línea 14: | Línea 14: | ||
</pre> | </pre> | ||
− | == | + | == Puertos INT == |
{|class="wikitable" | {|class="wikitable" | ||
− | |+ | + | |+Arduino [[UNO]] y [[NANO]] |
|- | |- | ||
!Pin!!Port!!INT | !Pin!!Port!!INT | ||
Línea 26: | Línea 26: | ||
{|class="wikitable" | {|class="wikitable" | ||
− | |+PCINT | + | |+Arduino [[MEGA]] |
+ | |- | ||
+ | !Pin!!Port!!INT | ||
+ | |- | ||
+ | |6||PE4||INT4 | ||
+ | |- | ||
+ | |7||PE5||INT5 | ||
+ | |- | ||
+ | |43||PD0||INT0 | ||
+ | |- | ||
+ | |44||PD1||INT1 | ||
+ | |- | ||
+ | |45||PD3||INT2 | ||
+ | |- | ||
+ | |46||PD6||INT3 | ||
+ | |} | ||
+ | |||
+ | == Puertos PCINT == | ||
+ | {|class="wikitable" | ||
+ | |+Arduino [[UNO]] y [[NANO]] | ||
|- | |- | ||
!Pin!!Port!!PCINT!!Pin!!Port!!PCINT!!Pin!!Port!!PCINT | !Pin!!Port!!PCINT!!Pin!!Port!!PCINT!!Pin!!Port!!PCINT | ||
Línea 41: | Línea 60: | ||
|- | |- | ||
|7||PD7||PCINT23||13||PB5||PCINT5||A5||PC5||PCINT13 | |7||PD7||PCINT23||13||PB5||PCINT5||A5||PC5||PCINT13 | ||
+ | |} | ||
+ | |||
+ | {|class="wikitable" | ||
+ | |+Arduino [[UNO]] y [[NANO]] | ||
+ | |- | ||
+ | !Pin!!Port!!PCINT!!Pin!!Port!!PCINT!!Pin!!Port!!PCINT | ||
+ | |- | ||
+ | |10||PB4||PCINT4||SS||PCINT0||PB0||A8||PK0||PCINT16 | ||
+ | |- | ||
+ | |11||PD7||PCINT5||SCK||PCINT1||PB1||A9||PK1||PCINT17 | ||
+ | |- | ||
+ | |12||PD7||PCINT6||MOSI||PCINT2||PB2||A10||PK2||PCINT18 | ||
+ | |- | ||
+ | |13||PD7||PCINT7||MISO||PCINT3||PB3||A11||PK3||PCINT19 | ||
+ | |- | ||
+ | |14||PD7||PCINT10||-||-||-||A12||PK4||PCINT20 | ||
+ | |- | ||
+ | |15||PD7||PCINT9||-||-||-||A13||PK5||PCINT21 | ||
+ | |- | ||
+ | | -||-||-||-||-||-||A14||PK6||PCINT22 | ||
+ | |- | ||
+ | | -||-||-||-||-||-||A15||PK7||PCINT23 | ||
|} | |} | ||
Línea 46: | Línea 87: | ||
== Ejemplo == | == Ejemplo == | ||
− | < | + | <syntaxhighlight lang="c++"> |
// Activar PCINT en un PIN | // Activar PCINT en un PIN | ||
void pciSetup(byte pin){ | void pciSetup(byte pin){ | ||
Línea 78: | Línea 119: | ||
//Nada | //Nada | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
== Vea tambien == | == Vea tambien == | ||
− | * [INT] | + | * [[INT]] |
== Referencias externas == | == Referencias externas == | ||
− | * [https://www.luisllamas.es/interrupciones-en-todos-los-pines-de-arduino-con-pcint/] - Luis Llamas | + | * [https://www.luisllamas.es/interrupciones-en-todos-los-pines-de-arduino-con-pcint/ PCINT] - Luis Llamas |
Revisión actual del 23:03 23 sep 2019
Contenido
Descripcion
Existen dos tipos de interrupciones externas:
- INT, interrupciones de harware externo
- PCINT, interrupciones Pin Change, que actual a nivel de bancos completos.
Sintaxis
PCICR; PCMSK0; PCIFR; ISP(PCINT0_vect) //D8 a D13 ISP(PCINT1_vect) //A0 a A5 ISP(PCINT2_vect) //D0 a D7
Puertos INT
Pin | Port | INT |
---|---|---|
2 | PD2 | INT0 |
3 | PD3 | INT2 |
Pin | Port | INT |
---|---|---|
6 | PE4 | INT4 |
7 | PE5 | INT5 |
43 | PD0 | INT0 |
44 | PD1 | INT1 |
45 | PD3 | INT2 |
46 | PD6 | INT3 |
Puertos PCINT
Pin | Port | PCINT | Pin | Port | PCINT | Pin | Port | PCINT |
---|---|---|---|---|---|---|---|---|
2 | PD2 | PCINT18 | 8 | PB0 | PCINT0 | A0 | PC0 | PCINT8 |
3 | PD3 | PCINT19 | 9 | PB1 | PCINT1 | A1 | PC1 | PCINT9 |
4 | PD4 | PCINT20 | 10 | PB2 | PCINT2 | A2 | PC2 | PCINT10 |
5 | PD5 | PCINT21 | 11 | PB3 | PCINT3 | A3 | PC3 | PCINT11 |
6 | PD6 | PCINT22 | 12 | PB4 | PCINT4 | A4 | PC4 | PCINT12 |
7 | PD7 | PCINT23 | 13 | PB5 | PCINT5 | A5 | PC5 | PCINT13 |
Pin | Port | PCINT | Pin | Port | PCINT | Pin | Port | PCINT |
---|---|---|---|---|---|---|---|---|
10 | PB4 | PCINT4 | SS | PCINT0 | PB0 | A8 | PK0 | PCINT16 |
11 | PD7 | PCINT5 | SCK | PCINT1 | PB1 | A9 | PK1 | PCINT17 |
12 | PD7 | PCINT6 | MOSI | PCINT2 | PB2 | A10 | PK2 | PCINT18 |
13 | PD7 | PCINT7 | MISO | PCINT3 | PB3 | A11 | PK3 | PCINT19 |
14 | PD7 | PCINT10 | - | - | - | A12 | PK4 | PCINT20 |
15 | PD7 | PCINT9 | - | - | - | A13 | PK5 | PCINT21 |
- | - | - | - | - | - | A14 | PK6 | PCINT22 |
- | - | - | - | - | - | A15 | PK7 | PCINT23 |
Advertencias
Ejemplo
// Activar PCINT en un PIN
void pciSetup(byte pin){
*digitalPinToPCMSK(pin) |= bit (digitalPinToPCMSKbit(pin)); //activar pin en PCMSK
PCIFR |= bit (digitalPinToPCICRbit(pin)); //limpiar flag de la interrupcion en PCIFR
PCICR |= bit (digitalPinToPCICRbit(pin)); //activar interrupcion para el grupo en PCICR
}
// Definir ISR para cada puerto
ISR(PCINT0_vect) {
//gestionar para PCINT para D8 a D13
}
ISR(PCINT1_vect){
//gestionar PCINT para A0 a A5
}
ISR(PCINT2_vect){
//gestionar PCINT para D0 a D7
}
void setup(){
//Activar las PCINT para distintos pins
pciSetup(7);
pciSetup(8);
pciSetup(9);
pciSetup(A0);
}
void loop(){
//Nada
}
Vea tambien
Referencias externas
- PCINT - Luis Llamas