Xmega IEC60730 Class B Library  1.0
 All Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
classb_sram.h
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
2 /**
3  * \file
4  *
5  * \brief Settings for the SRAM test.
6  *
7  * \par Application note:
8  * AVR1610: Guide to IEC60730 Class B compliance with XMEGA
9  *
10  * \par Documentation
11  * For comprehensive code documentation, supported compilers, compiler
12  * settings and supported devices see readme.html
13  *
14  * \author
15  * Atmel Corporation: http://www.atmel.com \n
16  * Support email: avr@atmel.com
17  *
18  * Copyright (C) 2012 Atmel Corporation. All rights reserved.
19  *
20  * \page License
21  *
22  * Redistribution and use in source and binary forms, with or without
23  * modification, are permitted provided that the following conditions are met:
24  *
25  * 1. Redistributions of source code must retain the above copyright notice,
26  * this list of conditions and the following disclaimer.
27  *
28  * 2. Redistributions in binary form must reproduce the above copyright notice,
29  * this list of conditions and the following disclaimer in the documentation
30  * and/or other materials provided with the distribution.
31  *
32  * 3. The name of Atmel may not be used to endorse or promote products derived
33  * from this software without specific prior written permission.
34  *
35  * 4. This software may only be redistributed and used in connection with an
36  * Atmel AVR product.
37  *
38  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
39  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
40  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
41  * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
42  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
43  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
44  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
45  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
46  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
47  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
48  * DAMAGE.
49  */
50 
51 #ifndef _SRAM_H_
52 #define _SRAM_H_
53 
54 
55 //! \defgroup classb_sram Internal SRAM Test
56 //!
57 //! \brief This self-diagnostic test checks the internal SRAM memory for coupling faults.
58 //!
59 //! The test \ref classb_sram_test() divides the internal SRAM into \ref CLASSB_NSECS sections that are
60 //! tested in turns with a March algorithm (see \ref marchx). The simplest behavior of the test
61 //! is when there is no overlap between memory sections. In this case all sections have the same
62 //! size, except possibly the last one (see \ref CLASSB_NSECS). The first memory section (referred to as
63 //! the buffer) is reserved: it is used by the test to store the content of the other sections
64 //! while they are being tested (for more details see \ref classb_buffer).
65 //!
66 //! If there is overlap (see \ref CLASSB_OVERLAP), every time a memory section is tested a part of the
67 //! previous section is tested as well. Note that this does not apply to the buffer, since it is
68 //! the first section. The size of the buffer is then expanded with respect to the previous case.
69 //! Further, the size of the second section is decreased correspondingly.
70 //!
71 //! If there should be an error in internal SRAM the error handler \ref CLASSB_ERROR_HANDLER_SRAM()
72 //! would be called.
73 //!
74 //! \note Interrupts must be disabled during this test.
75 //!
76 //! \section marchx March X
77 //!
78 //! The chosen algorithm is <em>March X</em>. This consists on the following steps:
79 //! \f[ \Updownarrow (w_\textbf{D}); \Uparrow(r_\textbf{D}, w_\bar{\textbf{D}}); \Downarrow (r_\bar{\textbf{D}}, w_\textbf{D}); \Updownarrow (r_\textbf{D}) \;,\f]
80 //! where \f$w\f$ denotes a write operation, \f$r\f$ denotes a read operation,
81 //! \f$\textbf{D}\f$ is any data background, \f$\bar{\textbf{D}}\f$ is the complement
82 //! of \f$\textbf{D}\f$ and the arrows refer to the addressing order. In our implementation
83 //! we have chosen \f$\textbf{D} = \text{0x00}\f$.
84 //!
85 //! Under the restricted coupling faults (CFs) model, the interleaved organization of the memory
86 //! in XMEGA avoids any kind of intra-word CFs. However, in order to detect some intra-word CFs
87 //! that are not considered by this fault model, we have included the following optional march
88 //! element:
89 //! \f[ \Updownarrow (w_\textbf{D_0}, r_\textbf{D_0} \ldots w_\textbf{D_d}, r_\textbf{D_d}) \;,\f]
90 //! where the background sequence is \f$\text{{0x00, 0xFF, 0x55, 0xAA, 0x33, 0xCC, 0x0F, 0xF0}}\f$.
91 //! This intra-word test is only executed if \ref CLASSB_SRAM_INTRAWORD_TEST is defined. The elements
92 //! that correspond to the first two data backgrounds are redundant because the first part of the
93 //! test includes them. This optional test will detect all intra-word state CFs considered by the
94 //! unrestricted CF model.
95 //!
96 //!
97 //@{
98 
99 //! \name Configuration settings
100 //@{
101 
102 //! \brief Number of sections the SRAM is divided into for testing.
103 //!
104 //! It is advisable that \c INTERNAL_SRAM_SIZE is divisible by the number of
105 //! sections and, therefore, recommended values are 2, 4, 8, 16, etc. Otherwise an extra
106 //! section will be added with the remainder of the division as size. Note that the higher
107 //! the number of sections the smaller the size of \ref classb_buffer, i.e. the section of memory
108 //! that is reserved for the test) and the faster each partial test is completed.
109 #define CLASSB_NSECS 8
110 
111 /**
112  * \brief Overlap between memory sections (in % of \c CLASSB_SEC_SIZE).
113  *
114  * This should be an unsigned long, i.e. <val>UL.
115  */
116 #define CLASSB_OVERLAP 25UL
117 
118 #ifdef __DOXYGEN__
119  //! \brief If defined an intra-word test will be added after the inter-word test.
120  //!
121  //! Given the layout of the memory, the probability of intra-word coupling faults
122  //! is greatly diminished. However, for extra safety the test can be expanded to
123  //! check some intra word coupling faults.
124  #define CLASSB_SRAM_INTRAWORD_TEST
125 #else
126 // #define CLASSB_SRAM_INTRAWORD_TEST
127 #endif
128 //@}
129 
130 
131 //! \internal
132 //! \name Constants that are automatically computed.
133 //@{
134 //!\internal The size of each segment in bytes
135 #define CLASSB_SEC_SIZE (INTERNAL_SRAM_SIZE / CLASSB_NSECS)
136 
137 //! \internal The size of the last segment in bytes (when \c INTERNAL_SRAM_SIZE is not divisible by \ref CLASSB_NSECS)
138 #define CLASSB_SEC_REM (INTERNAL_SRAM_SIZE % CLASSB_NSECS)
139 
140 //! \internal Size of overlap in bytes. When testing a memory section, the algorithm starts \c CLASSB_OVERLAP_SIZE
141 //! bytes behind the start of the section.
142 #define CLASSB_OVERLAP_SIZE (CLASSB_SEC_SIZE*CLASSB_OVERLAP)/100
143 
144 //! \internal Total number of segments, including remainder if present.
145 #if (CLASSB_SEC_REM == 0)
146 # define CLASSB_NSEC_TOTAL CLASSB_NSECS
147 #else
148 # define CLASSB_NSEC_TOTAL CLASSB_NSECS + 1
149 #endif
150 //@}
151 
152 //! \name Class B Test
153 //@{
154 void classb_sram_test( void );
155 //@}
156 
157 //! \internal\name March X Algorithm
158 //@{
159 void classb_marchX(register volatile uint8_t * p_sram, register volatile uint8_t * p_buffer, register uint16_t size);
160 //@}
161 
162 
163 //@}
164 #endif