Estou tendo problema com µC str711fr2 muito intrigante. O problema esta no envio de dados pela serial, por exemplo enviado 0x55, no outro µC/PC chega 0x03, a hipótese de interferência foi descartada pois o valores são sempre os mesmos e enviando string não apresenta erro, também foi testada várias velocidade e o problema persiste inclusive com os mesmo valores.
O compilador é o gcc versão 4.1.1 utilizando a ultima versão da STR71xlib encontrada no site da ST.
O código resumido utilizado para representar o problema é este:
-------------
- Código: Selecionar todos
#include <stdarg.h>
#include <stdio.h>
#include <71x_lib.h>
#include <71x_map.h>
#include <gpio.h>
#define UART0_Rx_Pin (0x0001<<8)
#define UART0_Tx_Pin (0x0001<<9)
int main (void){
/* Configuracao do PLL com cristal de 16Mhz para os clocks Core:48Mhz APB1:24Mhz APB2:24Mhz ------------*/
// clk / 2
RCCU_Div2Config( ENABLE );
// APB1
RCCU_FCLKConfig ( RCCU_RCLK_2 );
// APB2
RCCU_PCLKConfig ( RCCU_RCLK_2 );
// Configurar MCLK, RCCU_DEFAULT = RCLK /1
RCCU_MCLKConfig ( RCCU_DEFAULT );
// Configurar PLL1 ( * 12 , / 2 )
RCCU_PLL1Config ( RCCU_PLL1_Mul_12, RCCU_Div_2 );
// Aguarda PLL ativar (lock)
while( RCCU_FlagStatus( RCCU_PLL1_LOCK ) == RESET ) ;
// Seleciona PLL1 como fonte de clock para RCLK
RCCU_RCLKSourceConfig (RCCU_PLL1_Output);
/* Configure the UART0 pins */
GPIO_Config(GPIO0, UART0_Tx_Pin, GPIO_AF_PP);
GPIO_Config(GPIO0, UART0_Rx_Pin, GPIO_IN_TRI_CMOS);
/* Configure the UART X */
UART_OnOffConfig( UART0, ENABLE ); /* Turn UART0 on */
//UART_FifoConfig ( UART0, ENABLE ); /* Disable FIFOs */
UART_FifoReset ( UART0 , UART_RxFIFO ); /* Reset the UART_RxFIFO */
UART_FifoReset ( UART0 , UART_TxFIFO ); /* Reset the UART_TxFIFO */
UART_LoopBackConfig(UART0 , DISABLE ); /* Disable Loop Back */
/* Configure the UART0 as following:
- Baudrate = 9600 Bps
- No parity
- 8 data bits
- 1 stop bit */
UART_Config( UART0, 9600, UART_NO_PARITY, UART_1_StopBits ,UARTM_8D );
UART_RxConfig( UART0, ENABLE ); /* Enable Rx */
UART_StringSend(UART0, "Teste 123");
UART_ByteSend( UART0, 0 );
for (int ind = 0; ind <= 255;ind++){
UART_ByteSend(UART0,(u8 *)ind);
}
UART_ByteSend( UART0, 255 );
}
-------------
A saída do código acima é esta:
---
- Código: Selecionar todos
TX = valor em decimal que sai do µC
RX = valor em decimal que chega no outro µC ou PC
Tx Rx
----------------------------
Teste 123 Teste 123
0 24
0 24
1 240
2 159
3 229
4 24
5 240
6 159
7 229
8 24
9 240
10 159
11 229
12 24
13 240
14 159
15 229
16 24
17 240
18 159
19 229
20 0
21 0
22 160
23 225
24 24
25 240
26 159
27 229
28 24
29 240
30 159
31 229
32 192
33 0
34 0
35 64
36 160
37 2
38 0
39 64
40 128
41 2
42 0
43 64
44 188
45 2
46 0
47 64
48 220
49 2
50 0
51 64
52 0
53 0
54 0
55 0
56 64
57 2
58 0
59 64
60 252
61 2
62 0
63 64
64 28
65 3
66 0
67 64
68 52
69 3
70 0
71 64
72 76
73 3
74 0
75 64
76 100
77 3
78 0
79 64
80 124
81 3
82 0
83 64
84 148
85 3
86 0
87 64
88 172
89 3
90 0
91 64
92 196
93 3
94 0
95 64
96 220
97 3
98 0
99 64
100 244
101 3
102 0
103 64
104 12
105 4
106 0
107 64
108 36
109 4
110 0
111 64
112 60
113 4
114 0
115 64
116 84
117 4
118 0
119 64
120 108
121 4
122 0
123 64
124 132
125 4
126 0
127 64
128 156
129 4
130 0
131 64
132 180
133 4
134 0
135 64
136 204
137 4
138 0
139 64
140 228
141 4
142 0
143 64
144 252
145 4
146 0
147 64
148 20
149 5
150 0
151 64
152 0
153 0
154 0
155 0
156 0
157 0
158 0
159 0
160 0
161 0
162 0
163 0
164 44
165 5
166 0
167 64
168 68
169 5
170 0
171 64
172 0
173 0
174 0
175 0
176 0
177 0
178 0
179 0
180 92
181 5
182 0
183 64
184 116
185 5
186 0
187 64
188 140
189 5
190 0
191 64
192 44
193 241
194 159
195 229
196 0
197 0
198 160
199 225
200 0
201 0
202 160
203 225
204 0
205 0
206 160
207 225
208 0
209 0
210 160
211 225
212 0
213 0
214 160
215 225
216 0
217 0
218 160
219 225
220 0
221 0
222 160
223 225
224 0
225 0
226 160
227 225
228 0
229 0
230 160
231 225
232 215
233 240
234 33
235 227
236 4
237 209
238 159
239 229
240 219
241 240
242 33
243 227
244 0
245 209
246 159
247 229
248 211
249 240
250 33
251 227
252 252
253 208
254 159
255 229
255 229
---
Lembrando que a string é corretamente interpretada no terminal.
Se alguém tiver alguma dica,
desde já agradeço.