Pièce jointe « mod_IO.tex »
Téléchargement 1 \section{Module IO (E/S) et manipulation des broches}
2
3 Montre les fonctions pour pouvoir travailler avec les broches du PIC.
4
5 \verb! #include <pinio.h> !
6
7 \subsection[{output\_high\_slow}]{\label{ID_OUTPUTHIGHSLOW}output\_high\_slow}
8
9 Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC, vérifie l'état de \textbf{tris}
10 \begin{verbatim}
11 void output_high_slow( BYTE puerto,
12 BYTE pin);
13 ejemplo:
14 output_high_slow(PIN_B0);
15 \end{verbatim}
16 \subsection[{output\_high\_fast}]{\label{ID_OUTPUTHIGHFAST}output\_high\_fast}
17
18 Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC, ne vérifie pas l'état de \textbf{tris}
19 \begin{verbatim}
20 void output_high_fast( BYTE puerto,
21 BYTE pin);
22 ejemplo:
23 output_high_fast(PIN_B0);
24 \end{verbatim}
25
26 \subsection[{output\_high}]{\label{ID_OUTPUTHIGH}output\_high}
27
28 Établit une broche de sortie (PIN) à l'état haut, tension proche de VCC.
29 La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE
30
31 Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE , SLOW\_IO a la valeur TRUE
32
33 \begin{verbatim}
34 #define SLOW_IO TRUE
35
36 void output_high_fast( BYTE puerto,
37 BYTE pin);
38 ejemplo:
39 output_high_fast(PIN_B0);
40 \end{verbatim}
41
42 \subsection[{output\_low\_slow}]{\label{ID_OUTPUTLOWSLOW}output\_low\_slow}
43
44 Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse, vérifie l'état de \textbf{tris}
45 \begin{verbatim}
46 void output_low_slow( BYTE puerto,
47 BYTE pin);
48 exemple:
49 output_low_slow(PIN_B0);
50 \end{verbatim}
51
52 \subsection[{output\_low\_fast}]{\label{ID_OUTPUTLOWFAST}output\_low\_fast}
53
54 Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse, ne vérifie pas l'état de \textbf{tris}
55 \begin{verbatim}
56 void output_low_fast( BYTE puerto,
57 BYTE pin);
58 exemple:
59 output_low_fast(PIN_B0);
60 \end{verbatim}
61
62 \subsection[{output\_low}]{\label{ID_OUTPUTLOW}output\_low}
63 Établit une broche de sortie (PIN) a l'état bas, tension proche de la masse,
64 La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE
65
66 Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE , SLOW\_IO a la valeur TRUE
67
68 \begin{verbatim}
69 void output_low( BYTE puerto,
70 BYTE pin);
71 exemple:
72 output_low(PIN_B0);
73 \end{verbatim}
74
75 \subsection[{input\_slow}]{\label{ID_INPUTSLOW}input\_slow}
76
77 Retourne l'état d'une broche d'entrée (pin). peut être 1 ou 0, vérifie l'état de \textbf{tris}
78 \begin{verbatim}
79 BYTE input_slow( BYTE puerto,
80 BYTE pin);
81 exemple:
82 input_slow(PIN_B1);
83 \end{verbatim}
84
85 \subsection[{input\_fast}]{\label{ID_INPUTFAST}input\_fast}
86
87 Retourne l'état d'une broche d'entrée (pin) peut être 1 ou 0, ne vérifie pas l'état de \textbf{tris}
88 \begin{verbatim}
89 BYTE input_fast( BYTE puerto,
90 BYTE pin);
91 exemple:
92 input_fast(PIN_B1);
93 \end{verbatim}i2c\_start
94
95 \subsection[{input}]{\label{ID_INPUT}input}
96
97 Retourne l'état d'une broche d'entrée (pin). peut être 1 ou 0
98 La vérification de l'état de tris dépend de l'état de la macro SLOW\_IO come vrai TRUE ou faux FALSE
99
100 Par défaut, si on n'écrit pas \#define SLOW\_IO TRUE , SLOW\_IO a la valeur TRUE
101
102 \begin{verbatim}
103 BYTE input( BYTE puerto,
104 BYTE pin);
105 exemple:
106 input(PIN_B1);
107 \end{verbatim}
108
109 \subsection[{set\_pin\_to\_slow}]{ \label{ID_SETPINTOSLOW}set\_pin\_to\_slow}
110
111 Établit l'état d'une broche de sortie (pin) à 1 ou 0
112 \begin{verbatim}
113 void set_pin_to_slow(volatile BYTE puerto,
114 BYTE pin,
115 BYTE X);
116 exemple :
117 set_pin_to_slow(PIN_C1,1);//la broche C1 est maintenant à l'état haut
118 set_pin_to_slow(PIN_C1,0);//la broche C1 est maintenant à l'état bas
119 \end{verbatim}
120
121 \subsection[{set\_pin\_to\_fast}]{ \label{ID_SETPINTOFAST}set\_pin\_to\_fast}
122
123 Établit l'état d'une broche de sortie (pin) à 1 ou 0
124 \begin{verbatim}
125 void set_pin_to_fast(volatile BYTE puerto,
126 BYTE pin,
127 BYTE X);
128 exemple :
129 set_pin_to_fast(PIN_C1,1);//la broche C1 est maintenant à l'état haut
130 set_pin_to_fast(PIN_C1,0);//la broche C1 est maintenant à l'état bas
131 \end{verbatim}
132 \subsection[{set\_pin\_to}]{ \label{ID_SETPINTO}set\_pin\_to}
133
134 Établit l'état d'une broche de sortie (pin) à 1 ou 0
135 \begin{verbatim}
136 void set_pin_to(volatile BYTE puerto,
137 BYTE pin,
138 BYTE X);
139 exemple :
140 set_pin_to(PIN_C1,1);//la broche C1 est maintenant à l'état haut
141 set_pin_to(PIN_C1,0);//la broche C1 est maintenant à l'état bas
142 \end{verbatim}
143
144 \subsection[{set\_pin\_tris\_to}]{\label{ID_SETPINTRISTO}set\_pin\_tris\_to}
145
146 TRIS data direction register: registre de direction des données.
147
148 Établit le TRIS d'une ~broche à 1 ou 0
149 \begin{itemize}
150 \item si TRIS est à 1, la broche est en entrée
151 \item si TRIS est à 0, la broche est en sortie
152 \end{itemize}
153
154 \begin{verbatim}
155 void set_pin_tris_to(volatile BYTE *tris,
156 volatile BYTE *puerto,
157 BYTE pin,
158 BYTE X);
159 exemple:
160 set_pin_tris_to(PIN_C1,1);//el TRIS C1 à 1, C1 en entrée
161 set_pin_tris_to(PIN_C1,0);//el TRIS C1 à 0, C1 en sortie
162 \end{verbatim}
163
164 \subsection[{set\_porta\_as\_digital}]{\label{ID_SETPORTAASDIGITAL}set\_porta\_as\_digital}
165
166 Établit le port A comme DIGITAL
167 \begin{verbatim}
168 #define set_porta_as_digital() ADCON1=0x06
169 exemple:
170 set_porta_as_digital();
171 \end{verbatim}
172
173 \subsection[{set\_pullup\_portb}]{ \label{ID_SETPULLUPPORTB}set\_pullup\_portb}
174
175 autorise ou inhibe les résistances de tirage vers le haut (pull-{}up) du port B
176
177 \begin{itemize}
178 \item pour autoriser les résistances de tirage vers le haut (pull-{}up) X= 1 o TRUE
179 \item pour inhiber ~les résistances de tirage vers le haut (pull-{}up) ~X= 0 o FALSE
180 \end{itemize}
181
182 void set\_pullup\_portb(BYTE X);
183
184 \subsection[{Exemple de PinIO}]{ \label{ID_EJEMPLOPINIO}Exemple de PinIO}
185
186 pour compiler vous avez besoin des commandes suivantes :
187 \begin{verbatim}
188 Exemple de compilation : ~./compila.sh ej\_pinio 16f877a
189 \end{verbatim}
190
191 ej\_pinio.c
192 \verbatiminput{source/ej_pinio.c}
Fichiers joints
Pour vous référer aux pièces jointes d'une page, utilisez attachment:filename, comme indiqué ci-dessous dans la liste de fichiers. N'utilisez pas l'URL du lien [get], car elle peut changer et donc être facilement cassée.Vous n'êtes pas autorisé à joindre un fichier à cette page.