Class B Safety Software Library PDF
Class B Safety Software Library PDF
INTRODUCTION
This application note describes the Class B Safety
Software Library routines that detect the occurrence of
Faults in a single channel CPU. These routines have
been developed in accordance with the IEC 60730
standard to support the Class B certification process.
These routines can be directly integrated with the end
users application to test and verify the critical
functionalities of a controller without affecting the end
users application.
This application note also describes the Application
Programming Interface (API) functions that are
available in the Class B Safety Software Library.
The Class B safety software routines can be called
periodically at start-up or run time to test the following
components:
CPU Registers
CPU Program Counter
Invariable Memory
Variable Memory
Clock
Interrupt Handling and Execution
The author thanks the International Electrotechnical Commission (IEC) for permission to reproduce information from its
International Standard IEC 60730-1ed.3.2
(2007). All such extracts are copyright of
IEC, Geneva, Switzerland. All rights
reserved. Further information on the IEC is
available from www.iec.ch. IEC has no
responsibility for the placement and context in which the extracts and contents are
reproduced by the author, nor is IEC in any
way responsible for the other content or
accuracy therein.
DS01229C-page 1
AN1229
SYSTEM REQUIREMENTS
The
CPU
Register
test
implements
the
functional test H.2.16.5 defined by the IEC 60730
standard. It detects stuck-at Faults in the CPU registers.
This ensures that the bits in the registers are not stuck at
a value 0 or 1; this is a non-destructive test.
2.
3.
API FUNCTIONS
The following API functions implement the CPU
Register test:
SSL_8bit_CPU_RegisterTest (PIC10/12/16)
SSL_8bitsFamily_CPU_RegisterTest (PIC18)
SSL_16bitsFamily_CPU_RegisterTest
SSL_32bitsFamily_CPU_RegisterTest
DS01229C-page 2
AN1229
Program Counter Test
The Program Counter (PC) test implements the functional test H.2.16.5 defined by the IEC 60730 standard.
The PC holds the address of the next instruction to be
executed.
The test performs the following major tasks:
1.
2.
3.
4.
API FUNCTIONS
The following API functions implement the PC test:
SSL_8bit_PCtest (PIC10/12/16)
SSL_8bitsFamily_PCtest (PIC18)
SSL_16bitsFamily_PCtest
SSL_32bitsFamily_PCtest
EXAMPLE 1:
DS01229C-page 3
AN1229
Invariable Memory (Flash/EEPROM) Test
1.
2.
3.
4.
5.
API FUNCTIONS
The following API functions implement the Invariable
Memory test:
SSL_8bit_EEPROMtest_CRC16 (PIC10/12/16)
SSL_8bitsFamily_EEPROMtest_CRC16 (PIC18)
SSL_8bitsFamily_Flashtest_CRC16 (PIC18)
SSL_16bitsFamily_Flashtest_CRC16
SSL_16bitsFamily_EEPROMtest_CRC16
SSL_32bitsFamily_Flashtest_CRC16
Note:
FIGURE 1:
No
CRCFlag == 0
Yes
Yes
No
Fail/Errors Found
End
DS01229C-page 4
AN1229
Variable Memory Test
FIGURE 2:
order.
: Arranges the address sequence in descending
order.
: Arranges the address sequence in either
memory cell).
r 1 : Indicates a read operation (reads 1 from a
memory cell).
w 0 : Indicates a write operation (writes 0 to a
MARCH TEST
A March test performs a finite set of operations on
every memory cell in a memory array. Each operation
performs the following tasks:
1.
2.
3.
4.
memory cell).
w 1 : Indicates a write operation (writes 1 to a
memory cell).
Note:
SSL_8bitsFamily_RAM_STACKtest_MarchC (PIC18)
SSL_16bitsFamily_RAM_STACKtest_MarchC
SSL_32bitsFamily_RAM_STACKtest_MarchC
DS01229C-page 5
AN1229
MARCH C TEST
API FUNCTIONS
Stuck-at Fault
Addressing Fault
Transition Fault
Coupling Fault
SSL_8bit_RAMtest_MarchC (PIC10/12/16)
SSL_8bitsFamily_RAMtest_MarchC (PIC18)
SSL_8bitsFamily_RAM_STACKtest_MarchC (PIC18)
SSL_16bitsFamily_RAMtest_MarchC
SSL_16bitsFamily_RAM_STACKtest_MarchC
SSL_32bitsFamily_RAMtest_MarchC
SSL_32bitsFamily_RAM_STACKtest_MarchC
FIGURE 3:
MARCH C ALGORITHM
MarchC
{
( w0 );
( r 0 , w 1 );
( r 1 , w0 );
( r 0 );
( r 0 , w 1 );
( r 1 , w0 );
(r 0)
EXAMPLE 2:
for(i=0;i<=(n-1);i++)
x(i)=0;
for(i=0;i<=(n-1);i++)
{
if (x(i)==0)
x(i) =1;
else
return fail;
}
for(i=0;i<=(n-1);i++)
{
if(x(i)==1)
x(i)=0;
else
return fail;
}
for(i=(n-1);i>=0;i--)
{
if(x(i)==0)
x(i)=1;
else
return fail;
}
for(i=(n-1);i>=0;i--)
{
if(x(i)==1)
x(i)=0;
else
return fail;
for(i=(n-1);i>=0;i--)
{
if(x(i)==0) {}
else
return fail
}
return pass;
DS01229C-page 6
AN1229
MARCH C MINUS TEST
API FUNCTIONS
Stuck-at Fault
Addressing Fault
Transition Fault
Coupling Fault
functions
implement
the
SSL_8bit_RAMtest_MarchC_Minus (PIC10/12/16)
SSL_8bitsFamily_RAMtest_MarchC_Minus (PIC18)
SSL_16bitsFamily_RAMtest_MarchC_Minus
SSL_32bitsFamily_RAMtest_MarchC_Minus
FIGURE 4:
MARCH C MINUS
ALGORITHM
MarchCMinus
{
( w0 );
( r 0 , w 1 );
( r 0 , w 1 );
( r 1 , w0 );
( r 1 , w0 );
( r 0 );
DS01229C-page 7
AN1229
MARCH B TEST
API FUNCTIONS
Stuck-at
Linked Idempotent Coupling
Inversion Coupling
FIGURE 5:
MARCH B ALGORITHM
March B
{
( w0 ); ( r 0, w1, r 1, w 0, r 0, w1); ( r 1 , w0, w1 );
( r 1, w0, w1, w 0); ( r 0 , w1, w0);
}
DS01229C-page 8
SSL_8bit_RAMtest_MarchB (PIC10/12/16)
SSL_8bitsFamily_RAMtest_MarchB (PIC18)
SSL_16bitsFamily_RAMtest_MarchB
SSL_32bitsFamily_RAMtest_MarchB
Note 1: The user application should allocate
appropriate space for the stack before
executing any of the March tests (see the
details in the specific API function
description). The stack must be allocated
at an appropriate address so that it does
not get overwritten during the test
execution.
2: Depending on the architecture, it is recommended that the stack be placed at the
beginning or at the end of the data memory. The user application should specify
an address such that it does not overlap
other statically allocated resources (e.g.,
the MPLAB ICD 2 RAM space or other
debugger used RAM space).
AN1229
EXAMPLE 3:
for(i=0;i<=(n-1);i++)
x(i)=0;
for(i=0;i<=(n-1);i++)
{
if(x(i)=0)
x(i)=1;
else
return fail;
if(x(i)==1)
x(i)=0;
else
return fail;
if(x(i)==0)
x(i)=1;
else
return fail;
}
for(i=0;i<=(n-1);i++)
{
if(x(i)==1)
{
x(i)=0;
x(i)=1;
}
else
return fail;
}
for(i=(n-1);i>=0;i--)
{
if(x(i)=1)
{
x(i)=0;
x(i)=1;
x(i)=0;
}
else
return fail;
}
for(i=(n-1);i>=0;i--)
{
if(x(i)==0)
{
x(i)=1;
x(i)=0;
}
else
return fail;
}
return pass;
DS01229C-page 9
AN1229
CHECKERBOARD RAM TEST
The Checkerboard RAM test writes the checkerboard
patterns to a sequence of adjacent memory locations.
This test is performed in units (memory chunks) of architecture-specific sizes (2 bytes for 8-bit architecture, 4
bytes for 16-bit architecture, 64 bytes for 32-bit architecture). This is a non-destructive memory test.
This test performs the following major tasks:
1.
2.
3.
4.
5.
Clock Test
According to the IEC 60730 standard, only harmonics
and subharmonics of the clock need to be tested. The
Clock test implements the independent time slot monitoring H.2.18.10.4 defined by the IEC 60730 standard. It
verifies the reliability of the system clock (i.e., the system
clock should be neither too fast nor too slow):
Depending on the choice of the reference clock, one of
the following Clock tests can be used:
Clock Test Using the Secondary Oscillator (SOSC)
Clock Test Using the Line Frequency
(50 Hz, 60 Hz)
API FUNCTIONS
The following API functions
Checkerboard RAM test:
implement
the
SSL_8bit_RAMtest_CB (PIC10/12/16)
SSL_8bitsFamily_RAM_CB_test (PIC18)
SSL_16bitsFamily_RAMtest_CheckerBoard
SSL_32bitsFamily_RAMtest_CheckerBoard
1.
2.
Interrupt Test
The Interrupt test implements the independent time slot
monitoring H.2.18.10.4 defined by the IEC 60730
standard. It checks whether the number of interrupts
that occurred is within the predefined range.
The goal of the Interrupt test is to verify that interrupts
occur regularly. The Interrupt test function can be
invoked at specified time intervals. It is triggered by a
timer or line frequency interrupt to monitor and verify
the interrupt operation.
To keep track of the interrupts that occur frequently, a
dedicated counter in each ISR can be decremented
when an interrupt occurs. For example, if the Serial
Peripheral Interface (SPI) is configured to generate an
interrupt every 2 ms, the SPI will generate at least five
interrupts in 10 ms. When a SPI interrupt occurs, the
counter dedicated to keep track of the SPI interrupt is
decremented. Thus, if the counter is initialized to five,
the counter is decremented to zero in 10 ms. This is
verified by the Interrupt test function that is triggered
after every 10 ms.
DS01229C-page 10
3.
4.
API FUNCTIONS
The following API functions implement the Clock test:
SSL_8bitsFamily_CLOCKtest (PIC18)
SSL_16bitsFamily_CLOCKtest
SSL_32bitsFamily_CLOCKtest
AN1229
CLOCK TEST USING THE LINE FREQUENCY
(50 Hz, 60 Hz)
2.
3.
4.
FIGURE 6:
API FUNCTIONS
The following API functions implement the Clock test:
API Functions for 8-bit PIC MCUs (PIC18)
SSL_16bitsFamily_CLOCKtest_LineFreq
SSL_32bitsFamily_CLOCKtest_LineFreq
V2
TMR2 or
TMR3
V3
V1
V4
ICx
Capture
Event
Capture
Interrupt
(ICI<1:0> = 01)
Read Captured
Value in ISR
Read Captured
Value in ISR
Capture FIFO
Note:
V1
xxxx
xxxx
xxxx
V1
V2
xxxx
xxxx
V3
V2
xxxx
xxxx
V3
V4
xxxx
xxxx
1st Capture
2nd Capture
3rd Capture
4th Capture
DS01229C-page 11
AN1229
Addressing of Variable and Invariable
Memory and Internal Data Path
For single chip microcontrollers or digital signal
controllers, such as PIC MCUs and dsPIC DSCs, the
Periodic Static Memory test is used to test the variable
memory, and the periodic checksum is used to test the
invariable memory. These tests detect any stuck-at
Fault in the internal address bus and internal data path.
Timing
The PIC MCUs and dsPIC DSCs have several
dedicated communication interfaces, such as UART,
I2C and SPI modules. The IEC 60730 Class B
specifications suggest that these modules should use
time slot monitoring to ensure that the communication
occurs at the correct point in time.
Plausibility Check
Addressing Wrong Address
This test is required only for microcontrollers with an
external memory device.
External Communication
The IEC 60730 Class B specifications suggest the
following measures to ensure reliable communication
between components:
TRANSFER REDUNDANCY
The transfer redundancy is a Fault/error control
technique that protects against coincidental and/or
systematic errors in the input and output information. It
is achieved by transferring the data between the transmitter and receiver. The data is transferred at least
twice in succession and then compared.
PROTOCOL TEST
The Protocol test is a Fault/error control technique in
which the data is transferred to and from the computer
components to detect errors in the internal
communication protocol.
DS01229C-page 12
I/O PERIPHERY
The plausibility check on an I/O pin can be performed
by toggling the I/O and checking the state of the pin.
ANALOG MULTIPLEXER
To verify the operation of the analog multiplexer, known
voltage values are applied to all channels. These
values are read and compared with the applied voltage
for verification.
A/D CONVERTER
To test the analog functions of the A/D converter, a
known external voltage is applied to the analog inputs.
The conversion results are then compared with the
applied voltage.
SSL_8bit_CPU_RegisterTest
SSL_8bit_PCtest
SSL_8bit_EEPROMtest_CRC16
SSL_8bit_RAMtest_MarchC
SSL_8bit_RAMtest_MarchC_Minus
SSL_8bit_RAMtest_MarchB
AN1229
SSL_8bit_CPU_RegisterTest
Description
This function implements the CPU Register test. The test successively writes the values 0x55 and 0xAA into the registers and then reads the values from these registers for verification. The function returns an error code if the values do
not match. The contents of the register (W0) that returns the error code are not preserved. The contents of the CPU
register to be tested is saved on a temporary register before executing the routine and is restored upon the completion
of the test.
Include
None.
Prototype
int SSL_8bit_CPU_RegisterTest(void);
Arguments
None.
Return Value
REGISTER_TEST_FAIL
REGISTER_TEST_PASS
Return value = 0
Return value = 1
Remarks
None.
Source File
None.
TABLE 1:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
77 words
Stack
NONE
Execution Time
81 cycles
DS01229C-page 13
AN1229
SSL_8bit_PCtest
Description
This function implements the PC test, which is a functional test of the PC. The test invokes the functions that are located
in the Flash memory at different addresses. The SSL_ProgCounterTest.h header file defines the addresses, where
these functions reside in the Flash memory. The functions placed at these addresses return a unique value, which is
the starting address of the called function. This returned value is verified using the SSL_8bit_PCtest function.
Include
SSL_ProgCounterTest.h
Prototype
unsigned int SSL_8bit_PCtest(void);
Arguments
None.
Return Value
PC_TEST_FAIL
Return value = 0
PC_TEST_PASS
Return value = 1
Remarks
None.
TABLE 2:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
107 words
Stack
1 byte
Execution Time
92 cycles
DS01229C-page 14
AN1229
SSL_8bit_EEPROMtest_CRC16
Description
This function implements the Invariable Memory test. It computes the CRC of the data located between the address,
EEPROM_STARTADDRESS, and the address, EEPROM_ENDADDRESS. This function returns the final CRC value.
Include
SSL_EEPROM_CRC.h
Prototype
unsigned int SSL_8bits_EEPROMtest_CRC16(unsigned char startAddress,unsigned char endAddress)
Arguments
startAddress
endAddress
Return Value
Holds the CRC result
crc_Result
Remarks
None.
Source File
None.
TABLE 3:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
149 words
Stack
1 byte
Execution Time
1091 cycles(1)
Note 1:
DS01229C-page 15
AN1229
SSL_8bit_RAMtest_MarchC
Description
This function implements the March C test. This test accesses an 8-bit word from the RAM memory. The address must
be aligned to the data type and the length must be an integral multiple of the data width. This is a destructive test;
therefore, this test can be executed at the system start-up before initializing the memory and the run-time libraries. The
memory will be cleared when the control returns from the SSL_8bit_RAMtest_MarchC function.
Include
SSL_MarchCRamTest.h
Prototype
unsigned char SSL_8bit_RAMtest_MarchC(void);
Arguments
None.
Return Value
MARCHC_RAM_TEST_FAIL
Return value = 0
MARCHC_RAM_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_MarchCRamTest.c
TABLE 4:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
388 bytes
Stack
15 bytes
Execution Time
3834 cycles(1)
Note 1:
DS01229C-page 16
AN1229
SSL_8bit_RAMtest_MarchC_Minus
Description
This function implements the March C Minus test. This test accesses an 8-bit word from the RAM memory. The address
must be aligned to the data type and the length must be an integral multiple of the data width. This is a destructive test;
therefore, this test can be executed at the system start-up before initializing the memory and the run-time libraries. The
memory will be cleared when the control returns from the SSL_8bit_RAMtest_MarchCMinus function.
Include
SSL_MarchCMInusRamTest.h
Prototype
unsigned char SSL_8bit_RAMtest_MarchCMinus(void);
Arguments
None.
Return Value
MARCHC_RAM_TEST_FAIL Return value = 0
MARCHC_RAM_TEST_PASS Return value = 1
Remarks
None.
Source File
SSL_MarchCMinusRamTest.c
TABLE 5:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
269 bytes
Stack
10 bytes
Execution Time
3834 cycles(1)
Note 1:
DS01229C-page 17
AN1229
SSL_8bit_RAMtest_MarchB
Description
This function implements the March B test. This test accesses a byte word from the RAM memory. The address must
be properly aligned to the data type and the length must be an integral multiple of the data width. This is a destructive
test; therefore, this test can be executed at system start-up before initializing the memory and the run-time library. The
memory will be cleared when the control returns from the SSL_8bit_RAMtest_MarchB function.
Include
SSL_MarchBRamTest.h
Prototype
unsigned char SSL_8bit_RAMtest_MarchB(void);
Arguments
None.
Return Value
MARCHB_RAM_TEST_FAIL
Return value = 0
MARCHB_RAM_TEST_PASS
Return value = 1
Source File
SSL_MarchBRamTest.c
TABLE 6:
RESOURCE REQUIREMENTS
Parameter
Program Memory
Requirements
453 bytes
Stack
Execution Time
Note 1:
2761 cycles(1)
DS01229C-page 18
AN1229
API FUNCTIONS FOR 8-BIT PIC MCUs
(PIC18)
This section lists and describes the API functions that
are available in the Class B Safety Software Library for
the 8-bit architecture. The functions are listed below
followed by their individual detailed descriptions:
SSL_8bitsFamily_CPU_RegisterTest
SSL_8bitsFamily_PCtest
SSL_8bitsFamily_Flashtest_CRC16
SSL_8bitsFamily_EEPROMtest_CRC16
SSL_8bitsFamily_RAM_STACKtest_MarchC
SSL_8bitsFamily_RAMtest_MarchC_Minus
SSL_8bitsFamily_RAMtest_MarchB
SSL_8bitsFamily_RAMtest_CheckerBoard
SSL_8bitsFamily_CLOCKtest
SSL_8bitsFamily_CLOCKtest_LineFreq
DS01229C-page 19
AN1229
SSL_8bitsFamily_CPU_RegisterTest
Description
This function implements the CPU Register test. The test successively writes the values 0x55 and 0xAA into the registers and then reads the values from these registers for verification. The function returns an error code if the values do
not match. The contents of the register (W0) that returns the error code are not preserved. The contents of the CPU
register to be tested is saved on a temporary register before executing the routine and is restored upon the completion
of the test.
Include
None.
Prototype
void SSL_8bitsFamily_CPU_RegisterTest(void);
Arguments
None.
Return Value
REGISTER_TEST_FAIL
REGISTER_TEST_PASS
Remarks
None.
Source File
None.
TABLE 7:
RESOURCE REQUIREMENTS
Parameter
Program Memory
Requirements
77 words
Stack
NONE
Execution Time
81 cycles
DS01229C-page 20
AN1229
SSL_8bitsFamily_PCtest
Description
This function implements the PC test, which is a functional test of the PC. The test invokes the functions that are located
in the Flash memory at different addresses. The SSL_PcTest.h header file defines the addresses, where these functions
reside in the Flash memory. The functions placed at these addresses return a unique value, which is the starting address
of the called function. This returned value is verified using the SSL_8bitsFamily_PCtest function.
Include
SSL_PcTest.h
Prototype
int SSL_8bitsFamily_PCtest(void);
Arguments
None.
Return Value
PC_TEST_FAIL
Return value = 0
PC_TEST_PASS
Return value = 1
Remarks
None.
TABLE 8:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
107 words
Stack
1 byte
Execution Time
92 cycles
DS01229C-page 21
AN1229
SSL_8bitsFamily_Flashtest_CRC16
Description
This function implements the Invariable Memory test. It computes the CRC of the data located between the address
FLASH_STARTADDRESS and the address FLASH_ENDADDRESS. This function returns the final CRC value.
Include
SSL_Flash_CRC.h
Prototype
unsigned int SSL_8bitsFamily_Flashtest_CRC16
(word32 startAddress,word32 endAddress, unsigned int crc_Result);
ARGUMENTS
startAddress
endAddress
crc_Result
Return Value
Holds the CRC result
crc_Result
Remarks
None.
TABLE 9:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
489 bytes
Stack
70 bytes
Execution Time
446 cycles(1)
Note 1:
The execution time specified here is for a single Flash memory location.
DS01229C-page 22
AN1229
SSL_8bitsFamily_EEPROMtest_CRC16
Description
This function implements the Invariable Memory test. It computes the CRC of the data located between the address,
EEPROM_STARTADDRESS, and the address, EEPROM_ENDADDRESS. This function returns the final CRC value.
Include
SSL_EEPROM_CRC.h
Prototype
unsigned int SSL_8bitsFamily_EEPROMtest_CRC16(uReg32 startAddress, uReg32 endAddress,
unsigned int crc_Result);
Arguments
startAddress
endAddress
crc_Result
Return Value
Holds the CRC result
crc_Result
Remarks
None.
Source File
None.
TABLE 10:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
149 words
Stack
1 byte
Execution Time
1091 cycles(1)
Note 1:
DS01229C-page 23
AN1229
SSL_8bitsFamily_RAMtest_MarchC
Description
This function implements the March C test. This test accesses an 8-bit word from the RAM memory. The address must
be aligned to the data type and the length must be an integral multiple of the data width. This is a destructive test;
therefore, this test can be executed at the system start-up before initializing the memory and the run-time libraries. The
memory will be cleared when the control returns from the SSL_8bitsFamily_RAMtest_MarchC function.
Include
SSL_MarchC.h
Prototype
int SSL_8bitsFamily_RAMtest_MarchC(char * ramStartAddress,int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_TEST_FAIL
Return value = 0
MARCHC_RAM_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_MarchCRamTest.c
TABLE 11:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
388 bytes
Stack
15 bytes
Execution Time
3834 cycles(1)
Note 1:
DS01229C-page 24
AN1229
SSL_8bitsFamily_RAM_STACKtest_MarchC
Description
This function implements the March C test on the RAM memory and stack. This test accesses an 8-bit word from the
RAM memory. The address must be aligned to the data type and the length must be an integral multiple of the data
width. It first tests the RAM memory and then the stack area by transferring the stack contents into the tested RAM area.
After the stack is tested, it restores the contents of the stack. This is a destructive test; therefore, this test can be
executed at system start-up before initializing the memory and the run-time libraries. The memory will be cleared when
the control returns from the SSL_8bitsFamily_RAM_STACKtest_MarchC function.
Include
SSL_MarchC_RamAndStackTest.h
Prototype
int SSL_8bitsFamily_RAM_STACKtest_MarchC(char * ramStartAddress, unsigned int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_STACK_TEST_FAIL
Return value = 0
MARCHC_RAM_STACK_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_MarchCRamAndStackTest.c
TABLE 12:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
890 bytes
Stack
88 bytes
Execution Time
1576 cycles(1)
Note 1:
DS01229C-page 25
AN1229
SSL_8bitsFamily_RAMtest_MarchC_Minus
Description
This function implements the March C test on the RAM memory and stack. This test accesses an 8-bit word from the
RAM memory. The address must be aligned to the data type and the length must be an integral multiple of the data
width. It first tests the RAM memory and then the stack area by transferring the stack contents into the tested RAM area.
After the stack is tested, it restores the contents of the stack. This is a destructive test; therefore, this test can be
executed at system start-up before initializing the memory and the run-time libraries. The memory will be cleared when
the control returns from the SSL_8bitsFamily_RAM_STACKtest_MarchCMinus function.
Include
SSL_MarchC_Minus.h
Prototype
int SSL_8bitsFamily_RAMtest_MarchC_Minus(char * ramStartAddress, int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_TEST_FAIL
Return value = 0
MARCHC_RAM_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_RamTest_MarchCMinus.c
TABLE 13:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
124 bytes
Stack
15 bytes
Execution Time
1402 cycles
DS01229C-page 26
AN1229
SSL_8bitsFamily_RAMtest_MarchB
Description
This function implements the March B test. This test accesses a byte word from the RAM memory. The address must
be properly aligned to the data type and the length must be an integral multiple of the data width. This is a destructive
test; therefore, this test can be executed at system start-up before initializing the memory and the run-time library. The
memory will be cleared when the control returns from the SSL_8bitsFamily_RAMtest_MarchB function.
Include
SSL_MarchB.h
Prototype
int SSL_8bitsFamily_RAMtest_MarchB(char * ramStartAddress, int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March B algorithm starts
reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even
number
Return Value
MARCHB_TEST_FAIL
Return value = 0
MARCHB_TEST_PASS
Return value = 1
Source File
SSL_MarchBRamTest.c
TABLE 14:
RESOURCE REQUIREMENTS
Parameter
Program Memory
Requirements
453 bytes
Stack
Execution Time
Note 1:
2761 cycles(1)
DS01229C-page 27
AN1229
SSL_8bitsFamily_RAMtest_CheckerBoard
Description
This function implements the Checkerboard test on the RAM memory. The test is performed on the memory space
specified by the variable, SIZE. The execution begins from the address defined by the variable, START_RAM. The number
of specified locations must be even.
Include
SSL_CheckerBoardTest.INC
Prototype
unsigned char SSL_8bitsFamily_Ram_CB_test(void);
Arguments
None.
Return Value
RAM_Test_Fail
RAM_Test_Pass
Remarks
None.
Source File
SSL_CheckerBoard.asm
TABLE 15:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
321 bytes
Stack
68 bytes
Execution Time
43 cycles(1)
Note 1:
DS01229C-page 28
AN1229
SSL_8bitsFamily_CLOCKtest
Description
This function implements the Clock test. It is used to verify the proper operation of the CPU clock. The TMR0 value of
Timer0 is saved within the Timer1 interrupt handler. This value represents the number of CPU clock cycles elapsed in
1 ms time period of the SOSC. If the number of clock cycles is beyond the defined boundary, the function sets an error
flag.
This test performs the following major tasks:
1.
2.
3.
4.
The LP secondary oscillator is used as an independent clock source or a reference clock source. This 32 kHz
oscillator is used to clock Timer1.
The POSC with Phase-Locked Loop (PLL) is the clock source to the CPU. Timer0 runs at the CPU clock
frequency.
Timer1 is configured to generate an interrupt at specified time intervals (e.g., 1 ms).
The TMR0 value of Timer0 is saved within the Timer1 interrupt handler. This value represents the number of CPU
clock cycles elapsed in the 1 ms time period of the SOSC. If the number of clock cycles is beyond the defined
boundary, the function sets an error flag.
For example, the following parameters are used to calculate the CLK_MIN_TIME and CLK_MAX_TIME values for a
PIC18F device:
Therefore, with 4% tolerance, the number of CPU clock cycles in 1ms (2000 cycles) are:
CLK_MIN_TIME: 1920
CLK_MAX_TIME: 2080
Include
SSL_ClockTest.h
Prototype
unsigned int SSL_8bitsFamily_CLOCKtest(void);
Arguments
None.
Return Value
CLOCK_NO_ERROR
Return value = 1
CLOCK_ERROR
Return value = 0
Remarks
None.
DS01229C-page 29
AN1229
SSL_8bitsFamily_CLOCKtest(Continued)
Source File
SSL_ClockTest.c
TABLE 16:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
DS01229C-page 30
AN1229
SSL_8bitsFamily_CLOCKtest_LineFreq
Description
This function implements the line frequency Clock test. It is used to verify the proper operation of the CPU clock. It uses
the following procedure to configure the IC1CON register:
1.
2.
3.
The IC1 pin generates an interrupt after every 20 ms if the line frequency is 50 Hz and after every 16.66 ms if the line
frequency is 60 Hz. Timer1 is configured in such a way so that the timer count does not time-out within 20 ms/16.66 ms.
The capture event is generated on every rising edge of the line frequency. For period measurement, the capture interrupt is generated twice and Timer1 count is stored in the 2nd interrupt routine.
If the number of clock cycles is beyond the defined boundary, the function sets an error flag.
For example, the following parameters are used to calculate CLK_MIN_TIME and CLK_MAX_TIME for a PIC18F device:
The number of counts that will be counted in the 20ms is = 0.02 * 2000000 = 40000. With a tolerance of 4%
CLK_MIN_TIME: 38400
CLK_MAX_TIME: 41600
Include
SSL_ClockTest_LineFreq.h
Prototype
int SSL_8bitsFamily_CLOCKtest_LineFreq(void);
Arguments
None.
Return Value
CLOCK_NO_ERROR
Return value = 1
CLOCK_ERROR
Return value = 0
Remarks
None.
Source File
SSL_ClockTest_LineFreq.c
TABLE 17:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
DS01229C-page 31
AN1229
API FUNCTIONS FOR 16-BIT PIC
MCUs AND dsPIC DSCs
This section lists and describes the API functions that
are available in the Class B Safety Software Library for
16-bit architecture. The API functions are listed below
followed by their individual detailed descriptions:
SSL_16bitsFamily_CPU_RegisterTest
SSL_16bitsFamily_PCtest
SSL_16bitsFamily_Flashtest_CRC16
SSL_16bitsFamily_EEPROMtest_CRC16
SSL_16bitsFamily_RAMtest_MarchC
SSL_16bitsFamily_RAMtest_MarchC_Minus
SSL_16bitsFamily_RAMtest_MarchB
SSL_16bitsFamily_RAMtest_CheckerBoard
SSL_16bitsFamily_CLOCKtest
SSL_16bitsFamily_CLOCKtest_LineFreq
DS01229C-page 32
AN1229
SSL_16bitsFamily_CPU_RegisterTest
Description
This function implements the CPU Register test. The test successively writes the values 0x5555 and 0xAAAA into the
CPU registers and then reads the values from these registers for verification. The function returns an error code if the
values do not match. The contents of the register (W0) that returns the error code are not preserved. The contents of
the CPU registers to be tested are saved on the stack before executing the routine and are restored upon the completion
of the test.
Include
None.
Prototype
int SSL_16bitsFamily_CPU_RegisterTest();
Arguments
None.
Return Value
CPU_REGISTER_TEST_FAIL
CPU_REGISTER_TEST_PASS
Return value = 0
Return value = 1
Remarks
None.
Source File
None.
TABLE 18:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
58 bytes (dsPIC30F/dsPIC33F/dsPIC33E)
24 bytes (PIC24H/PIC24F/PIC24E)
Execution Time
DS01229C-page 33
AN1229
SSL_16bitsFamily_PCtest
Description
This function implements the PC test, which is a functional test of the PC. The test invokes the functions that are located
in the Flash memory at different addresses. The customized linker script defines the addresses, where these functions
reside in the Flash memory. The functions placed at these addresses return a unique value, which is the starting address
of the called function. This returned value is verified using the SSL_16bitsFamily_PCtest function.
Include
SSL_PcTest.h
Prototype
SSL_16bitsFamily_PCtest();
Arguments
None.
Return Value
PC_TEST_FAIL
Return value = 0
PC_TEST_PASS
Return value = 1
Remarks
None.
TABLE 19:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
258 bytes
Stack
28 bytes
Execution Time
32 cycles
DS01229C-page 34
AN1229
SSL_16bitsFamily_Flashtest_CRC16
Description
This function implements the Invariable Memory test. It computes the CRC of the data located between the address
FLASH_STARTADDRESS and the address FLASH_ENDADDRESS. This function returns the final CRC value.
Include
SSL_Flash_CRC.h
Prototype
unsigned int SSL_16bitsFamily_Flashtest_CRC16
(uReg32 startAddress,uReg32 endAddress, unsigned int init_CrcValue);
ARGUMENTS
startAddress
endAddress
init_CrcValue
Return Value
Holds the CRC result
crc_Result
Remarks
None.
TABLE 20:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
489 bytes
Stack
70 bytes
Execution Time
446 cycles(1)
Note 1:
The execution time specified here is for a single Flash memory location.
DS01229C-page 35
AN1229
SSL_16bitsFamily_EEPROMtest_CRC16
Description
This function implements the Invariable Memory test. It computes the CRC of the data located between the address,
EEPROM_STARTADDRESS, and the address, EEPROM_ENDADDRESS. This function returns the final CRC value.
Include
SSL_EEPROM_CRC.h
Prototype
unsigned int SSL_16bitsFamily_EEPROMtest_CRC16
(uReg32 startAddress,uReg32 endAddress ,unsigned int init_CrcValue);
Arguments
startAddress
endAddress
init_CrcValue
Return Value
Holds the CRC result
crc_Result
Remarks
None.
Source File
None.
TABLE 21:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
492 bytes
Stack
70 bytes
Execution Time
348 cycles(1)
Note 1:
DS01229C-page 36
AN1229
SSL_16bitsFamily_RAMtest_MarchC
Description
This function implements the March C test. This test accesses a 16-bit word from the RAM memory. The address must
be aligned to the data type and the length must be an integral multiple of the data width. This is a destructive test;
therefore, this test can be executed at the system start-up before initializing the memory and the run-time libraries. The
memory will be cleared when the control returns from the SSL_16bitsFamily_RAMtest_MarchC function.
Include
SSL_MarchC.h
Prototype
int SSL_16bitsFamily_RAMtest_MarchC(int * ramStartAddress,int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_TEST_FAIL
Return value = 0
MARCHC_RAM_TEST_PASS
Return value = 1
Remarks
None.
Note 1: The user application should allocate 0x50 bytes for the stack before executing any of the March tests. The
stack must be allocated at an appropriate address so that it does not get overwritten during test execution.
2: It is recommended that the stack be placed at the beginning or at the end of the data memory. The user
application should specify an address that does not overlap other statically allocated resources (e.g., the
MPLAB ICD 2 RAM space, which starts from the address 0x800).
3: The following changes are made to the .gld file before executing the March B or March C test:
.stack 0x850: /*Stack Starting Address\*
{
__SP_init = .;
. += 0x50; /* Stack length*/
__SPLIM_init = .;
. += 8;
} >data
Source File
SSL_MarchCRamTest.c
TABLE 22:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
585 bytes
Stack
88 bytes
Execution Time
1254 cycles(1)
Note 1:
DS01229C-page 37
AN1229
SSL_16bitsFamily_RAM_STACKtest_MarchC
Description
This function implements the March C test on the RAM memory and stack. This test accesses a 16-bit word from the
RAM memory. The address must be aligned to the data type and the length must be an integral multiple of the data
width. It first tests the RAM memory and then the stack area by transferring the stack contents into the tested RAM area.
After the stack is tested, it restores the contents of the stack. This is a destructive test; therefore, this test can be
executed at system start-up before initializing the memory and the run-time libraries. The memory will be cleared when
the control returns from the SSL_16bitsFamily_RAM_STACKtest_MarchC function.
Include
SSL_MarchC.h
Prototype
int SSL_16bitsFamily_RAM_STACKtest_MarchC(int * ramStartAddress,int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_STACK_TEST_FAIL
Return value = 0
MARCHC_RAM_STACK_TEST_PASS
Return value = 1
Remarks
None.
Note 1: The user application should allocate 0x50 bytes for the stack before executing any of the March tests. The
stack must be allocated at an appropriate address so that it does not get overwritten during test execution.
2: It is recommended that the stack be placed at the beginning or at the end of the data memory. The user
application should specify an address that does not overlap other statically allocated resources (e.g., the
MPLAB ICD 2 RAM space which starts from the address 0x800).
3: The following changes are made to the .gld file before executing the March B or March C test:
.stack 0x850: /*Stack Starting Address\*
{
__SP_init = .;
. += 0x50; /* Stack length*/
__SPLIM_init = .;
. += 8;
} >data
Source File
SSL_MarchCRamAndStackTest.c
TABLE 23:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
890 bytes
Stack
88 bytes
Execution Time
1576 cycles(1)
Note 1:
DS01229C-page 38
AN1229
SSL_16bitsFamily_RAMtest_MarchC_Minus
Description
This function implements the March C test on the RAM memory and stack. This test accesses a 16-bit word from the
RAM memory. The address must be aligned to the data type and the length must be an integral multiple of the data
width. It first tests the RAM memory and then the stack area by transferring the stack contents into the tested RAM area.
After the stack is tested, it restores the contents of the stack. This is a destructive test; therefore, this test can be
executed at system start-up before initializing the memory and the run-time libraries. The memory will be cleared when
the control returns from the SSL_16bitsFamily_RAMtest_MarchC_Minus function.
Include
SSL_MarchC_Minus.h
Prototype
int SSL_16bitsFamily_RAMtest_MarchC_Minus(int * ramStartAddress,int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March C algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHC_RAM_TEST_FAIL
Return value = 0
MARCHC_RAM_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_MarchC_MinusRamTest.c
TABLE 24:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
381 bytes
Stack
30 bytes
Execution Time
122 cycles(1)
Note 1:
DS01229C-page 39
AN1229
SSL_16bitsFamily_RAMtest_MarchB
Description
This function implements the March B test. This test accesses a 16-bit word from the RAM memory. The address must
be properly aligned to the data type and the length must be an integral multiple of the data width. This is a destructive
test; therefore, this test can be executed at system start-up before initializing the memory and the run-time library. The
memory will be cleared when the control returns from the SSL_16bitsFamily_RAMtest_MarchB function.
Include
SSL_MarchB.h
Prototype
int SSL_16bitsFamily_RAMtest_MarchB(int * ramStartAddress,int ramSize);
Arguments
ramStartAddress
Indicates the starting address from where the March B algorithm starts reading the data
ramSize
Indicates the number of bytes that are tested; the size must be an even number
Return Value
MARCHB_TEST_FAIL
Return value = 0
MARCHB_TEST_PASS
Return value = 1
Remarks
None.
Note 1: The user application should allocate 0x50 bytes for the stack before executing any of the March tests. The
stack must be allocated at an appropriate address so that it does not get overwritten during test execution.
2: It is recommended that the stack should be placed at the beginning or at the end of the data memory. The
user application should specify an address such that it does not overlap other statically allocated resources
(e.g., the MPLAB ICD 2 RAM space which starts from the address 0x800).
3: The following changes are made to the .gld file before executing the March B or March C test:
.stack 0x850: /*Stack Starting Address\*
{
__SP_init = .;
. += 0x50; /* Stack length*/
__SPLIM_init = .;
. += 8;
} >data
Source File
SSL_MarchBRamTest.c
TABLE 25:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
630 bytes
Stack
88 bytes
Execution Time
1183 cycles(1)
Note 1:
DS01229C-page 40
AN1229
SSL_16bitsFamily_RAMtest_CheckerBoard
Description
This function implements the Checkerboard test on the RAM memory. The test is performed on the memory space
specified by the variable, RamSize. The execution begins from the address defined by the variable, RAMSTARTADDRESS.
The number of specified locations must be even.
Include
SSL_CBram.h
Prototype
int SSL_16bitsFamily_RAMtest_CheckerBoard(int *ramStartAddress,int RamSize);
Arguments
RamStartAddress
Indicates the starting address from where the Checkerboard test is to be performed
RamSize
Indicates the number of locations that are tested; the size must be an even number
Return Value
CB_TEST_FAIL
Return value = 0
CB_TEST_PASS
Return value = 1
Remarks
None.
Source File
SSL_CheckerBoard.s
TABLE 26:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
321 bytes
Stack
68 bytes
Execution Time
43 cycles(1)
Note 1:
DS01229C-page 41
AN1229
SSL_16bitsFamily_CLOCKtest
Description
This function implements the Clock test. It is used to verify the proper operation of the CPU clock. The TMR2 value of
Timer2 is saved within the Timer1 interrupt handler. This value represents the number of CPU clock cycles elapsed in
1 ms time period of the SOSC. If the number of clock cycles is beyond the defined boundary, the function sets an error
flag.
This test performs the following major tasks:
1.
2.
3.
4.
5.
The LP secondary oscillator is used as an independent clock source or a reference clock source. This 32 kHz
oscillator is used to clock Timer1.
The POSC with Phase-Locked Loop (PLL) is the clock source to the CPU. Timer2 runs at the CPU clock
frequency.
Timer1 is configured to generate an interrupt at specified time intervals (e.g., 1 ms).
The PR2 register in the Timer2 module holds the time period value. It must be initialized to a value greater than
1 ms so that Timer2 does not time out before the occurrence of a Timer1 interrupt.
The TMR2 value of Timer2 is saved within the Timer1 interrupt handler. This value represents the number of CPU
clock cycles elapsed in the 1 ms time period of the SOSC. If the number of clock cycles is beyond the defined
boundary, the function sets an error flag.
For example, the following parameters are used to calculate the CLK_MIN_TIME and CLK_MAX_TIME values for a
dsPIC30F device:
POSC: XT_PLL8
FOSC: 7.37 MHz * 8
FCY: FOSC/4: (7.37 * 10^6 * 8)/4
FCY: 14740000
SOSC: 32 kHz
Timer1 Period Register (PR1): 31
Therefore, with 4% tolerance, the number of CPU clock cycles in 1 ms (14740 cycles) are:
CLK_MIN_TIME: 14150
CLK_MAX_TIME: 15330
Include
SSL_ClockTest.h
SSL_ClockSwitch.h
Prototype
unsigned int SSL_16bitsFamily_CLOCKtest(void);
Arguments
None.
Return Value
CLOCK_NO_ERROR
CLOCK_ERROR
Remarks
None.
DS01229C-page 42
AN1229
SSL_16bitsFamily_CLOCKtest(Continued)
Source File
SSL_ClockTest.c
TABLE 27:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
387 bytes
Stack
8 bytes
Execution Time
30 cycles
DS01229C-page 43
AN1229
SSL_16bitsFamily_CLOCKtest_LineFreq
Description
This function implements the line frequency Clock test. It is used to verify the proper operation of the CPU clock. It uses
the following procedure to configure the IC1CON register:
1.
2.
3.
The IC1 pin generates an interrupt after every 20 ms if the line frequency is 50 Hz and after every 16.66 ms if the line
frequency is 60 Hz. The Timer2 prescaler is configured to operate in 1:8 mode so that the timer count does not time-out
within 20 ms/16.66 ms. The capture event is generated on every rising edge of the line frequency. For period measurement, the capture interrupt is generated after taking two time-stamps, V1 and V2 (see Figure 6). The total number of
clock cycles is calculated using the following formula:
Total Number of Clock Cycles = Timer Count * Timer Prescaler.
If the number of clock cycles is beyond the defined boundary, the function sets an error flag.
Include
SSL_ClockTest_LineFreq.h
SSL_ClockSwitch.h
Prototype
int SSL_16bitsFamily_CLOCKtest_LineFreq();
Arguments
None.
Return Value
CLOCK_NO_ERROR
CLOCK_ERROR
Remarks
None.
Source File
SSL_ClockTest_LineFreq.c
TABLE 28:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
447 bytes
Stack
12 bytes
Execution Time
25 cycles
DS01229C-page 44
AN1229
32-BIT API FUNCTIONS FOR 32-BIT
PIC MCUs
This section lists and describes the API functions that
are available in the PIC32MX Class B Safety Software
Library for the 32-bit architecture. The functions are
listed below followed by their individual detailed
descriptions:
SSL_32bitsFamily_CPU_RegisterTest
SSL_32bitsFamily_PCtest
SSL_32bitsFamily_Flashtest_CRC16
SSL_32bitsFamily_RAMtest_MarchC
SSL_32bitsFamily_RAM_STACKtest_MarchC
SSL_32bitsFamily_RAMtest_MarchC_Minus
SSL_32bitsFamily_RAMtest_MarchB
SSL_32bitsFamily_RAMtest_CheckerBoard
SSL_32bitsFamily_CLOCKtest
SSL_32bitsFamily_CLOCKtest_LineFreq
DS01229C-page 45
AN1229
SSL_32bitsFamily_CPU_RegisterTest
Description
This function implements the CPU Register test. First it tests the register 0 to have all bits cleared. For all the other
registers (1 to 31) the test successively writes the values 0x55555555 and 0xAAAAAAAA into the corresponding CPU
register, and then reads the values from the register for verification. The function returns an error code if the values do
not match.
Include
SSL_CpuRegisterTest.h
Prototype
int SSL_32bitsFamily_CPU_RegisterTest(void);
Arguments
None.
Return Value
CPU_REGISTER_TEST_FAIL
The test failed. Some CPU register(s) has been detected to have stuck bits
CPU_REGISTER_TEST_PASS
The test passed. CPU registers have not been detected to have stuck bits
Remarks
This is a non-destructive test. Interrupts should be disabled when calling this test function.
The standard C language call convention applies regarding the registers usage (refer to Section 5.6 Function Calling
Convention in the MPLAB C Compiler For PIC32 MCUs Users Guide (DS51686)).
Upon the function entry, all registers that need to be preserved are saved into the stack. These registers are restored
upon completion of the test. Upon the function return, the register v0 will contain the return code.
Source File
SSL_CPURegisterTest.S
TABLE 29:
RESOURCE REQUIREMENTS
Parameter
Program Memory
Requirements
2156 bytes
Stack
44 bytes
Execution Time
Note 1:
2:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states,
zero RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled.
The co-processor 0 (CP0) registers are not tested by this function. These registers are configuration and
status registers and modifying their values could adversely affect the system behavior at run time.
DS01229C-page 46
AN1229
SSL_32bitsFamily_PCtest
Description
This function implements the PC test, which is a functional test of the PC. It checks that the PC register is not stuck and
it properly holds the address of the next instruction to be executed.
The test invokes the functions that are located in Flash memory at different addresses. The functions placed at these
addresses return a unique value, which is the starting address of the called function. This returned value is verified using
the SSL_32bitsFamily_PCtest function.
The provided customized linker script, elf32pic32mx.ld, defines the addresses where these functions reside in
Flash memory.
Include
SSL_PcTest.h
Prototype
int SSL_32bitsFamily_PCtest(void);
Arguments
None.
Return Value
PC_TEST_FAIL
The test failed. The PC register has been detected to hold an incorrect address.
PC_TEST_PASS
Remarks
The test uses three different functions:
SSL_TestPCFunction1()
SSL_TestPCFunction2()
SSL_TestPCFunction3()
The ROM location of these functions that are used for PC test at run time can be changed by modifying the provided
elf32pic32mx.ld file.
The elf32pic32mx.ld linker script file should be added to the project.
Source File
TABLE 30:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states,
zero RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build:
MPLAB C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 47
AN1229
SSL_32bitsFamily_Flashtest_CRC16
Description
This function calculates the 16-bit CRC of the supplied memory area using the standard Linear Feedback Shift Register
(LFSR) implementation.
It calculates the CRC over the memory area between the start address and end address and returns the CRC Value.
The 16-bit CRC is calculated using the supplied generator polynomial and initial seed. Different generator polynomials
can be selected.
Include
SSL_Flash_CRC.h
Prototype
unsigned int SSL_32bitsFamily_Flashtest_CRC16(char* startAddress, char* endAddress,
unsigned int crcPoly, unsigned int crcSeed);
Arguments
startAddress
endAddress
crcPoly
crcSeed
The initial value in the CRC LFSR. The usual recommended value is 0xFFFF.
Return Value
The value of the calculated CRC over the specified memory area.
Remarks
This test is non-destructive for the memory area to which it is applied.
The start address and end address over which the CRC value is calculated are PIC32 variant and applicationdependent.
They are run-time parameters.
Source File
SSL_FlashTest_CRC16.c
TABLE 31:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states,
zero RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build:
MPLAB C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 48
AN1229
SSL_32bitsFamily_RAMtest_MarchC
Description
This function implements the March C test. This test performs 32-bit word RAM accesses. The address of the RAM area
to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4.
The tested RAM memory will be cleared when the control returns from the SSL_32bitsFamily_RAMtest_MarchC
function.
Include
SSL_MarchC.h
Prototype
int SSL_32bitsFamily_RAMtest_MarchC(int* ramStartAddress, int ramSize);
Arguments
ramStartAddress
Start address from which the March C test is to be performed. Must be properly 32-bit
aligned.
ramSize
Number of consecutive byte locations for which the test is to be performed. The size must
be a number multiple of 4.
Return Value
MARCHC_TEST_PASS
The test passed. RAM area tested has not been detected to have Faults
MARCHC_TEST_FAIL
The test failed. Some RAM area location has been detected to have Faults.
Remarks
This is a destructive memory test. The test must not be performed over the RAM areas that have to be preserved;
otherwise, these RAM areas must be saved/restored before/after running the test.
Alternatively the test could be run at system start-up before the memory and the run time library is initialized; however,
the stack must be initialized.
At least 100 bytes should be available for the stack for executing the March C test. The tested RAM area must not
overlap the stack.
Other statically allocated resources such as the MPLAB ICD or REAL ICE allocated RAM buffers should be excluded
from this test.
The start address from which the March C test is to be performed and the size of the RAM area are PIC32 variant and
application-dependent. They are run-time parameters.
Source File
SSL_MarchCRamTest.c
TABLE 32:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states, zero
RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build: MPLAB
C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 49
AN1229
SSL_32bitsFamily_RAM_STACKtest_MarchC
Description
This function implements the March C test on both a RAM and a stack area.
First the RAM area is tested using the standard March C test. If the test succeeded the requested Stack area is copied
into the RAM area that has just been tested and then the March C test is run over the Stack area as if it were a regular
RAM area. The saved Stack area is restored and the result of the test is returned to the user.
This test performs 32-bit word RAM accesses. The address of both the RAM and stack areas to be tested have to be
32-bit aligned and the size of the tested areas must be an integral multiple of 4.
The tested RAM memory will be cleared when the control returns from the
SSL_32bitsFamily_RAM_STACKtest_MarchC function.
Include
SSL_MarchC.h
Prototype
int SSL_32bitsFamily_RAM_STACKtest_MarchC(int* ramStartAddress, int ramSize, int*
stackTopAddress, int stackSize);
Arguments
ramStartAddress
Start address of RAM area for which the March C test is to be performed. Must not
overlap the Stack area! Must be properly 32-bit aligned.
ramSize
Number of consecutive byte locations for which the test is to be performed. The size must
be a number multiple of 4. The size of the RAM area tested must be > 100 bytes.
stackTopAddress
Address of the top of the Stack area for which the March C test is to be performed. Note
that the stack is supposed to grow downward. This must not overlap the RAM area. Must
be properly 32-bit aligned.
stackSize
Number of consecutive byte locations in the Stack area for which the test is to be
performed. The size must be a number multiple of 4 and must be < RAM size.
Return Value
MARCHC_TEST_PASS
The test passed. RAM and Stack area tested have not been detected to have Faults.
MARCHC_TEST_FAIL
The test failed. Either some RAM or Stack area location has been detected to have
Faults.
MARCHC_TEST_FAIL_SIZE
The test failed. There was not enough space in the RAM area to save the Stack area.
MARCHC_TEST_FAIL_STACK The test failed. The requested Stack area does not actually contain the current
hardware SP register.
Remarks
The RAM and Stack areas must not overlap.
The Stack grows downward so the tested area is: [stackTopAddress-stackSize, stackTopAddress]
The processor SP register is changed to the point to the RAM area while the Stack area is tested.
The size of the Stack area to be tested must be less than the size of the RAM area.
Since running the March C RAM and Stack test requires at least 128 bytes of stack, it implies that the size of the tested
RAM area should be at least 128 bytes long.
Once the Stack area is tested, the SP register is restored.
This is a destructive memory test.
DS01229C-page 50
AN1229
SSL_32bitsFamily_RAM_STACKtest_MarchC(Continued)
The test must not be performed over the RAM areas that have to be preserved; otherwise, these RAM areas must be
saved/restored before/after running the test.
Alternately, the test could be run at system start-up before the memory and the run time library is initialized; however,
the stack needs to be initialized.
At least 128 bytes should be available to the stack for executing the March C test.
The tested RAM area must not overlap the stack.
Other statically allocated resources, such as the MPLAB ICD or REAL ICE allocated RAM buffers should be excluded
from this test.
The start address for both RAM and the stack areas to be tested and the size of these areas are PIC32MX variant and
application-dependent. They are run-time parameters.
The standard C language call convention applies regarding the registers usage (refer to Section 5.6 Function Calling
Convention in the MPLAB C Compiler For PIC32 MCUs Users Guide (DS51686).
Upon the function return the register v0 will contain the return code.
Source File
SSL_MarchCStackTest.S
TABLE 33:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states, zero
RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build: MPLAB
C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 51
AN1229
SSL_32bitsFamily_RAMtest_MarchC_Minus
Description
This function implements the March C Minus test. This test performs 32-bit word RAM accesses. The address of the
RAM area to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4.
The tested RAM memory will be cleared when the control returns from the
SSL_32bitsFamily_RAMtest_MarchC_Minus function.
Include
SSL_MarchC.h
Prototype
int SSL_32bitsFamily_RAMtest_MarchC_Minus(int* ramStartAddress, int ramSize);
Arguments
ramStartAddress
Start address from which the March C Minus test is to be performed. Must be properly
32-bit aligned.
ramSize
Number of consecutive byte locations for which the test is to be performed. The size must
be a number multiple of 4.
Return Value
MARCHC_TEST_PASS
The test passed. RAM area tested has not been detected to have Faults.
MARCHC_TEST_FAIL
The test failed. Some RAM area location has been detected to have Faults.
Remarks
This is a destructive memory test.
The test must not be performed over the RAM areas that have to be preserved; otherwise, those RAM areas must be
saved/restored before/after running the test.
Alternatively, the test could be run at system start-up before the memory and the run time library is initialized; however,
the stack needs to be initialized.
At least 100 bytes should be available to the stack for executing the March C Minus test.
The tested RAM area must not overlap the stack.
Other statically allocated resources such as the MPLAB ICD or REAL ICE allocated RAM buffers should be excluded
from this test.
The start address from which the March C Minus test is to be performed and the size of the RAM area are PIC32 variant
and application-dependent. They are run-time parameters.
DS01229C-page 52
AN1229
SSL_32bitsFamily_RAMtest_MarchC_Minus(Continued)
Source File
SSL_MarchCRamTest.c
TABLE 34:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states, zero
RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build: MPLAB
C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 53
AN1229
SSL_32bitsFamily_RAMtest_MarchB
Description
This function implements the March B test. This test performs 32-bit word RAM accesses. The address of the RAM area
to be tested must be 32-bit aligned and the size of the tested RAM area must be an integral multiple of 4.
The tested RAM memory will be cleared when the control returns from the SSL_32bitsFamily_RAMtest_MarchB
function.
Include
SSL_MarchB.h
Prototype
int SSL_32bitsFamily_RAMtest_MarchB(int* ramStartAddress, int ramSize);
Arguments
ramStartAddress
Start address from which the March B test is to be performed. Must be 32-bit aligned.
ramSize
Number of consecutive byte locations for which the test is to be performed. The size must
be a number multiple of 4.
Return Value
MARCHB_TEST_PASS
The test passed. RAM area tested has not been detected to have Faults.
MARCHB_TEST_FAIL
The test failed. Some RAM area location has been detected to have Faults.
Remarks
This is a destructive memory test.
The test must not be performed over the RAM areas that have to be preserved; otherwise, these RAM areas must be
saved/restored before/after running the test.
Alternately, the test could be run at system start-up before the memory and the run time library is initialized; however,
the stack needs to be initialized.
At least 100 bytes should be available to the stack for executing the March B test.
The tested RAM area must not overlap the stack.
Other statically allocated resources such as the MPLAB ICD or REAL ICE allocated RAM buffers should be excluded
from this test.
The start address from which the March B test is to be performed and the size of the RAM area are PIC32 variant and
application-dependent. They are run-time parameters.
Source File
SSL_MarchBRamTest.c
TABLE 35:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states,
zero RAM Wait states, Prefetch and Cache enabled, PBDIV=1:1 interrupts and DMA disabled. Build:
MPLAB C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 54
AN1229
SSL_32bitsFamily_RAMtest_CheckerBoard
Description
This function implements the Checkerboard test on the RAM memory.
It writes the checkerboard pattern (0x55555555 followed by 0xAAAAAAAA) to adjacent memory locations starting at
ramStartAddress.
It performs the following steps:
1.
2.
3.
4.
5.
6.
7.
8.
The content of a 64 bytes memory chunk to be tested is saved in temporary CPU registers.
Writes the pattern 0x55555555 followed by 0xAAAAAAAA to adjacent memory locations filling up the 64 bytes
memory chunk.
It reads the memory chunk adjacent locations and checks that the read-back values match the written pattern. If
the values match set the success result and go to step 4; otherwise, set the error result and go to step 6.
Writes the inverted pattern 0xAAAAAAAA followed by 0x55555555 to adjacent memory locations filling up the 64
bytes memory chunk.
It reads the memory chunk adjacent locations and checks that the read-back values match the written pattern. If
the values match set the success result; otherwise, set the error result.
The content of the tested 64 bytes memory chunk is restored from the temporary CPU registers.
If the result shows error, the test is done and returns.
The Address Pointer is incremented to point to the next sequential 64 bytes memory chunk and the test is
repeated from step 1 until all the number of requested memory locations is tested.
Include
SSL_CBram.h
Prototype
int SSL_32bitsFamily_RAMtest_CheckerBoard(int* ramStartAddress, int ramSize);
Arguments
ramStartAddress
Start address from which the Checkerboard test is to be performed. Must be properly
32-bit aligned.
ramSize
Number of consecutive byte locations for which the test is to be performed. The size must
be a number multiple of 64.
Return Value
CB_TEST_PASS
The test passed. RAM area tested has not been detected to have stuck bits.
CB_TEST_FAIL
The test failed. Some RAM area location has been detected to have stuck bits.
Remarks
This is a non-destructive memory test. The content of the tested memory area is saved and restored. The test operates
in 64 bytes long memory chunks at a time.
At least 32 bytes should be available to the stack for executing the RAM Checker Board test.
The tested RAM area must not overlap the stack.
The start address from which the Checkerboard test is to be performed and the size of the RAM area are PIC32 variant
and application-dependent. They are run-time parameters.
The routine accesses one 4-byte RAM word at a time.
The standard C language call convention applies regarding the registers usage (refer to Section 5.6 Function Calling
Convention in the MPLAB C Compiler For PIC32 MCUs Users Guide (DS51686).
DS01229C-page 55
AN1229
SSL_32bitsFamily_RAMtest_CheckerBoard(Continued)
Upon the function entry all registers that need to be preserved are save into the stack. These registers are restored upon
the completion of the test.
Upon the function return the register v0 will contain the return code.
Source File
SSL_CheckerBoardTest.S
TABLE 36:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
776 bytes
Stack
32 bytes
Execution Time
Note 1:
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states, zero
RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build: MPLAB
C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 56
AN1229
SSL_32bitsFamily_CLOCKtest
Description
The CPU Clock test verifies that the system clock is within specified limits.
The SOSC is used as the reference clock.
The function monitors the CPU Core Timer that runs on the CPU system clock.
The test performs the following major steps:
1.
2.
3.
4.
5.
6.
7.
The SOSC is used as the independent clock source/reference clock source connected to hardware Timer1.
The CPU Core Timer monitored in this measurement is incremented every other CPU system clock.
Usually the system runs on the POSC with PLL as the clock source to the CPU. However, any CPU clock source
except the SOSC itself which is used as a reference is valid for this test.
Timer1 is configured to time out after the specified interval of time elapsed (e.g., 10 ms).
The content of the Core Timer is saved at the beginning of the measurement, once Timer1 is started.
When the hardware Timer1 times out another reading of the Core Timer is taken and the difference is made with
the start value. This difference value represents the number of CPU clock cycles counted by the Core Timer
during the SOSC period of time.
If this value crosses the defined boundary limits, the function returns an appropriate error value, specifying which
exact limit (upper/lower) was violated.
Include
SSL_ClockTest.h
Prototype
int SSL_32bitsFamily_CLOCKtest(unsigned int sysClk, int nMs, int hiClkErr, int loClkErr);
Arguments
sysClk
nMs
Number of milliseconds to be used for the CPU Clock monitoring (1 nMs 1000)
hiClkErr
The upper error limit for the system clock, Hz. A monitored value greater than
(sysClk+hiClkErr) will trigger the return of the CLOCK_TEST_FAIL_HI error code.
loClkErr
The lower error limit for the system clock, Hz. A monitored value less than
(sysClk-loClkErr) will trigger the return of the CLOCK_TEST_FAIL_LOW error code.
Return Value
CLOCK_TEST_PASS
The test passed. The monitored CPU clock is within the requested limits.
CLOCK_TEST_FAIL_HI
The test failed. The monitored CPU clock is greater than the specified upper limit.
CLOCK_TEST_FAIL_LOW
The test failed. The monitored CPU clock is less than the specified lower limit.
Remarks
The test uses the hardware Timer1. It initializes the timer as needed and, after the test is done, shuts off the timer. The
previous state of Timer1 is not preserved/restored.
The test assumes that the Core Timer is enabled and linearly counting up as it should do during normal system operation. If the application code specifically disables the Core Timer, it should enable it before this test is called. Also if the
value in the Core Timer is updated/changed as part of an ISR, this ISR should be disabled.
The interrupts should be disabled when executing this test as the time spent in ISRs will affect the accurate timing of
this routine.
DS01229C-page 57
AN1229
SSL_32bitsFamily_CLOCKtest(Continued)
The SOSC is used as a reference. The frequency of the signal/crystal connected to this input is defined using the
CLOCK_TEST_SOSC_FREQ symbol.
The value of the CPU clock monitoring time, nMs, is limited because of the use of the hardware Timer1, which is a
16-bit timer. Therefore, the value loaded into this Timer1 register should not exceed 216-1.
Source File
SSL_ClockTest.c
TABLE 37:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
2:
The maximum execution time is routine execution + 2 SOSC signal periods (1 period for measurement +
synchronization time).
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states, zero
RAM Wait states, Prefetch and Cache enabled, PBDIV=1:1 interrupts and DMA disabled. Build: MPLAB
C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 58
AN1229
SSL_32bitsFamily_CLOCKtest_LineFreq
Description
The CPU Clock Line Test verifies that the system clock is within specified limits.
An external frequency applied on the Input Capture 1 pin (IC1) is used as the reference clock.
The hardware Timer2 that runs on the system Peripheral Bus (PB) clock is used to monitor the CPU clock and Peripheral
Bus divider.
The test performs the following major steps:
1.
2.
3.
The IC1 input is used as the independent clock source/reference clock source to capture the hardware Timer2.
An external reference frequency, usually the line frequency, must be applied to the IC1 input pin.
The Input Capture 1 is configured as follows:
Timer2 is selected as the IC1 time base
Capture is performed on every rising edge
Capture done event is generated on every second capture
The hardware Timer2 prescaler is calculated (based on the input reference frequency and the current PB
frequency) as being the smallest divider possible, such that the 16-bit Timer2 does not overflow within a period
time of the input reference signal.
This way, the best resolution is achieved for the given conditions. If no valid prescaler value can be obtained an
error value is returned (the maximum divider for Timer2 is 256).
4.
5.
The IC1 performs the capture on every rising edge of the input reference frequency. For period measurement,
the capture done event is generated after the IC1 module takes two time stamps (i.e., after every period of the
input reference (20 ms if reference frequency is 50 Hz, 16.66ms if the reference frequency is 60 Hz)).
Once the capture done event is signaled, the two Timer2 captured readings are extracted and the number of
elapsed PB clocks is calculated as being the difference between the two readings multiplied by the Timer2
prescaler.
If this value crosses the defined boundary limits the function returns an appropriate error value, specifying which
exactly limit (upper/lower) was violated.
CALCULATION EXAMPLE 1:
System Clock = 80 MHz
PB Clock = 80 MHz (PB divider = 1:1)
Input Reference = 50 Hz
T2 Min Divider = floor(PBclk/(65536*RefClk)) + 1 = 25
Actual T2 Divider = 32
The number of cycles counted by the Timer2 in the Reference clock period is = (80,000,000/32)/50 = 50,000.
CALCULATION EXAMPLE 2:
System Clock = 80 MHz
PB Clock = 10 MHz (PB divider = 1:8)
Input Reference = 60 Hz
T2 Min Divider = floor(PBclk/(65536*RefClk)) + 1 = 3
Actual T2 Divider = 4
The number of cycles counted by Timer2 in the Reference clock period is = (10,000,000/4)/60 = 41,666.
Include
SSL_ClockTest_LineFreq.h
Prototype
int SSL_32bitsFamily_CLOCKtest_LineFreq(unsigned int sysClk, unsigned int lineRefClk,
int hiClkErr, int loClkErr);
DS01229C-page 59
AN1229
SSL_32bitsFamily_CLOCKtest_LineFreq(Continued)
Arguments
sysClk
lineRefClk
The frequency of the reference applied to the IC1 input pin, Hz. Usual values are 50/60 Hz
hiClkErr
The upper error limit for the system clock, Hz. A monitored value greater than
(sysClk+hiClkErr) will trigger the return of the CLOCK_TEST_FAIL_HI error code.
loClkErr
The lower error limit for the system clock, Hz. A monitored value less than
(sysClk-loClkErr) will trigger the return of the CLOCK_TEST_FAIL_LOW error code.
Return Value
CLOCK_TEST_PASS
The test passed. The monitored CPU clock is within the requested limits.
CLOCK_TEST_FAIL_HI
The test failed. The monitored CPU clock is greater than the specified upper limit.
CLOCK_TEST_FAIL_LOW
The test failed. The monitored CPU clock is less than the specified lower limit.
CLOCK_TEST_FAIL_LOW_REF
The test failed. The frequency of the provided reference was too low and could
not be used.
Remarks
The test uses the hardware Input Capture 1 module. It initializes the module as needed and, after the test is done, it
shuts it off. The previous state of IC1 is not preserved/restored.
The test uses the hardware Timer2. It initializes the timer as needed and, after the test is done, shuts off the timer. The
previous state of Timer1 is not preserved/restored.
The value of the PB frequency which is used as input by the Timer2 is derived from the system CPU clock by dividing
it with the PB divider. The test does not change the value of the PB divider, it uses the current value.
The interrupts should be disabled when executing this test as the time spent in ISRs affects the accurate timing of this
routine.
The frequency of the signal used as a reference on IC1 input should normally be the line frequency.
However, any frequency can be used as long as a valid Timer2 divider can be obtained (see the example calculation
below for the 16-bit Timer2).
If the reference frequency is too low, a valid divider for the Timer2 will not be possible (the maximum divider for Timer2
is 256). A greater PB divider must be selected in this case.
If the selected reference frequency is too high, the number of Timer2 captured counts will be too small and the
measurement will not have enough resolution.
Source File
SSL_ClockTest_LineFreq.c
DS01229C-page 60
AN1229
TABLE 38:
RESOURCE REQUIREMENTS
Parameter
Requirements
Program Memory
Stack
Execution Time
Note 1:
2:
The maximum execution time is routine execution + 3 reference signal periods (2 periods for
measurement + synchronization time).
The value for the CPU cycles can vary greatly depending on the system settings and the build parameters.
All execution time measurements are done with the following settings: 80 MHz, two Flash Wait states,
zero RAM Wait states, Prefetch and Cache enabled, PBDIV = 1:1 interrupts and DMA disabled. Build:
MPLAB C32 V1.10(b) Release -O3 -fomit-frame-pointer.
DS01229C-page 61
AN1229
SUMMARY
REFERENCES
DS01229C-page 62
AN1229
APPENDIX A:
SOURCE CODE
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated (the Company) is intended and supplied to you, the
Companys customer, for use solely and exclusively with products manufactured by the Company.
The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved.
Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil
liability for the breach of the terms and conditions of this license.
THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
All of the software covered in this application note is available as a single WinZip archive file. This archive can be
downloaded from the Microchip corporate web site at:
www.microchip.com
DS01229C-page 63
AN1229
APPENDIX B:
The following table is reproduced with the permission of the International Electrotechnical Commission (IEC). IEC
60730-1 ed.3.2 Copyright 2007 IEC, Geneva, Switzerland. www.iec.ch.
TABLE B-1:
DS01229C-page 64
H.11.12.7
AN1229
TABLE B-1:
H.11.12.7 (CONTINUED)
DS01229C-page 65
AN1229
TABLE B-1:
DS01229C-page 66
H.11.12.7 (CONTINUED)
AN1229
TABLE B-1:
H.11.12.7 (CONTINUED)
DS01229C-page 67
AN1229
TABLE B-1:
DS01229C-page 68
H.11.12.7 (CONTINUED)
AN1229
APPENDIX C:
REVISION HISTORY
SSL_32bitsFamily_CPU_RegisterTest
SSL_32bitsFamily_PCtest
SSL_32bitsFamily_Flashtest_CRC16
SSL_32bitsFamily_RAMtest_MarchC
SSL_32bitsFamily_RAM_STACKtest_MarchC
SSL_32bitsFamily_RAMtest_MarchC_Minus
SSL_32bitsFamily_RAMtest_MarchB
SSL_32bitsFamily_RAMtest_CheckerBoard
SSL_32bitsFamily_CLOCKtest
SSL_32bitsFamily_CLOCKtest_LineFreq
Revision C (04/2012)
Added 8-bit information.
DS01229C-page 69
AN1229
NOTES:
DS01229C-page 70
Note the following details of the code protection feature on Microchip devices:
Microchip products meet the specification contained in their particular Microchip Data Sheet.
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
Trademarks
The Microchip name and logo, the Microchip logo, dsPIC,
KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART,
PIC32 logo, rfPIC and UNI/O are registered trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor,
MXDEV, MXLAB, SEEVAL and The Embedded Control
Solutions Company are registered trademarks of Microchip
Technology Incorporated in the U.S.A.
Analog-for-the-Digital Age, Application Maestro, chipKIT,
chipKIT logo, CodeGuard, dsPICDEM, dsPICDEM.net,
dsPICworks, dsSPEAK, ECAN, ECONOMONITOR,
FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP,
Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB,
MPLINK, mTouch, Omniscient Code Generation, PICC,
PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE,
rfLAB, Select Mode, Total Endurance, TSHARC,
UniWinDriver, WiperLock and ZENA are trademarks of
Microchip Technology Incorporated in the U.S.A. and other
countries.
SQTP is a service mark of Microchip Technology Incorporated
in the U.S.A.
All other trademarks mentioned herein are property of their
respective companies.
2008-2012, Microchip Technology Incorporated, Printed in
the U.S.A., All Rights Reserved.
Printed on recycled paper.
ISBN: 9781620762523
== ISO/TS 16949 ==
2008-2012 Microchip Technology Inc.
DS01229C-page 71
ASIA/PACIFIC
ASIA/PACIFIC
EUROPE
Corporate Office
2355 West Chandler Blvd.
Chandler, AZ 85224-6199
Tel: 480-792-7200
Fax: 480-792-7277
Technical Support:
http://www.microchip.com/
support
Web Address:
www.microchip.com
India - Bangalore
Tel: 91-80-3090-4444
Fax: 91-80-3090-4123
India - New Delhi
Tel: 91-11-4160-8631
Fax: 91-11-4160-8632
Austria - Wels
Tel: 43-7242-2244-39
Fax: 43-7242-2244-393
Denmark - Copenhagen
Tel: 45-4450-2828
Fax: 45-4485-2829
India - Pune
Tel: 91-20-2566-1512
Fax: 91-20-2566-1513
France - Paris
Tel: 33-1-69-53-63-20
Fax: 33-1-69-30-90-79
Japan - Osaka
Tel: 81-66-152-7160
Fax: 81-66-152-9310
Germany - Munich
Tel: 49-89-627-144-0
Fax: 49-89-627-144-44
Atlanta
Duluth, GA
Tel: 678-957-9614
Fax: 678-957-1455
Boston
Westborough, MA
Tel: 774-760-0087
Fax: 774-760-0088
Chicago
Itasca, IL
Tel: 630-285-0071
Fax: 630-285-0075
Cleveland
Independence, OH
Tel: 216-447-0464
Fax: 216-447-0643
Dallas
Addison, TX
Tel: 972-818-7423
Fax: 972-818-2924
Detroit
Farmington Hills, MI
Tel: 248-538-2250
Fax: 248-538-2260
Indianapolis
Noblesville, IN
Tel: 317-773-8323
Fax: 317-773-5453
Los Angeles
Mission Viejo, CA
Tel: 949-462-9523
Fax: 949-462-9608
Santa Clara
Santa Clara, CA
Tel: 408-961-6444
Fax: 408-961-6445
Toronto
Mississauga, Ontario,
Canada
Tel: 905-673-0699
Fax: 905-673-6509
Australia - Sydney
Tel: 61-2-9868-6733
Fax: 61-2-9868-6755
China - Beijing
Tel: 86-10-8569-7000
Fax: 86-10-8528-2104
China - Chengdu
Tel: 86-28-8665-5511
Fax: 86-28-8665-7889
China - Chongqing
Tel: 86-23-8980-9588
Fax: 86-23-8980-9500
Netherlands - Drunen
Tel: 31-416-690399
Fax: 31-416-690340
Korea - Daegu
Tel: 82-53-744-4301
Fax: 82-53-744-4302
Spain - Madrid
Tel: 34-91-708-08-90
Fax: 34-91-708-08-91
China - Hangzhou
Tel: 86-571-2819-3187
Fax: 86-571-2819-3189
Korea - Seoul
Tel: 82-2-554-7200
Fax: 82-2-558-5932 or
82-2-558-5934
China - Nanjing
Tel: 86-25-8473-2460
Fax: 86-25-8473-2470
Malaysia - Penang
Tel: 60-4-227-8870
Fax: 60-4-227-4068
China - Qingdao
Tel: 86-532-8502-7355
Fax: 86-532-8502-7205
Philippines - Manila
Tel: 63-2-634-9065
Fax: 63-2-634-9069
China - Shanghai
Tel: 86-21-5407-5533
Fax: 86-21-5407-5066
Singapore
Tel: 65-6334-8870
Fax: 65-6334-8850
China - Shenyang
Tel: 86-24-2334-2829
Fax: 86-24-2334-2393
China - Shenzhen
Tel: 86-755-8203-2660
Fax: 86-755-8203-1760
Taiwan - Kaohsiung
Tel: 886-7-536-4818
Fax: 886-7-330-9305
China - Wuhan
Tel: 86-27-5980-5300
Fax: 86-27-5980-5118
Taiwan - Taipei
Tel: 886-2-2500-6610
Fax: 886-2-2508-0102
China - Xian
Tel: 86-29-8833-7252
Fax: 86-29-8833-7256
Thailand - Bangkok
Tel: 66-2-694-1351
Fax: 66-2-694-1350
UK - Wokingham
Tel: 44-118-921-5869
Fax: 44-118-921-5820
China - Xiamen
Tel: 86-592-2388138
Fax: 86-592-2388130
China - Zhuhai
Tel: 86-756-3210040
Fax: 86-756-3210049
DS01229C-page 72
Italy - Milan
Tel: 39-0331-742611
Fax: 39-0331-466781
Japan - Yokohama
Tel: 81-45-471- 6166
Fax: 81-45-471-6122
11/29/11