From 054bffbda977b7080e9cb19604cd588bdfda755e Mon Sep 17 00:00:00 2001 From: Yohan Boujon Date: Wed, 3 Feb 2021 18:37:06 +0100 Subject: [PATCH] Added tp1 --- tp1/exo2.c | 22 +++++ tp1/exo3.c | 21 +++++ tp1/exo4.c | 25 ++++++ tp1/exo5.c | 25 ++++++ tp1/exo6.c | 28 ++++++ tp1/exo7.c | 44 ++++++++++ tp1/main.c | 28 ++++++ tp1/tutoriel.componentinfo.xml | 86 ++++++++++++++++++ tp1/tutoriel.cproj | 156 +++++++++++++++++++++++++++++++++ 9 files changed, 435 insertions(+) create mode 100755 tp1/exo2.c create mode 100755 tp1/exo3.c create mode 100755 tp1/exo4.c create mode 100755 tp1/exo5.c create mode 100755 tp1/exo6.c create mode 100755 tp1/exo7.c create mode 100755 tp1/main.c create mode 100755 tp1/tutoriel.componentinfo.xml create mode 100755 tp1/tutoriel.cproj diff --git a/tp1/exo2.c b/tp1/exo2.c new file mode 100755 index 0000000..9565e9d --- /dev/null +++ b/tp1/exo2.c @@ -0,0 +1,22 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO + +unsigned char a,b,x,y,z; + +int main(void) +{ + DDRB = 0xFF; + x = 0x6E; + y = 0xA5; + z = ~((x & 0xF0) | (y & 0x0F)); + PORTB = ~z; + + while (1) { + } +} diff --git a/tp1/exo3.c b/tp1/exo3.c new file mode 100755 index 0000000..2162a29 --- /dev/null +++ b/tp1/exo3.c @@ -0,0 +1,21 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO + +unsigned char entree,sortie; + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + while (1) { + entree=PINA; + sortie=entree; + PORTB=sortie; + } +} \ No newline at end of file diff --git a/tp1/exo4.c b/tp1/exo4.c new file mode 100755 index 0000000..e065365 --- /dev/null +++ b/tp1/exo4.c @@ -0,0 +1,25 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + while (1) { + if(PINA==0xFF) + { + PORTB=0xFF; + } + else + { + PORTB=0x00; + }; + } +} + diff --git a/tp1/exo5.c b/tp1/exo5.c new file mode 100755 index 0000000..971564b --- /dev/null +++ b/tp1/exo5.c @@ -0,0 +1,25 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + while (1) { + if(PINA==0xF7) //on vérifie si le 3ème bouton est appuyé + { + PORTB=0x00; //les leds sont allumées + } + else + { + PORTB=0xFF; //les leds sont éteintes + }; + } +} + diff --git a/tp1/exo6.c b/tp1/exo6.c new file mode 100755 index 0000000..ee30bfe --- /dev/null +++ b/tp1/exo6.c @@ -0,0 +1,28 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO +unsigned char carry,temp; + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + while (1) + { + if(PINA==0xF7) + { + carry=1; + }; + if(carry==1 && PINA!=0xF7) + { + PORTB=~PORTB; + carry=0; + }; + }; +} + diff --git a/tp1/exo7.c b/tp1/exo7.c new file mode 100755 index 0000000..f2ef3a1 --- /dev/null +++ b/tp1/exo7.c @@ -0,0 +1,44 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO +#define F_CPU 3686400 //nous specifions la fréquence du processeur +#include //bibliotheque necessaire pour le delai en millisecondes +#define V1R2 ~0x81 //on defini chaque pattern de leds donné dans le tp +#define O1R2 ~0x41 +#define R1R2 ~0x21 +#define R1V2 ~0x24 +#define R1O2 ~0x22 +#define R1R2 ~0x21 + +void seconde(char x); //fonction qui fait attendre x secondes + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + char tabsec[6]= {2, 4, 2, 15, 4, 2}; //on defini chaque cycle en secondes + char tabfeu[6]= {V1R2, O1R2, R1R2, R1V2, R1O2, R1R2}; //on defini le pattern de chaque led + while (1) + { + int i; + for(i=0;i<6;i++) //on repete 6 fois l'action en fonction des valeurs du tableau + { + PORTB=tabfeu[i]; //on affect un pattern en fonction de sa valeur dans le tableau + seconde(tabsec[i]); //on attends x secondes en fonction de la durée du cycle défini dans le tableau + }; + }; +} + +void seconde(char x) +{ + int y; + for(y=0;y<100*x+1;y++) + { + _delay_ms(10); + } +} \ No newline at end of file diff --git a/tp1/main.c b/tp1/main.c new file mode 100755 index 0000000..7d32bb2 --- /dev/null +++ b/tp1/main.c @@ -0,0 +1,28 @@ +/* + * tutoriel.c + * + * Created: 29/01/2021 09:13:18 + * Author : yboujon1 + */ + +#include // necessaire pour l'acces au reg IO +unsigned char carry,temp; + +int main(void) +{ + DDRB = 0xFF; //sortie + DDRA = 0x00; //entree + while (1) + { + if((PINA & (1< + + + + + + Device + Startup + + + Atmel + 1.2.0 + C:/Program Files (x86)\Atmel\Studio\7.0\Packs + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include + + include + C + + + include + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\include\avr\iom16.h + + header + C + BDa+/Y5e630de26bwSjZpg== + + include/avr/iom16.h + + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.c + template + source + C Exe + H7ZbrvNuFnv6bp46igi5tg== + + templates/main.c + Main file (.c) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\templates\main.cpp + template + source + C Exe + YXFphlh0CtZJU+ebktABgQ== + + templates/main.cpp + Main file (.cpp) + + + + C:/Program Files (x86)\Atmel\Studio\7.0\Packs\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16 + + libraryPrefix + GCC + + + gcc/dev/atmega16 + + + + + ATmega_DFP + C:/Program Files (x86)/Atmel/Studio/7.0/Packs/atmel/ATmega_DFP/1.2.132/Atmel.ATmega_DFP.pdsc + 1.2.132 + true + ATmega16 + + + + Resolved + Fixed + true + + + \ No newline at end of file diff --git a/tp1/tutoriel.cproj b/tp1/tutoriel.cproj new file mode 100755 index 0000000..b3965c9 --- /dev/null +++ b/tp1/tutoriel.cproj @@ -0,0 +1,156 @@ + + + + 2.0 + 7.0 + com.Atmel.AVRGCC8.C + dce6c7e3-ee26-4d79-826b-08594b9ad897 + ATmega16 + none + Executable + C + $(MSBuildProjectName) + .elf + $(MSBuildProjectDirectory)\$(Configuration) + tutoriel + tutoriel + tutoriel + Native + true + false + true + true + 0x20000000 + + true + exception_table + 2 + 0 + + + + + + + + + + + + + com.atmel.avrdbg.tool.simulator + + 0x1E9403 + + + + + ISP + + com.atmel.avrdbg.tool.simulator + + + Simulator + + ISP + + + + 0 + + ISP + + com.atmel.avrdbg.tool.stk500 + + + STK500 + + 0 + 0 + + + + + + -mmcu=atmega16 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16" + True + True + True + True + False + True + True + + + NDEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize for size (-Os) + True + True + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + + + + + + + -mmcu=atmega16 -B "%24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\gcc\dev\atmega16" + True + True + True + True + False + True + True + + + DEBUG + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Optimize (-O1) + True + True + Default (-g2) + True + + + libm + + + + + %24(PackRepoDir)\atmel\ATmega_DFP\1.2.132\include + + + Default (-Wa,-g) + + + + + + compile + + + + \ No newline at end of file