Cours:CoursM2103

De troyesGEII
Aller à : navigation, rechercher

gestion des broches

Entrée/Sortie

broche Rôle Registre Code
PC5 Sortie DDRC DDRC |= (1<<PC5);
PD5 et PD7 Sortie DDRD DDRD |= (1<<PD5)|(1<<PD7);
PA3 Entrée DDRA DDRA &=~(1<<PA3);
PD0 et PD1 Entrée DDRD  DDRD &=~( (1<<PD0)|(1<<PD1));
// modifier la direction de toutes les broches d'un port
// ex : PA0,PA1,PA2,PA3 en entrées
// ex : PA4,PA5,PA6,PA7 en sortie

DDRA=0b11110000;
//ou
DDRA=0xF0;
//ou
DDRA=(1<<PA7)|(1<<PA6)|(1<<PA5)|(1<<PA4)|(0<<PA3)|(0<<PA2)|(0<<PA1)|(0<<PA0);
//ou
DDRA|=(1<<PA7)|(1<<PA6)|(1<<PA5)|(1<<PA4);
DDRA&=~((1<<PA3)|(1<<PA2)|(1<<PA1)|(1<<PA0));