CROSS Technical Documentation User Manual and Technical Doc.
INFN Milano Bicocca
Loading...
Searching...
No Matches
Error_handling.c
Go to the documentation of this file.
1/*----------------------------------------------------------------------------
2 * Name: Error_handling.c
3 * Purpose: Funzioni e variabili per la gestione degli errori
4 * Version: V1.00
5 * Note(s):
6 *----------------------------------------------------------------------------
7 * History:
8 *
9 *----------------------------------------------------------------------------*/
10 /// \file
11
12/*! \page ErrorCross_ ErrorCross
13 *\brief <span style="color:red;"> <b> Errors Managing </b> </span>
14 *\tableofcontents
15
16 *\section error_summary Page Summary
17 <hr width="50%" size="10" align="left">
18 Here you can find informations about the follwoing topics:
19 - \ref indirizzi_flag
20 - \ref indirizzi
21 - \ref flags
22 - \ref error_managing_functions
23 - \ref error_anatomy
24
25 *\section indirizzi_flag Error registers and flags
26<hr width="90%" size="10" align="left">
27 *\subsection indirizzi Error registers
28 <hr width="90%" size="10" align="left">
29 A large number of flags are available to take account of the presence of errors or not adequate performances
30 of both the hw and fw.
31 The errors are in a vector of \b unsigned \b int. Every element of the vector cotains 32 flags of information.
32 A flag in true state means that the corresponding error has been verified.
33 The vector with the errors is #Post_frontend_errors:
34\snippet Error_handling.c vec_Post_frontend_errors
35 its registers are addressed according to the enum #ERROR_CROSS_address_
36 whose list follows. Note that the length of the half vector is #error_number_of_errors_registers, the last element of the list for board down.
37 A similar number of elements with the same name offset by #error_offset_for_board_up account for board up.
38 The number on left of the list is the register address whithin #Post_frontend_errors:
39
40<ol start="0">
41 <li> #error_address_reg_ADC0 flags list at \ref flags_error_ADC
42 <li> #error_address_reg_ADC1 flags list at \ref flags_error_ADC
43 <li> #error_address_Power_Supply_in_General flags list at \ref flags_error_PowerSupply
44 <li> #error_address_I2C0 Error register for I2C0 flags list at \ref flags_error_I2C
45 <li> #error_address_I2C1 Error register for I2C1 flags list at \ref flags_error_I2C
46 <li> #error_address_SPI Error register for SPI flags list at \ref flags_error_SPI
47 <li> #error_preamplifier_down flags list at \ref flags_error_preamplifier
48 <li> #error_preamplifier_up flags list at \ref flags_error_preamplifier
49 <li> #error_address_CAN flags list at \ref flags_error_CAN
50 <li> #error_address_PGA_DetectorTrimmer_down flags list at \ref flags_error_PGA_DetectorTrimmer
51 <li> #error_address_PGA_DetectorTrimmer_up flags list at \ref flags_error_PGA_DetectorTrimmer
52 <li> #error_address_Bias_adjustment flags list at \ref flags_error_Bias_Adj
53 <li> #error_number_of_errors_registers (this is not an address, it is the lenght of the vector)
54 <li> #error_offset_for_board_up registers for board up start from this addres and replica the firsts above
55</ol>
56
57\n The first regsiters, from address 0 to #error_number_of_errors_registers, are for the lower board.
58The registers whose address starts from #error_offset_for_board_up registers,
59are for board up and are a replica in meaning of the first ones. So, for instance, a fail in reading
60power supply for board down is found at address #error_address_Power_Supply_in_General, or 2,
61while the same fail on board up
62is found at address #error_offset_for_board_up registers + #error_address_Power_Supply_in_General.
63
64 *\subsection flags Flags
65<hr width="90%" size="10" align="left">
66\n Every register of the #Post_frontend_errors vector is a set of 32 homogenous flags, that summmmarize the behaviour
67of some subjects, ADC, I2, SPI, etc. The signature of an error is the value of 1 of a flag and every flag.
68 As an instance, to consult the error during I2C0 communication one has to look at the register #Post_frontend_errors[#error_address_I2C0].
69 Each flag of that registers that is 1 marks the verification of any not expected bahaviour.
70 \n Now, to manage the flags a few function are available, described below.
71 \n Let's start to interpet the flags. To each register an enum is built that lists the flags. They are all listed below. The number on the left
72 of the lists are the position of the flag in the register. As an instance, if the error #Vbol_neg_large_for_switching happens, than a 1
73 is stored at 1 << #Vbol_neg_large_for_switching in the #error_address_Power_Supply_in_General register.
74 \n Here is the list:
75
76<!-- ------------------- Definizioni per i contatori --------------------------- -->
77\htmlonly
78<head>
79<style>
80ul {
81 list-style-type: none;
82}
83body {
84 counter-reset: ADC -1 PowSup -1 I2C -1 I2C_B -1 CAN -1 Trimmer -1 Bias -1 preamplifier -1 PGA_DetectorTrimmer -1 SPI -1;
85}
86li.ADC::before {
87 counter-increment: ADC;
88 content: counter(ADC) ". " ;
89}
90li.PowSup::before {
91 counter-increment: PowSup;
92 content: counter(PowSup) ". " ;
93}
94li.I2C::before {
95 counter-increment: I2C;
96 content: counter(I2C) ". " ;
97}
98li.I2C_B::before {
99 counter-increment: I2C_B;
100 content: counter(I2C_B) ". " ;
101}
102li.CAN::before {
103 counter-increment: CAN;
104 content: counter(CAN) ". " ;
105}
106li.Trimmer::before {
107 counter-increment: Trimmer;
108 content: counter(Trimmer) ". " ;
109}
110li.Bias::before {
111 counter-increment: Bias;
112 content: counter(Bias) ". " ;
113}
114li.preamplifier::before {
115 counter-increment: preamplifier;
116 content: counter(preamplifier) ". " ;
117}
118li.PGA_DetectorTrimmer::before {
119 counter-increment: PGA_DetectorTrimmer;
120 content: counter(PGA_DetectorTrimmer) ". " ;
121}
122li.SPI::before {
123 counter-increment: SPI;
124 content: counter(SPI) ". " ;
125}
126
127table, th, td {
128 border: 1px solid;
129 border-collapse: collapse;
130}
131
132</style>
133</head>
134
135
136\endhtmlonly
137<!-- ------------------- FIne Definizioni per i contatori --------------------------- -->
138
139<table style="width: 90%" >
140<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_reg_ADC0 and #error_address_reg_ADC1 (ADC's errors)</td></tr> \anchor flags_error_ADC
141<tr><td style="width: 15%">ADC errors flags </td>
142<td style="width:75%">
143<span style="color:red;"> Da implementare</span>
144<ul>
145 <li class="ADC"> #ADC_internal_General_fails ADC general fault
146 <li class="ADC"> #ADC_SPI_fault (its value is 0) for SPI Communication fault
147 <li class="ADC"> #ADC_RDY_pin_fault for ADC ready signal not received
148 <li class="ADC"> #ADC_RDY_pin_fault_during_calibration for ADC ready not during calibration
149 <li class="ADC"> #VREF_ADC_too_small for ADC VREF measured out of its tolerance, too small
150 <li class="ADC"> #VREF_ADC_too_large for ADC VREF measured out of its tolerance, too large
151 <li class="ADC"> #ADC_external_fails measurement form an external ADC went wrong
152</ul>
153</td>
154</tr>
155</table>
156
157\n
158
159<!-- ------------------- error_address_Power_Supply_in_General --------------------------- -->
160<table style="width: 90%" >
161<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_Power_Supply_in_General (eorrors with any Power Supply)</td></tr> \anchor flags_error_PowerSupply
162<tr><td style="width: 15%">Errors flags for Vbol for switching </td>
163<td style="width:75%">
164<span style="color:red;"> Da implementare</span>
165<ul>
166 <li class="PowSup"> #Vbol_pos_small_for_switching (its value is 0) for Positive Vbol too small for switching from internal to external power or vice-versa</li>
167 <li class="PowSup"> #Vbol_pos_large_for_switching for Positive Vbol too large for switching from internal to external power or vice-versa</li>
168 <li class="PowSup"> #Vbol_neg_small_for_switching for Negative Vbol too small for switching from internal to external power or vice-versa</li>
169 <li class="PowSup"> #Vbol_neg_large_for_switching for Negative Vbol too large for switching from internal to external power or vice-versa</li>
170 <li class="PowSup"> #ADC_RDY_pin_fault_during_calibration for ADC ready not during calibration
171 <li class="PowSup"> #VREF_ADC_too_small for ADC VREF measured out of its tolerance, too small
172 <li class="PowSup"> #VREF_ADC_too_large for ADC VREF measured out of its tolerance, too large
173</ul>
174</td>
175</tr>
176<tr><td>Errors flags for Vbol limiting values </td>
177<td>
178<span style="color:red;"> Da implementare</span>
179 <ul>
180 <li class="PowSup"> #Vbol_pos_too_large for Positive Vbol exceeds the maximum</li>
181 <li class="PowSup"> #Vbol_pos_too_small for Positive Vbol is below the lower limit</li>
182 <li class="PowSup"> #Vbol_neg_too_large for Negative Vbol exceeds the maximum
183 <li class="PowSup"> #Vbol_neg_too_small for Negative Vbol is below the lower limit
184 </ul>
185</td>
186</tr>
187<tr><td>Errors flags for VREF_POS_PRE</td>
188<td>
189<span style="color:red;"> Da implementare</span>
190 <ul>
191 <li class="PowSup"> #Vref_pos_too_large for Positive Vref too large
192 <li class="PowSup"> #Vref_pos_too_small for Positive Vref too small
193 </ul>
194</td>
195</tr>
196<tr><td>Errors flags for VREF_NEG_PRE</td>
197<td>
198<span style="color:red;"> Da implementare</span>
199 <ul>
200 <li class="PowSup"> #Vref_neg_absolute_val_too_large for Negative Vref too large
201 <li class="PowSup"> #Vref_neg_absolute_val_too_small for Negative Vref too small
202 </ul>
203</td>
204</tr>
205<tr><td>Errors flags for VCC_PRE </td>
206<td>
207<span style="color:red;"> Da implementare</span>
208 <ul>
209 <li class="PowSup"> #VCC_PRE_pos_too_large for Positive supply for preamplifier too large
210 <li class="PowSup"> #VCC_PRE_pos_too_small for Positive supply for preamplifier too small
211 </ul>
212</td>
213</tr>
214<tr><td>Errors flags for VEE_PRE </td>
215<td>
216<span style="color:red;"> Da implementare</span>
217 <ul>
218 <li class="PowSup"> #VEE_PRE_absolute_val_too_large for Negative supply for preamplifier too large
219 <li class="PowSup"> #VEE_PRE_absolute_val_too_small for Negative supply for preamplifier too small
220 </ul>
221</td>
222</tr>
223<tr><td>Errors flags rotation for VCC_PGA </td>
224<td>
225<span style="color:red;"> Da implementare</span>
226 <ul>
227 <li class="PowSup"> #VCC_PGA_pos_too_large Positive supply for PGA too large
228 <li class="PowSup"> #VCC_PGA_pos_too_small for Positive supply for PGA too small
229 </ul>
230</td>
231</tr>
232<tr><td> Errors flags rotation for VEE_PGA </td>
233<td>
234<span style="color:red;"> Da implementare</span>
235 <ul>
236 <li class="PowSup"> #VEE_PGA_absolute_val_too_large for Negative supply for PGA too large
237 <li class="PowSup"> #VEE_PGA_absolute_val_too_small for Negative supply for PGA too small
238 </ul>
239</td>
240</tr>
241<tr><td> Errors flags for V__dig_5V </td>
242<td>
243<span style="color:red;"> Da implementare</span>
244<ul>
245 <li class="PowSup"> #V__dig_5V_val_too_large for Digital 5 V supply too large
246 <li class="PowSup"> #V__dig_5V_val_too_small for Digital 5 V supply too small
247 </ul>
248</td>
249</tr>
250<tr><td> Errors flags for V__dig_3e3V </td>
251<td>
252<span style="color:red;"> Da implementare</span>
253 <ul>
254 <li class="PowSup"> #V__dig_3e3V_val_too_large for Digital 3.3 V supply too large
255 <li class="PowSup"> #V__dig_3e3V_val_too_small for Digital 3.3 V supply too small
256 </ul>
257</td>
258</tr>
259</table>
260
261\n
262<!-- ------------------- error_address_I2C0/1 A --------------------------- -->
263<table style="width: 90%" >
264<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_I2C0
265and #error_address_I2C1 (errors with any I2C) </td></tr> \anchor flags_error_I2C
266<tr><td style="width: 15%">Trouble with I2C communication </td>
267<td style="width: 75%">
268<span style="color:red;"> parziale</span>
269 <ul>
270 <li class="I2C"> #I2C_Error_NONE it would be EVENT_TRANSFER_DONE. The definition from CMSIS is "ARM_I2C_" + "EVENT_TRANSFER_DONE"
271 <li class="I2C"> #I2C_Error_EVENT_TRANSFER_INCOMPLETE this and the following follows the rule above
272 <li class="I2C"> #I2C_Error_EVENT_SLAVE_TRANSMIT
273 <li class="I2C"> #I2C_Error_EVENT_SLAVE_RECEIVE
274 <li class="I2C"> #I2C_Error_EVENT_ADDRESS_NACK
275 <li class="I2C"> #I2C_Error_NONE this would be "ARM_I2C_" + "EVENT_GENERAL_CALL"
276 <li class="I2C"> #I2C_Error_EVENT_ARBITRATION_LOST
277 <li class="I2C"> #I2C_Error_EVENT_BUS_ERROR
278 <li class="I2C"> #I2C_Error_EVENT_BUS_CLEAR
279 </ul>
280</td>
281</tr>
282<tr><td> I2C Mux0 settings </td>
283<td>
284<span style="color:red;"> parziale</span>
285 <ul>
286 <li class="I2C"> #I2C_Error_I2C_mux I2C mux distribution error
287 </ul>
288</td>
289</tr>
290<tr><td> I2C to parallel conversion PCA9554 </td>
291<td>
292 <ul>
293 <li class="I2C"> #I2C_Error_I2C_to_parallel_PCA9554_0, I2C to parallel conversion ch0
294 <li class="I2C"> #I2C_Error_I2C_to_parallel_PCA9554_1, I2C to parallel conversion ch1
295 <li class="I2C"> #I2C_Error_I2C_to_parallel_PCA9554_2, I2C to parallel conversion ch2
296 <li class="I2C"> #I2C_Error_I2C_to_parallel_PCA9554_3, I2C to parallel conversion ch3
297 </ul>
298</td>
299</tr>
300<tr><td> Preamplifier trimmer </td>
301<td>
302 <ul>
303 <li class="I2C"> #I2C_Error_trimmer_0, trimmer ch0
304 <li class="I2C"> #I2C_Error_trimmer_1, trimmer ch1
305 <li class="I2C"> #I2C_Error_trimmer_2, trimmer ch2
306 <li class="I2C"> #I2C_Error_trimmer_3, trimmer ch3
307 <li class="I2C"> #I2C_Error_trimmer_4, trimmer ch4
308 <li class="I2C"> #I2C_Error_trimmer_5, trimmer ch5
309 </ul>
310</td>
311
312</tr>
313<tr><td> EPROM </td>
314<td>
315 <ul>
316 <li class="I2C"> #I2C_error_EPROM_0, EPROM ch0
317 <li class="I2C"> #I2C_error_EPROM_1, EPROM ch1
318 <li class="I2C"> #I2C_error_EPROM_2, EPROM ch2
319 <li class="I2C"> #I2C_error_EPROM_3, EPROM ch3
320 <li class="I2C"> #I2C_error_EPROM_4, EPROM ch4
321 <li class="I2C"> #I2C_error_EPROM_5, EPROM ch5
322 </ul>
323</td>
324
325</table>
326
327\n
328<!-- ------------------- error_address_I2C0/1 B --------------------------- -->
329<table style="width: 90%" >
330<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_I2C0_B
331and #error_address_I2C1_B (errors with any I2C) </td></tr> \anchor flags_error_I2C_B
332<tr><td style="width: 15%">Trouble with preamplifier thermometer </td>
333<td style="width: 75%">
334<span style="color:red;"> parziale</span>
335 <ul>
336 <li class="I2C_B"> #I2C_error_termometro_0, termometro ch0
337 <li class="I2C_B"> #I2C_error_termometro_1, termometro ch1
338 <li class="I2C_B"> #I2C_error_termometro_2, termometro ch2
339 <li class="I2C_B"> #I2C_error_termometro_3, termometro ch3
340 <li class="I2C_B"> #I2C_error_termometro_4, termometro ch4
341 <li class="I2C_B"> #I2C_error_termometro_5, termometro ch5
342 </ul>
343</td>
344</tr>
345
346</tr>
347<tr><td> Bias trimmer </td>
348<td>
349 <ul>
350 <li class="I2C_B"> #I2C_error_trimmer_bias_0, trimmer_bias ch0
351 <li class="I2C_B"> #I2C_error_trimmer_bias_1, trimmer_bias ch1
352 <li class="I2C_B"> #I2C_error_trimmer_bias_2, trimmer_bias ch2
353 <li class="I2C_B"> #I2C_error_trimmer_bias_3, trimmer_bias ch3
354 <li class="I2C_B"> #I2C_error_trimmer_bias_4, trimmer_bias ch4
355 <li class="I2C_B"> #I2C_error_trimmer_bias_5 trimmer_bias ch5
356 </ul>
357</td>
358
359</table>
360
361
362\n
363<!-- ------------------- error_SPI --------------------------- -->
364<table style="width: 90%" >
365<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_SPI </td></tr> \anchor flags_error_SPI
366<tr><td style="width: 15%">Trouble with SPI communication </td>
367<td style="width: 75%">
368<span style="color:red;"> parziale</span>
369 <ul>
370 <li class="SPI"> #SPI_error_NONE, this should be ARM_SPI_EVENT_TRANSFER_COMPLETE
371 <li class="SPI"> #SPI_error_EVENT_DATA_LOST, this is ARM_SPI_EVENT_DATA_LOST
372 <li class="SPI"> #SPI_error_EVENT_MODE_FAULT this is ARM_SPI_EVENT_MODE_FAULT
373 </ul>
374</td>
375</tr>
376</table>
377
378\n
379<!-- ------------------- error_address_CAN --------------------------- -->
380<table style="width: 90%" >
381<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_CAN (errors with CAN bus communication) </td></tr> \anchor flags_error_CAN
382<tr><td style="width: 15%"> Trouble with CAN communication </td>
383<td style="width: 75%">
384<span style="color:red;"> Da implementare</span>
385 <ul>
386 <li class="CAN"> #CAN_error_comunichiamo_qualche_dato_timeout_on_transmission (its value is 0) for Transmission CAN error
387 </ul>
388</td>
389</tr>
390</table>
391
392\n
393<!-- ------------------- error_preamplifier_down/up --------------------------- -->
394<table style="width: 90%" >
395<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_preamplifier_down and #error_preamplifier_up </td></tr> \anchor flags_error_preamplifier
396
397<tr><td style="width: 15%"> Trouble in temperature reading </td>
398<td style="width: 75%">
399<span style="color:red;"> Da implementare</span>
400 <ul>
401 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_0 for Preaamplifier temperature missed of CH0
402 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_1 for Preaamplifier temperature missed of CH1
403 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_2 for Preaamplifier temperature missed of CH2
404 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_3 for Preaamplifier temperature missed of CH3
405 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_4 for Preaamplifier temperature missed of CH4
406 <li class="preamplifier"> #preamplifier_Error_in_reading_temperature_5 for Preaamplifier temperature missed of CH5
407 </ul>
408</td>
409</tr>
410<tr><td> Troubles with reading preamplifier trimmer </td>
411<td>
412<span style="color:red;"> Da implementare</span>
413 <ul>
414 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_0 for Preaamplifier trimmer reading error CH0
415 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_1 for Preaamplifier trimmer reading error CH1
416 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_2 for Preaamplifier trimmer reading error CH2
417 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_3 for Preaamplifier trimmer reading error CH3
418 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_4 for Preaamplifier trimmer reading error CH4
419 <li class="preamplifier"> #preamplifier_Error_offset_not_accurate_5 for Preaamplifier trimmer reading error CH5
420 </ul>
421</td>
422</tr>
423<tr><td> Troubles with writing preamplifier trimmer </td>
424<td>
425<span style="color:red;"> Da implementare</span>
426 <ul>
427 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_0 for Preaamplifier trimmer writing error CH0
428 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_1 for Preaamplifier trimmer writing error CH1
429 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_2 for Preaamplifier trimmer writing error CH2
430 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_3 for Preaamplifier trimmer writing error CH3
431 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_4 for Preaamplifier trimmer writing error CH4
432 <li class="preamplifier"> #preamplifier_Error_with_its_trimmer_5 for Preaamplifier trimmer writing error CH5
433 </ul>
434</td>
435</tr>
436<tr><td> Troubles in writing the preamplifier EEPROMs </td>
437<td>
438<span style="color:red;"> parziale</span>
439 <ul>
440 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_0 for Preamplifier EEPROM writing error CH0
441 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_1 for Preamplifier EEPROM writing error CH1
442 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_2 for Preamplifier EEPROM writing error CH2
443 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_3 for Preamplifier EEPROM writing error CH3
444 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_4 for Preamplifier EEPROM writing error CH4
445 <li class="preamplifier"> #preamplifier_Error_with_its_EEPROM_5 for Preamplifier EEPROM writing error CH5
446 </ul>
447</td>
448</tr>
449</table>
450
451\n
452<!-- ------------------- error_address_CAN --------------------------- -->
453<table style="width: 90%" >
454<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_CAN (errors with CAN bus communication) </td></tr>
455<tr><td style="width: 15%"> Trouble with CAN communication </td>
456<td style="width: 75%">
457<span style="color:red;"> Da implementare</span>
458 <ul>
459 <li class="CAN"> #CAN_error_comunichiamo_qualche_dato_timeout_on_transmission (its value is 0) for Transmission CAN error
460 </ul>
461</td>
462</tr>
463</table>
464
465\n
466<!-- ------------------- #error_PGA_DetectorTrimmer --------------------------- -->
467<table style="width: 90%" >
468<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_PGA_DetectorTrimmer_down and #error_address_PGA_DetectorTrimmer_up </td></tr> \anchor flags_error_PGA_DetectorTrimmer
469<tr><td style="width: 15%"> Troubles with detector trimmer ommunication </td>
470<td style="width: 75%">
471<span style="color:red;"> Da implementare</span>
472 <ul>
473 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_0 for onboard trimmer error communication CH0
474 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_1 for onboard trimmer error communication CH1
475 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_2 for onboard trimmer error communication CH2
476 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_3 for onboard trimmer error communication CH3
477 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_4 for onboard trimmer error communication CH4
478 <li class="PGA_DetectorTrimmer"> #DetectorTrimmer_error_5 for onboard trimmer error communication CH5
479 </ul>
480</td>
481</tr>
482<tr><td style="width: 15%"> Troubles with PGA settings </td>
483<td style="width: 75%">
484<span style="color:red;"> Da implementare</span>
485 <ul>
486 <li class="PGA_DetectorTrimmer"> #PGA_error_0 for onboard trimmer error communication CH0
487 <li class="PGA_DetectorTrimmer"> #PGA_error_1 for onboard trimmer error communication CH1
488 <li class="PGA_DetectorTrimmer"> #PGA_error_2 for onboard trimmer error communication CH2
489 <li class="PGA_DetectorTrimmer"> #PGA_error_3 for onboard trimmer error communication CH3
490 <li class="PGA_DetectorTrimmer"> #PGA_error_4 for onboard trimmer error communication CH4
491 <li class="PGA_DetectorTrimmer"> #PGA_error_5 for onboard trimmer error communication CH5
492 </ul>
493</td>
494</tr>
495</table>
496
497\n
498<!-- ------------------- error_address_Bias_adjustment --------------------------- -->
499<table style="width: 90%" >
500<tr><td colspan="2"><span style="color:red;"> Register name:</span> #error_address_Bias_adjustment (detector bias errors) </td></tr> \anchor flags_error_Bias_Adj
501<tr><td style="width: 15%"> Final differential bias out of tolerance </td>
502<td style="width: 75%">
503<span style="color:red;"> Da implementare</span>
504 <ul>
505 <li class="Bias"> #Error_detector_realy_setting Error in setting any the relay
506 <li class="Bias"> #Final_bias_diff_not_accurate_0 (its value is 0) for detector bias setting out of tolerance CH0
507 <li class="Bias"> #Final_bias_diff_not_accurate_1 for detector bias setting out of tolerance CH1
508 <li class="Bias"> #Final_bias_diff_not_accurate_2 for detector bias setting out of tolerance CH2
509 <li class="Bias"> #Final_bias_diff_not_accurate_3 for detector bias setting out of tolerance CH3
510 <li class="Bias"> #Final_bias_diff_not_accurate_4 for detector bias setting out of tolerance CH4
511 <li class="Bias"> #Final_bias_diff_not_accurate_5 for detector bias setting out of tolerance CH5
512 </ul>
513</td>
514</tr>
515<tr><td> Final positive bias out of tolerance </td>
516<td>
517<span style="color:red;"> Da implementare</span>
518 <ul>
519 <li class="Bias"> #Final_bias_pos_not_accurate_0 for positive detector bias setting out of tolerance CH0
520 <li class="Bias"> #Final_bias_pos_not_accurate_1 for positive detector bias setting out of tolerance CH1
521 <li class="Bias"> #Final_bias_pos_not_accurate_2 for positive detector bias setting out of tolerance CH2
522 <li class="Bias"> #Final_bias_pos_not_accurate_3 for positive detector bias setting out of tolerance CH3
523 <li class="Bias"> #Final_bias_pos_not_accurate_4 for positive detector bias setting out of tolerance CH4
524 <li class="Bias"> #Final_bias_pos_not_accurate_5 for positive detector bias setting out of tolerance CH5
525 </ul>
526</td>
527</tr>
528<tr><td> Final negative bias out of tolerance </td>
529<td>
530<span style="color:red;"> Da implementare</span>
531 <ul>
532 <li class="Bias"> #Final_bias_neg_not_accurate_0 for negative detector bias setting out of tolerance CH0
533 <li class="Bias"> #Final_bias_neg_not_accurate_1 for negative detector bias setting out of tolerance CH1
534 <li class="Bias"> #Final_bias_neg_not_accurate_2 for negative detector bias setting out of tolerance CH2
535 <li class="Bias"> #Final_bias_neg_not_accurate_3 for negative detector bias setting out of tolerance CH3
536 <li class="Bias"> #Final_bias_neg_not_accurate_4 for negative detector bias setting out of tolerance CH4
537 <li class="Bias"> #Final_bias_neg_not_accurate_5 for negative detector bias setting out of tolerance CH5
538 <li class="Bias"> #Detector_bias_slopes_not_available since one or more channels have not the slope set
539 </ul>
540</td>
541</tr>
542<tr><td> Slopes not available </td>
543<td>
544 <ul>
545 <li class="Bias"> #Detector_bias_slopes_not_available since one or more channels have not the slope set
546 </ul>
547</td>
548</tr>
549</table>
550
551\n
552
553*\section error_managing_functions Error managing functions
554<hr width="90%" size="10" align="left">
555The user makes use of the function instr_ERROR_inspection_function() which is passed a parameter, via \b Byte6
556of the CAN instruction, tha can take one of the following 4 values:
557
558-# : this case the returned parameter is the address of the register where the last error has been detected;
559-# : the content of the register queried in the instruction is sent back;
560-# : the errors are all reset;
561-# : the state of the immidieate echos of errors, when verified. Note that the echos can be set ON or OFF by
562instr_ERROR_echo_on_off_function() via CAN bus.
563
564
565As an example, to verify the presence of negative bias adjustment error for CH2 we test true:
566\code{.c}
567Post_frontend_errors[error_address_Bias_adjustment] & ( 1 << Final_bias_pos_not_accurate_2)
568\endcode
569
570
571*\section error_anatomy Anatomy of errors
572<hr width="90%" size="10" align="left">
573
574There are 4 functions that are used in the fw to manage the errors:
575-# The first allows to set the error in the register; it is ERROR_codifica_errore()
576with input parameters: <i> uint8_t scheda_su_scheda_giu, unsigned char error_addres,
577unsigned char code_to_shift, uint8_t reset_count_se_0</i>
578in which <b><i> error_addres </i></b> is the address of the register, see sub-section \ref indirizzi, while <b><i> code_to_shift </i></b> is the position of the
579flag to set whitihn the register,
580see for this case the sub-section \ref flags. Here an axample of its use:
581\snippet I2C_mux.c error_example
582Note that ERROR_codifica_errore() set the flag whithin the register, but does not veirfy if the error has been
583generated. In the above example the presence of error is marked by #Error_bad_operation when different from zero.
584\n #Error_bad_operation is located whithin I2C_0_SignalEvent_t(), I2C_1_SignalEvent_t(), SPI_callback()
585to mark communication errors.
586\n #Error_bad_operation is not the only parameter to test for errors. As an instance, with CAN bus this
587other way is used:
588\snippet Preamplifier_Offset_Drift_Correcttion.c CAN error marker
589-# The second function is store_errors() that serves to push the whole registers.
590-# Then, the function restore_errors() pop's the whole regsiters.
591-# The function Error_imposta_la_istruzione() has to be located at the end of every instruction function to mark the error at Byte5, if present. If there is an error it
592sets the value 0xff at Byte5, if Byte5 is different from 0xff, otherwise it sets 0xfa.
593
594
595<hr width="90%" size="10" align="left">
596\sa The instructions to manage errors via CAN bus are \ref instr_ERROR_inspection_option "instr_ERROR_inspection" and
597\ref instr_ERROR_echo_on_off_option "instr_ERROR_echo_on_off".
598
599 */
600
601#include "tutti_gli_header.h"
602
603volatile unsigned int flag_error_verified=0; //! Alla verifica di un qualsiasi errore questo flag viene incrementato, 0 implica nessun errore
604volatile unsigned int flag_error_verified_at_startup=0; //! Alla verifica di un qualsiasi errore allo startup questo flag viene posto ad 1, 0 altrimenti
605volatile unsigned char flag_error_acknowledged=0 ; //! Il flag di errore veirifcato e tutti gli errori vengono resettati perch\'e acquisiti
606volatile unsigned char last_error_address=0; //! The address of the last verified error
607volatile unsigned char last_code_to_shift=0; //! The shift bit of the last error
608volatile unsigned char last_error_address_at_startup=0; //! The address of the last verified error
609volatile unsigned char last_code_to_shift_at_startup=0; //! The shift bit of the last error
610volatile unsigned char can_send_error=0; //! Error are notified via can if =1; not notified if =0
611
612
613 // Post_frontend_errors is a vector that account of all the possible errors that can take place.
614 //Every element of this vector referes to a subject. Every bit of the element individuates the error.
615 // The subjects, the indexes, are liste below.
616 //! \snippet Error_handling.c vec_Post_frontend_errors
617//! <!-- [vec_Post_frontend_errors] -->
618 unsigned int Post_frontend_errors[error_number_of_errors_registers+error_offset_for_board_up]; ///< Vector that lists the flag registers.
619 //First half for board down, second half for board up
620//! <!-- [vec_Post_frontend_errors] --> ///
621 unsigned int Post_frontend_errors_copy[error_number_of_errors_registers+error_offset_for_board_up]; ///< Copy of #Post_frontend_errors, the vector that lists the flag registers
622 ///
623volatile uint32_t Error_good_operation;
624volatile uint32_t Error_bad_operation; //!< this is a global variable present in all the communication interrupt functions, I2C, SPI,...
625 //!< exploited to mark the errors
626
627 char flag_error_verified_vecchio;
628 unsigned char last_error_address_vecchio;
629
630#define usa_la_struttura
631// #undef usa_la_struttura
632
633 #ifdef usa_la_struttura
634
635//error_definition_def error_register_per_flag_ADC[5]={"ADC not responding to SPI", //0
636// "ADC RDY pin not responding to measure", //1
637// "VREF out of tolerance", //2
638// "errore 4",
639// "errore 5"
640// };
641
642//all_errors_def all_errors[]={
643// "errore 1",
644// "errore 2",
645// "errore 3",
646// "errore 4",
647// "errore 5"
648//};
649
650/*! \brief If an error is found its flag is codified here.
651
652The errors are 32 bit flag regsiters. The bits that are 1 indicates that the corresponding error was verified.
653*\param[in] scheda_su_scheda_giu : 0 if down board, 1 if up board
654*\param[in] error_addres : is the address of the register where the flag is found. The address to be passed is that of the down board.
655 The actual address is dependent on the scheda_su_scheda_giu value;
656*\param[in] code_to_shift : is the posistion of the error flag within the register;
657*\param[in] reset_count_se_0 : if 0 a rest of all errors is done and the registration of errors starts from now
658
659*\return No params
660
661*\snippet Error_handling.c fun_ERROR_codifica_errore
662*/
663//! <!-- [fun_ERROR_codifica_errore] -->
664void ERROR_codifica_errore(uint8_t scheda_su_scheda_giu, unsigned char error_addres, unsigned char code_to_shift, uint8_t reset_count_se_0 ){
665 //if error_addres is >= error_number_of_errors_registers nothing is done, but the reset, if reset_count_se_0 is =0
666 uint8_t iii, buffer_instruction[8],actual_error_address=error_addres;
667 if(scheda_su_scheda_giu) actual_error_address=error_addres + error_offset_for_board_up;
668// if (scheda_su_scheda_giu) scheda_su_scheda_giu=1;
669// error_addres += scheda_su_scheda_giu;
670
671 if( reset_count_se_0 ==0){ // Verifichiamo solo gli errori che capitano da ora.
672 store_errors();
674 Error_good_operation=0;
675 flag_error_verified=0;
677 Post_frontend_errors[actual_error_address]=0;
678 }
679 if (( code_to_shift ==0) && ( (error_address_I2C0 == error_addres) | (error_addres == error_address_I2C1) | (error_addres == error_address_SPI) )){
680 __NOP();
681 }else {
682 if( reset_count_se_0 > 0 ){ //if error_addres is >= error_number_of_errors_registers nothing is
683 //done, but the reset, if reset_count_se_0 is =0
684 if (~( Post_frontend_errors[actual_error_address] & (1 << code_to_shift))) //Error is set only if it happens for the first time
685 {
686 Post_frontend_errors[actual_error_address] |= (1 << code_to_shift);
687 flag_error_verified++;
688 last_error_address= actual_error_address ;
689 last_code_to_shift=code_to_shift;
690 }
691 if (can_send_error) {
692 for( iii=0;iii<8;iii++){
693 buffer_instruction[iii]=tx_data[iii];
694 }
695 tx_data[5]= actual_error_address; //The register where the error is confined
696 tx_data[6]= 1; //This must be "1" and says that the node voltage read must be returned here
697 tx_data[7]= instr_ERROR_echo_on_off ; //instr code
698 tx_msg_info.id = ARM_CAN_EXTENDED_ID(indirizzo_CAN_della_scheda);
699 CANdrv->MessageSend(tx_obj_idx, &tx_msg_info, tx_data, 8U);//msg to CAN back to the control room
700 Aspetta_tanti_ms(100); //From here we wait the answer or generate an error
701 for( iii=0;iii<8;iii++){
702 tx_data[iii]=buffer_instruction[iii];
703 }
704 }
705 }
706 }
707}
708//! <!-- [fun_ERROR_codifica_errore] -->
709
710/*! \brief The state of the errors can be verified/reset
711*\param[in] what_to_answer
712\n 1: the answer is error present/not present,
713\n 2: the error regsister indicated in data[0] of CANbus message is sent,
714\n 3: reset all errors,
715\n 4: the state of echo of errors, ON/OFF.
716*\return is according to the requested action: last_error_address, error_register, can_send_error, the echo state ON/OFF
717
718*\snippet Error_handling.c fun_instr_ERROR_inspection_function
719*/
720//! <!-- [fun_instr_ERROR_inspection_function] -->
722 char ii;
723 volatile uint8_t istruzione = vettore_istruzioni[6];
724 #define check_for_presence_of_erros ( uint8_t) 1
725 #define send_back_the_register ( uint8_t) 2
726 #define reste_all_errors ( uint8_t) 3
727 #define quering_echo_on_or_off ( uint8_t) 4
728
729 switch (istruzione & 0x7F){
730 case check_for_presence_of_erros:
732 tx_data[1]= flag_error_verified;
733 break;
734 case send_back_the_register:
735 tx_data[5]= rx_data[0];
736 tx_data[0]= (Post_frontend_errors[tx_data[5]]>>0) & 0xff;
737 tx_data[1]= (Post_frontend_errors[tx_data[5]]>>8) & 0xff;
738 tx_data[2]= (Post_frontend_errors[tx_data[5]]>>16) & 0xff;
739 tx_data[3]= (Post_frontend_errors[tx_data[5]]>>24) & 0xff;
740 break;
741 case reste_all_errors:
742 flag_error_verified=0;
746 {
747 Post_frontend_errors[ii] = 0;
748 }
749 break;
750 case quering_echo_on_or_off:
752 break;
753 }
754}
755//! <!-- [fun_instr_ERROR_inspection_function] -->
756
757
758
759/*! \brief Copy all errors in a buffer
760*\No_par
761
762*\snippet Error_handling.c fun_store_errors
763*/
764//! <!-- [fun_store_errors] -->
765void store_errors (void){
766 uint8_t i;
767 flag_error_verified_vecchio += flag_error_verified;
768 last_error_address_vecchio = last_error_address;
769 flag_error_verified = 0;
770 for (i=0; i<error_number_of_errors_registers; i++)
771 {
773 }
774}
775//! <!-- [fun_store_errors] -->
776
777/*! \brief Re-store all errors from the buffer
778*\No_par
779*\snippet Error_handling.c fun_restore_errors
780*/
781//! <!-- [fun_restore_errors] -->
782void restore_errors (void){
783 uint8_t ii;
784
785 for (ii=0; ii<error_number_of_errors_registers; ii++)
786 {
788 }
789 flag_error_verified = flag_error_verified_vecchio;
790 last_error_address = last_error_address_vecchio;
791}
792//! <!-- [fun_restore_errors] -->
793
794
795/*! \brief Immediate echos of a verified error activated/disattivated.
796*\param[in] channel_input
797\n 0: errors are not notified on the CAN when they happen;
798\n 1: errors are notified immidiately by a can message when they happen
799*\retval can_send_error the replica of the inp
800
801*\snippet Error_handling.c fun_instr_ERROR_echo_on_off_function
802*/
803//! <!-- [fun_instr_ERROR_echo_on_off_function] -->
805{
806if ( vettore_istruzioni[0]){
808}else{
810}
811
812}
813//! <!-- [fun_instr_ERROR_echo_on_off_function] -->
814
815/*! \brief Function to be located at the end of every instruction to mark the error, if any
816*\retval marking of byte5 of the CAN replica
817
818*\snippet Error_handling.c fun_Error_imposta_la_isturzione
819*/
820//! <!-- [fun_Error_imposta_la_isturzione] -->
822 if(flag_error_verified){
823 if( tx_data[5]==255){
824 tx_data[5]=250;
825 }else{
826 tx_data[5]= 255;
827 }
828 }
829}
830//! <!-- [fun_Error_imposta_la_isturzione] -->
831
832#endif
@ instr_ERROR_echo_on_off
if enabled, echo of the error via CAN as soon as the error is verified
uint8_t tx_data[8]
Transmission data vector.
Definition: Can.c:321
uint32_t tx_obj_idx
This is the variable which resembles the flags from the communication.
Definition: Can.c:323
unsigned int indirizzo_CAN_della_scheda
Per ora lo assegnamo cos\i l'indirizzo della scheda.
Definition: Can.c:335
volatile uint8_t rx_data[8]
Received data vector.
Definition: Can.c:318
ARM_DRIVER_CAN * CANdrv
Definition: Can.c:333
void store_errors(void)
Copy all errors in a buffer.
unsigned int Post_frontend_errors[error_number_of_errors_registers+error_offset_for_board_up]
Error are notified via can if =1; not notified if =0.
void Error_imposta_la_istruzione(void)
Function to be located at the end of every instruction to mark the error, if any.
unsigned int Post_frontend_errors_copy[error_number_of_errors_registers+error_offset_for_board_up]
///
volatile unsigned char can_send_error
The shift bit of the last error.
volatile uint32_t Error_bad_operation
exploited to mark the errors
void instr_ERROR_inspection_function(void)
The state of the errors can be verified/reset.
volatile unsigned char last_code_to_shift
The address of the last verified error.
volatile unsigned char last_code_to_shift_at_startup
The address of the last verified error.
void ERROR_codifica_errore(uint8_t scheda_su_scheda_giu, unsigned char error_addres, unsigned char code_to_shift, uint8_t reset_count_se_0)
If an error is found its flag is codified here.
volatile unsigned int flag_error_verified_at_startup
Alla verifica di un qualsiasi errore questo flag viene incrementato, 0 implica nessun errore.
volatile unsigned char last_error_address
Il flag di errore veirifcato e tutti gli errori vengono resettati perch\'e acquisiti.
void instr_ERROR_echo_on_off_function(void)
Immediate echos of a verified error activated/disattivated.
void restore_errors(void)
Re-store all errors from the buffer.
volatile unsigned char flag_error_acknowledged
Alla verifica di un qualsiasi errore allo startup questo flag viene posto ad 1, 0 altrimenti.
volatile unsigned char last_error_address_at_startup
The shift bit of the last error.
@ error_address_I2C0
Error register A for I2C0.
@ error_offset_for_board_up
=15, First addresss for board up errors
@ error_address_I2C1
Error register A for I2C1
@ error_address_SPI
Error register for SPI.
@ error_number_of_errors_registers
Number of errors (this is not an addres)
void Aspetta_tanti_ms(int millisecondi)
The timing function.
Definition: Timer.c:52
volatile int8_t vettore_istruzioni[8]
This is a copy of the received 8 bytes from the CAN.