introduction to nuvoton iec60730-1 class b stl · sep 30, 2019 page 4 of 30 rev 1.00 an0037 1...

30
Sep 30, 2019 Page 1 of 30 Rev 1.00 AN0037 Application Note for NuMicro ® M451 Series Document Information Abstract This application note introduces Nuvoton IEC60730-1 Class B Software Test Library (STL) consisting of low-level software routines. These routines implement basic requirements specified in IEC60730-1 Annex H MCU part of the standard. The user can add STL into existing application to meet the requirements from IEC60730-1. Apply to NuMicro ® M451 Series. The information described in this document is the exclusive intellectual property of Nuvoton Technology Corporation and shall not be reproduced without permission from Nuvoton. Nuvoton is providing this document only for reference purposes of NuMicro microcontroller based system design. Nuvoton assumes no responsibility for errors or omissions. All data and specifications are subject to change without notice. For additional information or questions, please contact: Nuvoton Technology Corporation. www.nuvoton.com Introduction to Nuvoton IEC60730-1 Class B STL

Upload: others

Post on 28-May-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 1 of 30 Rev 1.00

AN0037

Application Note for NuMicro® M451 Series

Document Information

Abstract This application note introduces Nuvoton IEC60730-1 Class B Software Test Library (STL) consisting of low-level software routines. These routines implement basic requirements specified in IEC60730-1 Annex H MCU part of the standard. The user can add STL into existing application to meet the requirements from IEC60730-1.

Apply to NuMicro® M451 Series.

The information described in this document is the exclusive intellectual property of Nuvoton Technology Corporation and shall not be reproduced without permission from Nuvoton.

Nuvoton is providing this document only for reference purposes of NuMicro microcontroller based system design. Nuvoton assumes no responsibility for errors or omissions.

All data and specifications are subject to change without notice.

For additional information or questions, please contact: Nuvoton Technology Corporation.

www.nuvoton.com

Introduction to Nuvoton IEC60730-1 Class B STL

Page 2: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 2 of 30 Rev 1.00

AN0037

Table of Contents

1 OVERVIEW ................................................................................................................................ 4

2 STL TEST ITEMS .................................................................................................................... 5

2.1 Test Items for Startup ............................................................................................................... 5

2.2 Test Items for Runtime ............................................................................................................. 5

2.3 Application Test at Runtime ..................................................................................................... 6

2.4 Program Flow Chart .................................................................................................................. 7

2.4.1 Startup Checks Block ........................................................................................................................ 8 2.4.2 Runtime Checks Block ...................................................................................................................... 8 2.4.3 Application Control Block .................................................................................................................. 9

2.5 Program Performance Benchmarking .................................................................................. 10

3 FUNCTION DESCRIPTION OF TEST ITEMS FOR STARTUP .............................. 11

3.1 WDT and WWDT Reset Test ................................................................................................... 11

3.2 CPU Registers Test ................................................................................................................. 11

3.3 Program Counter Test ............................................................................................................ 12

3.4 WDT Test .................................................................................................................................. 13

3.5 Interrupt Test ............................................................................................................................ 14

3.6 RAM Test – March C ................................................................................................................ 14

3.7 RAM Test – March X ................................................................................................................ 16

3.8 Flash Test ................................................................................................................................. 17

4 FUNCTION DESCRIPTION OF TEST ITEMS FOR RUNTIME ............................... 19

4.1 CPU Registers Test ................................................................................................................. 19

4.2 Program Counter Test ............................................................................................................ 19

4.3 Stack Test ................................................................................................................................. 20

4.4 Interrupt Test ............................................................................................................................ 20

4.5 RAM Test – March X ................................................................................................................ 21

4.6 Flash Test ................................................................................................................................. 22

5 FUNCTION DESCRIPTION OF APPLICATION TEST AT RUNTIME .................. 23

5.1 GPIO Test .................................................................................................................................. 23

5.2 SPI Test ..................................................................................................................................... 23

5.3 PWM Test .................................................................................................................................. 24

Page 3: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 3 of 30 Rev 1.00

AN0037

5.4 ADC Test ................................................................................................................................... 24

6 STL EVALUATION BOARD ............................................................................................... 25

6.1 STL Evaluation Board Overview ............................................................................................ 25

6.2 Test Setting Table .................................................................................................................... 25

6.3 Schematics ............................................................................................................................... 26

6.3.1 MCU Schematic ............................................................................................................................... 26 6.3.2 Application Schematic ..................................................................................................................... 27 6.3.3 External Interface ............................................................................................................................. 27

7 CONCLUSION ........................................................................................................................ 28

Page 4: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 4 of 30 Rev 1.00

AN0037

1 Overview

IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate certification process in products, Nuvoton provides users with the sample code consisting of low-level software routines. These routines implement basic requirements specified in Annex H of the IEC60730-1 standard. There are three parts of the sample code, including test items for startup, runtime and application. The user can add and modify this code into existing application to meet the requirements from IEC60730-1.

The main purpose of this application note and the associated software is to facilitate and accelerate user software development and certification processes for applications based on M451 series microcontrollers. The Software Test Library (STL) collects common sets of tests dedicated mainly to generic blocks of M451 microcontrollers. The common part of STL package can also be reused for any other microcontrollers of M4 family. The user can include the STL into a final customer project, together with additional product specific tests and settings, for example, ADC and DAC tests.

With this application note, the user can better understand the methodology and techniques used in the STL. The provided examples show how to integrate the STL and the associated firmware in the application. The final implementation and functionality always has to be verified by the certification body at the application level.

Page 5: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 5 of 30 Rev 1.00

AN0037

2 STL Test Items

The STL consists of several kinds of test items, including CPU register, Program Counter, WDT, Stack, Interrupt, RAM and Flash tests. These tests are executed during startup or runtime stages or both. All these test functions have been released with this application note.

The user can download the STL from https://github.com/opennuvoton and add them into an existing project to implement the self-test feature.

2.1 Test Items for Startup

When the system is powered on, test items can confirm whether the function of the MCU is correct through the test items for startup. When the test is completed, system can execute the application. If the MCU is detected abnormally, it will stop the system and show an error message.

The following table lists the summary of test items for startup.

Test Items Description IEC60730-1 Annex H Items

WDT and WWDT

Reset Test

Test the reset function of WDT and WWDT. 1.3 Program Counter Test

CPU Register Test Read and write specific test patterns on CPU registers. 1.1 CPU Register Test

Program Counter Test Test the branch address location for program counter. 1.3 Program Counter Test

WDT Test Test WDT time period by Timer0. 1.3 Program Counter Test

Interrupt Test Test Interrupt count using Systick and Timer0. 2.0 Interrupt Test

RAM Test – March C Read and write specific test patterns on RAM by March C algorithm.

4.2 RAM Test

RAM Test – March X Read and write specific test patterns on RAM by March X algorithm.

4.2 RAM Test

Flash Test Read Flash data and get CRC32 checksum for check content of Flash.

4.1 ROM Test

Table 2-1 Startup Test Items

2.2 Test Items for Runtime

In the application execution, the test Items for runtime detect the MCU function continuously. In order not to affect the efficiency of the application, these test items are part of whole function. It focuses on the key functions of the system. If the MCU is detected abnormally, it will stop the system and show an error message.

Page 6: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 6 of 30 Rev 1.00

AN0037

The following table lists the summary of test items for runtime.

Test Items Description IEC60730-1 Annex H Items

CPU Register Test Read and write specific test patterns on CPU registers. 1.1 CPU Register Test

Program Counter Test

Test the branch address location for program counter. 1.3 Program Counter Test

Stack Test Test whether Stack boundary being overflowed or not. 4.2 RAM Test

Interrupt Test Test Interrupt count using Systick and Timer0. 2.0 Interrupt Test

RAM Test – March X Read and write specific test patterns on RAM by March X algorithm.

4.2 RAM Test

Flash Test Read Flash data and get CRC32 checksum for check content of Flash.

4.1 ROM Test

Table 2-2 Runtime Test Items

2.3 Application Test at Runtime

This application test confirms the peripheral functions of the MCU. It provides test program for common peripheral functions. MCU could verify the correctness of peripheral functions while the system is executing the application. If the MCU is detected abnormally, it will stop the system and show an error message.

The following table lists the summary of application tests for runtime.

Test Items Description IEC60730-1 Annex H Items

GPIO Test Test GPIO input and output signal. 7.1 Digital I/O Test

SPI Test Test SPI Master loop back transfer. It compares the received data with transmitted data.

7.1 Digital I/O Test

PWM Test Test PWM period and duty by PWM capture function. 7.1 Digital I/O Test

ADC Test Sample LDO voltage by ADC function. it compares the ADC result with LDO spec.

7.2 Analog I/O Test

Table 2-3 Runtime Application Tests

Page 7: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 7 of 30 Rev 1.00

AN0037

2.4 Program Flow Chart

The basic structure of control flow in the system level is shown in Figure 2-1.

Start

SYS_Init

Run Time Initial

Runtime Checks Block

Startup Checks Block

Application Control Block

Figure 2-1 Program Flow Chart

There are three parts of the sample code, including startup checks block, runtime checks block and application control block. The user can add and modify these programs into the existing application to meet the requirements from IEC60730-1. The following sections show the details of these three parts.

Page 8: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 8 of 30 Rev 1.00

AN0037

2.4.1 Startup Checks Block

Startup Checks Block

WDT and WWDT Reset Test

CPU Register Test

Program Counter Test

WDT Test

Interrupt Test

RAM Test – March C or X

Flash Test

Figure 2-2 Startup Checks Block

When the system is powered on, startup checks block confirms whether the MCU is correct through the test items for MCU startup. After the test is completed, system could execute the application.

2.4.2 Runtime Checks Block

Runtime Checks Block

Timercnt++

Timercnt %TEST_CYCLE

CPU Register Test Program Counter Test Stack Test Interrupt Test RAM Test March C or X Flash Test

= CPUREG_CYCLE = PC_CYCLE = STACK_CYCLE = INT_CYCLE = RAM_CYCLE = ROM_CYCLE

Figure 2-3 Runtime Checks Block

Page 9: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 9 of 30 Rev 1.00

AN0037

Each time MCU enters the runtime checks block, MCU will check that the value of Timercnt to determine the test item to be executed. The user can set it in the iec60730_test_runtime.h file, and adjust the execution times of each test item. According to this setting keeps the application performance.

2.4.3 Application Control Block

Application Control Block

TimercntAPP++

TimercntAPP %TEST_CYCLE

GPIO Test SPI Test PWM Test ADC Test

= GPIO_CYCLE = SPI_CYCLE = PWM_CYCLE = ADC_CYCLE

Application Program

Figure 2-4 Application Control Block

Each time MCU enters the application control block, MCU will check that the value of TimercntAPP to determine the test item to be executed. The user can set it in the iec60730_test_app.h file, and adjust the execution times of each test item. According to this setting keeps the application performance. After the test item has finished, the MCU could run application of the system.

Page 10: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 10 of 30 Rev 1.00

AN0037

2.5 Program Performance Benchmarking

This section shows the performance of test items, including startup test and runtime test. User could define and normalize test time for system performance to keep CPU resource for application.

Test Items for Startup

Test Items Execution time Peripherals Description

Clock: 22 MHz Clock: 72 MHz

CPU Register Test 18.66 us 5.76 us

Program Counter Test

3.64 us 1.10 us

WDT Test 31.30 ms 31.30 ms Timer0, WDT

Interrupt Test 10.44 ms 10.44 ms Timer0, Systick

RAM Test – March C 15.86 ms 4.89 ms Test Size: 32 KB

RAM Test – March X 10.68 ms 3.3 ms Test Size: 32 KB

Flash Test (SW) 489 ms 151 ms Test Size: 63 KB

Flash Test (HW) 7.38 ms 2.28 ms CRC Test Size: 63 KB

Table 2-4 Performance of Startup Test Items

Test Items for Runtime

Test Items Execution time Peripherals Description

Clock: 22 MHz Clock: 72 MHz

CPU Register Test 6.03 us 1.69 us

Program Counter Test

2.03 us 0.63 us

Stack Test 2.88 us 14.06 us

Interrupt Test 3.92 us 1.11 us Timer0, Systick

RAM Test – March X 25.72 us 8.05 us Test Size: 32 B

Flash Test (SW) 316 us 96.40 us Test Size: 32 B

Flash Test (HW) 6.52 us 2.02 us CRC Test Size: 32 B

Table 2-5 Performance of Runtime Test Items

Page 11: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 11 of 30 Rev 1.00

AN0037

3 Function Description of Test Items for Startup

3.1 WDT and WWDT Reset Test

This test item is used to test WDT and WWDT Reset function and check the results.

Format void IEC60730_WDT_WWDT_Reset_Test (uint32_t* WDTTestPass)

Arguments uint32_t* WDTTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values None

Return Values 0

Related Files wdt_wwdt_reset_test_startup.s

This test item is to test the reset function of WDT and WWDT individually. The system will reset twice by WDT and WWDT when the system is powered on.

3.2 CPU Registers Test

This test item is used to read and write specific test patterns on CPU registers and check the result.

Format void IEC60730_CPU_Reg_Test (void)

Arguments None

Global Values uint32_t CPUTestPass;

Test result will be stored in this value and main program will check its value to detect pass or fail.

0 = Fail

1 = Pass

Return Values None

Related Files cpureg_test_startup.s

Page 12: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 12 of 30 Rev 1.00

AN0037

This test item uses the test patterns, 0xAAAAAAAA and 0x55555555, to verify the following registers:

General purpose registers(R0 ~ R12)

PRIMASK register

CONTROL register

SP register

LR register

APSR register

If any errors occur, this test will abort immediately and show an error message.

3.3 Program Counter Test

This test item is used to test whether MCU Program Counter can branch to the pre-defined address location or not.

Format uint32_t IEC60730_PC_Test (uint32_t* PCTestPass)

Arguments uint32_t* PCTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values None

Return Values 0

Related Files

pc_test_startup.c

iec60730.sct

This test requires a scatter file, “iec60730.sct”, to arrange the code layout.

In this file, there are two sections, pc_test_1 and pc_test_2, located in different address.

User can modify this address to fit the test environment.

LR_IROM1 0x00000000 { ; load region

ER_IROM1 0x00000000 0x00040000 { ; load address = execution address

*.o (RESET, +First)

*(InRoot$$Sections)

}

Page 13: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 13 of 30 Rev 1.00

AN0037

ABS_ADDRESS1 0x1554 FIXED 36 {

pc_test_startup.o (pc_test_1)

}

ABS_ADDRESS2 0x2AA8 FIXED 36 {

pc_test_startup.o (pc_test_2)

}

ER_IROM2 +0 0x00040000 { ; load address = execution address

.ANY (+RO)

The pc_test_1 function returns the known value defined by user and pc_test_2 returns its function address. This test will check those two return values to make sure the program counter branches correctly.

3.4 WDT Test

This test item is used to compare Timer0 interrupt times with WDT.

Format uint32_t IEC60730_WDT_Test (uint32_t* WDTTestPass)

Arguments uint32_t* WDTTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values uint32_t u32Timer0Cnt

It is counted by Timer0 interrupt.

uint32_t u32WdtInt

It is invoked once by WDT interrupt.

Return Values 0

Related Files wdt_test_startup.c

The WDT test uses WDT and Timer0 to check if the WDT can work properly. The WDT is set to use LIRC as clock source. While the WDT interrupt is invoked, the interrupt count of Timer0 is checked whether it is located in the range of deviation, and then determines whether the test is passed or failed.

Page 14: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 14 of 30 Rev 1.00

AN0037

3.5 Interrupt Test

This test item is used to compare Timer0 interrupt times with Systick Timer.

Format uint32_t IEC60730_Interrupt_Test (uint32_t* IntTestPass)

Arguments uint32_t* IntTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values uint32_t u32Timer0Cnt

It is counted by Timer0 interrupt.

uint32_t u32SysTickCnt

It is counted by Systick Timer interrupt.

Return Values 0

Related Files interrupt_test_startup.c

The interrupt test uses Systick and Timer0 that have different clock sources. By comparing the invoked count by different timers, users can determine whether the test is passed or failed.

3.6 RAM Test – March C

The RAM memory is tested by March C algorithm.

Format void IEC60730_RamMarchC (void)

Arguments None

Global Values uint32_t RAMStartAddr

The starting address of RAM. It is set before user call the function.

uint32_t RAMEndAddr

The end address of RAM. It is set before user call the function.

uint32_t RAMTestPass

Test result will be stored in this value and main program will check its value to detect pass or fail.

Page 15: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 15 of 30 Rev 1.00

AN0037

0 = Fail

1 = Pass

Return Values None

Related Files ram_marchc_test_startup.c

This test is enabled by the defined RAM_STARTUP_MARCHC_WOM of iec60730_test.h file. The data in the tested area will be lost after test. The user can back up the data before test and then restore it after test. March X is a subset of March C. The user can select one of these two algorithms to test the RAM.

The test procedure of March C algorithm:

1. Clear all memory content to be zero.

2. Scan memory content from low to high address. For each memory location, check the

read bit is 0 or not. If not, the test is failed otherwise write 1 back to the memory location.

3. Scan memory content from low to high address. For each memory location, check the

read bit is 1 or not. If not, the test is failed otherwise write 0 back to the memory location

4. Scan memory content from high to low address. For each memory location, check the

read bit is 0 or not. If not, the test is failed otherwise write 1 back to the memory location

5. Scan memory content from high to low address. For each memory location, check the

read bit is 1 or not. If not, the test is failed otherwise write 0 back to the memory location

6. Check whether all bits are zero or not. The scanning direction can be either from high to

low, or low to high address.

Page 16: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 16 of 30 Rev 1.00

AN0037

Figure 3-1 March C Algorithm

3.7 RAM Test – March X

The RAM memory is tested by March X algorithm.

Format void IEC60730_RamMarchX (void)

Arguments None

Global Values uint32_t RAMStartAddr

The starting address of RAM. It is set before user call the function.

uint32_t RAMEndAddr

The end address of RAM. It is set before user call the function.

uint32_t RAMTestPass

Test result will be stored in this value and main program will check its value to detect pass or fail.

0 = Fail

1 = Pass

Return Values None

Related Files ram_marchx_test_startup.c

0000

0000

….

0000

0000

0000

….

0000

1111

0000

….

0000

1111

1111

….

0000

1111

1111

….

1111

1111

1111

….

0000

1111

0000

….

0000

0000

0000

….

0000

Step1 Step2

Step5 Step6

1111

1111

….

1111

0000

1111

….

1111

0000

0000

….

1111

Step3

0000

0000

….

0000

0000

0000

….

1111

0000

1111

….

1111

Step4

March C Steps

Page 17: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 17 of 30 Rev 1.00

AN0037

This test is enabled by the define RAM_STARTUP_MARCHX_WOM of iec60730_test.h file. The data in the tested area will be lost after test. The user can back up the data before test and then restore it after test.

The test procedure of March X algorithm:

1. Clear all memory content to be zero.

2. Scan memory content from low to high address. For each memory location, check the

read bit is 0 or not. If not, the test is failed otherwise write 1 back to the memory location.

3. Scan memory content from high to low address. For each memory location, check the

read bit is 1 or not. If not, the test is failed otherwise write 0 back to the memory location

4. Check whether all bits are zero or not. The scanning direction can be either from high to

low, or low to high address.

Figure 3-2 March X Algorithm

3.8 Flash Test

The Flash memory is tested by checking CRC checksum value.

Format uint32_t IEC60730_Flash_Test (uint32_t* ROMTestPass)

Arguments uint32_t* ROMTestPass;

Test result will be stored in this value and main program will check its value to detect pass or fail.

0 = Fail

1 = Pass

Global Values None

Return Values 0

Related Files flash_test_startup.c

0000

0000

….

0000

0000

0000

….

0000

1111

0000

….

0000

1111

1111

….

0000

1111

1111

….

1111

1111

1111

….

0000

1111

0000

….

0000

0000

0000

….

0000

Step1 Step2 Step3 Step4

March X Steps

Page 18: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 18 of 30 Rev 1.00

AN0037

The test function calculates the CRC32 checksum for the Flash program area, and then compares the checksum with prior calculated value __Check_Sum in startup_M451Series.s file to determine whether the test is passed or not. The MCU can get CRC32 checksum by hardware interface if the user defines CRC_COMAPRE_WITH_HW in iec60730_test.h file.

This test requires a scatter file, “iec60730.sct”, to arrange the code layout. In this file, there is an absolute address to define checksum value. The Flash program area is from address 0 to this checksum value address (0x10000-0x100).

User can modify this address to fit the test environment.

ABS_ADDRESS3 0x10000-0x100 FIXED 36 {

*.o (CHECKSUM +Last)

}

Page 19: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 19 of 30 Rev 1.00

AN0037

4 Function Description of Test Items for Runtime

4.1 CPU Registers Test

This test item is used to read and write specific test patterns on CPU registers and check the results.

Format void IEC60730_CPU_Reg_Test_RunTime (void)

Arguments None

Global Values uint32_t CPUTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Return Values None

Related Files cpureg_test_runtime.s

This test item uses the test patterns, 0xAAAAAAAA and 0x55555555, to verify the following registers:

General purpose registers(R0 ~ R7)

If any errors occur, this test will abort immediately and show an error message.

4.2 Program Counter Test

This test item is used to test whether MCU Program Counter can branch to the pre-defined address location or not.

Format uint32_t IEC60730_PC_Test_RunTime (uint32_t* PCTestPass)

Arguments uint32_t* PCTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values None

Page 20: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 20 of 30 Rev 1.00

AN0037

Return Values 0

Related Files pc_test_runtime.c

This test is the same with IEC60730_PC_Test (uint32_t* PCTestPass) function. The pc_test_1 function returns the known value defined by user and pc_test_2 returns its function address. This test will check those two return values to make sure the program counter branches correctly.

4.3 Stack Test

This test item is used to test whether Stack boundary is overflowed or not.

Format uint32_t IEC60730_Stack_Test_RunTime (uint32_t* StackTestPass)

Arguments uint32_t* StackTestPass

Test result will be stored in this value.

0 = Fail

1 = Pass

Global Values STACK_TEST_PTRN[]

It stores the pre-defined pattern.

Return Values 0

Related Files stack_test_runtime.c, stack_overrun_ptrn.c

The Stack test checks whether the specific pattern in the beginning of stack area is destroyed or not. If the pattern has not been changed, it means the Stack overrun condition never met.

4.4 Interrupt Test

This test item is used to compare Timer0 interrupt times with Systick Timer.

Format uint32_t IEC60730_Interrupt_Test_Runtime (uint32_t* IntTestPass)

Arguments uint32_t* IntTestPass

Test result will be stored in this value.

Page 21: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 21 of 30 Rev 1.00

AN0037

0 = Fail

1 = Pass

Global Values uint32_t u32Timer0Cnt

It is counted by Timer0 interrupt.

uint32_t u32SysTickCnt

It is counted by Systick Timer interrupt.

Return Values 0

Related Files interrupt_test_runtime.c

The interrupt test uses Systick and Timer0 that have different clock sources. By comparing the invoked count by different timers, the user can determine whether the test is passed or failed.

4.5 RAM Test – March X

The RAM memory is tested by March X algorithm.

Format uint32_t IEC60730_RAM_MarchX_Test_RunTime (uint32_t* RAMTestPass)

Arguments uint32_t* RAMTestPass;

Test result will be stored in this value and main program will check its value to detect pass or fail.

0 = Fail

1 = Pass

Global Values uint32_t RAMStartAddr;

The starting address of RAM. It is set before user call the function.

uint32_t RAMEndAddr;

The end address of RAM. It is set before user call the function.

Return Values 0

Related Files ram_marchcx_test_runtime.c

This test is enabled by the defined RAM_RUNTIME_MARCHX_WOM of iec60730_test_runtime.h file. All RAM area excluding stack and stack pattern will be tested. After tested, all data of verified area can be kept no change.

Page 22: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 22 of 30 Rev 1.00

AN0037

4.6 Flash Test

The Flash memory is tested by checking CRC checksum value.

Format uint32_t IEC60730_Flash_Test_RunTime (uint32_t* ROMTestPass)

Arguments uint32_t* ROMTestPass;

Test result will be stored in this value and main program will check its value to detect pass or fail.

0 = Fail

1 = Pass

Global Values None

Return Values 0

Related Files flash_test_runtime.c

The test function calculates the CRC32 checksum for the flash area specified by ROM_START and ROM_LENGTH defined in iec60730_test_runtime.h file. Then, it compares the checksum with prior calculated value __Check_Sum in the startup_M451Series.s file to determine whether the test is passed or not. The MCU can get CRC32 checksum by hardware interface if the user defines CRC_COMAPRE_WITH_HW in the iec60730_test.h file.

Page 23: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 23 of 30 Rev 1.00

AN0037

5 Function Description of Application Test at Runtime

5.1 GPIO Test

GPIO is tested by three GPIO pin: PB.5, PB.6 and PB.7.

Format uint8_t IEC60730_IO_Test (void);

Arguments None

Global Values None

Return Values 0 = Fail

1 = Pass

Related Files io_test.c

The test function has two parts. The first part which needs to connect PB.6 with PB.7. PB.6 will output a signal to PB.7. Then it compares the signal to check the I/O output and input function.

As to the second part, the MCU checks the I/O status by register directly. The PIN register will show the actual level of PB.5.

5.2 SPI Test

SPI is tested by SPI0_MISO and SPI0_MOSI.

Format uint8_t IEC60730_SPI_Test (void);

Arguments None

Global Values None

Return Values 0 = Fail

1 = Pass

Related Files SPI_test.c

The SPI test needs to connect SPI0_MISO with SPI0_MOSI. SPI0 will transfer 256 bytes data and get feedback data. If the data is the same, the SPI test is passed.

Page 24: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 24 of 30 Rev 1.00

AN0037

5.3 PWM Test

PWM is tested by PWM1_CH0 and PWM1_CH2

Format uint8_t IEC60730_PWM_Test (void);

Arguments None

Global Values None

Return Values 0 = Fail

1 = Pass

Related Files PWM_test.c

The PWM test needs to connect PWM1_CH0 with PWM1_CH2. It will set PWM1_CH0 to output a 10 kHz waveform and set PWM1_CH2 as capture mode. It calculates the capture data to get the waveform period. If the captured period is 10 kHz, the PWM test is passed.

5.4 ADC Test

ADC is tested by ADC_CH1 with VLDO.

Format uint8_t IEC60730_AD_Test (void);

Arguments None.

Global Values uint8_t u8ConvertTimes – ADC sample times.

uint8_t u8ADCStop – Flag to indicate whether ADC sample is finished or not.

uint32_t u32ConvertResVgap – the ADC result of VBG

uint32_t u32ConvertResVldo – the ADC result of VLDO

Return Values 0 = Fail

1 = Pass

Related Files ad_test.c

The ADC test calculates the VREF value by VBG value. Then it can use the VREF to calculate the voltage of the MCU VLDO pin by connect it with ADC_CH1. If the difference of these VLDO value is larger than 1.98V or smaller than 1.62V, the test is failed.

Page 25: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 25 of 30 Rev 1.00

AN0037

6 STL Evaluation Board

6.1 STL Evaluation Board Overview

The Nuvoton STL evaluation board is based on the Cortex® -M4 M452RE6AE microcontroller. It implements a test setting interface to enable test items on the board. In addition, it has an external interface included with 6-ch PWM, 2-ch ADC and 2-ch ACMP. It could be used to connect external application board. User can develop their own application board to extend the test items by themselves.

The Nuvoton STL evaluation board is shown in Figure 6-1.

Figure 6-1 Nuvoton STL Evaluation Board

6.2 Test Setting Table

The STL EVB is set by these connectors. The connectors need to be short or open before the MCU executes the test item. The GPIO test setting is different with the SPI test so it can only be enabled individually.

Test Items JP9 JP11 JP12 JP13 JP15

ADC Test Short(1,2)

PWM Test Short(1,2)

GPIO Test Short(1,2) Open(1,2)

SPI Test Short(1,2)

Table 6-1 Test Setting Table

Reset Button

M452RE6AE

ICE Debug Interface

Test Setting Interface

External Interface

Page 26: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 26 of 30 Rev 1.00

AN0037

6.3 Schematics

6.3.1 MCU Schematic

Figure 6-2 MCU Schematic

USB_PWR_EN P50USB_OC# P49

12 D2

NC

RB060L

VDD

P20

12

D1

SS24A

RB060L

R14

0

R0603

C13

0.1u

C0603

USB_VBUS

D-

P19

D+

X2

12MHz SMD X3225BXIN

1

GN

D2

GN

D4

XO

UT

3

C920p

C0603

DX

32

OP

14

C120p

C0603

P20P18

P28P26P24P22

P32P30

ICE

RS

TP

5

P18

P7

X1

X3215 32.768KHz SMD

P8

LE

D

P55P54

P56

P53

P2

US

B_

D+

P46

US

B_

IDP

47

P10P8P6P4

P43

US

B_

D-

P45

US

B_

VB

US

P44

P16P14P12

ICE

CL

KP

35

ICE

DA

TP

36

ADAVSS

D12MOP22

P24

P26P27

D12MIP23

P25

R210R0603

VDD

P36P34

P44P42P40P38

P17

P48P46

P13

P33

ICE

TX

D12MO

R70R0603

P50

ICETX

P58P56P54P52

P64P62P60

D12MI

R5

330R0603

12

IO1

0805LED_Red

KP-2012

VDD

R20R0603

LE

D

R60R0603

DX32O

DX32I

P51

P34

ICE

RX

ICERX

C3

10uF/10V

TANT-A

P52

R15

0

R0603

P37

C810uF/10V

TANT-A

C5

10uF/10V

TANT-A

C11

1u

C0603

P57

D+

D-

AVDDVREF

12

POWER1

0805LED_Red

KP-2012

R4

330R0603

VREF

C7

0.1u

C0603

P58

USB_ID

D-

D+

C21

0.1u

C0603

VDD

USB_OC#

C6

0.1u

C0603

R8 27

R0603

P38

CB1

0.1u

C0603

L3 L0603

U4

TPS2065CDBVR-2

OUT1

GND2

OC#3

IN5

EN/EN#4

NCT3520U High Active

USB_D-

USB_D+R10 27

R0603

J3

NC

VBUS1

D-2

D+3

GND5

ID4 Shield

6

Shield7

Shield8

Shield9

+

CT1

1uF/6.3V

TANT-A

C4

0.1u

C0603

R22

NCR0603

J1

NC

12345

P59

U1

M452RE6AE

PC.532

PC.431

PC.027PC.128

PC.330

PC.229

LDO_CAP26

VDD25

VSS24

PF.4/XT1_IN23

PF.3/XT1_OUT22

PD.721

PD.1520

PD.1419

PD.1318

PD.1217

PF

.216

X3

2I_

PF

.115

X3

2O

/PF

.014

PD

.211

PD

.110

PD

.99

PD

.88

VB

AT

13

PB

.63

AV

SS

7P

D.0

6

PB

.74

nR

ES

ET

5

PD

.312

PB

.15

1

PB.1163 PB.862 PB.461 PB.360 PB.259 PB.158

PB.1264

PB.057 VREF56 AVDD55 VDD54 VSS53 PA.052 PA.151 PA.250 PA.349

US

B_

VD

D3

3_

CA

P48

PF

.7/U

SB

_ID

47

US

B_

D+

46

US

B_

D-

45

US

B_

VB

US

44

VD

DIO

43

PE

.13

42

PE

.12

41

PE

.11

40

PE

.10

39

PE

.938

PE

.837

PF

.6/I

CE

_D

AT

36

PF

.5/I

CL

E_

CL

K35

PC

.734

PC

.633

PB

.52

USB_ID

P1

P5P3

P39

JP7

NC

1 23 45 67 89 1011 1213 1415 16

JP8

NC

1 23 45 67 89 1011 1213 1415 16

JP6

NC

1 23 45 67 89 1011 1213 1415 16

P7P9

P13P11

JP5

NC

1 23 45 67 89 1011 1213 1415 16

P15P14P16

P8

P12

P6

P10

P17

P31

P23

P2P4

P25

P29

P19P21

P27

P32

P24

P30

P20P22

P47

P39

P33

P26P28

P18

P36

P41

P45

P35P37

P44

P48

P40

P34

P46

R23

NCR0603

P51

P63

P55

P49

P42

P38

P62

P53

P59P57

P61

P54

P60

P64

P56

P50

P43P58

P52

P60

P40

R24

15kR0603

P1

ICEDAT

ICERST

VDDJP2

NC

1 23 45 67 89 10

ICECLK

VDD

R1

10K

R0603

ICERST

SW1

PUSH BOTTOM-4 Pin

SW

R170R0603

R25

15kR0603

ICETXICERX

C1020p

C0603

C220p

C0603

P61

JP1

NC

12

JP4

NC

12

P41

USB Host/Device

VCC5

Reset Crystal

P1

Debug Interface & Off Page

P62

P42

USB_VBUS

P32

NCT3520U pin3(OC#) is Open Drain Pin

P63

USB_OC#

R114.7K

R0603

VDD

VDD

ADAVSS

P2

P3

AVDDL1

L0603

P3

P5

R20

0R0603

P64

P48

P7

P4

LED

P9

DX

32

IP

15

P11

P6

Connector

P13

P31

P9

P15

R30R0603

P30

P35P33

P43P41P39P37

Power

P47P45

P10

CON1mini USB 5pin

USB_MINI_B

GND5 NC4 DP3 DM2 VCC1

SHIELD6

SHIELD7

SHIELD8

SHIELD9

TICEDAT

VDD

TICECLK

USB_IDD+

TICERST

R9

NC

R0603

VDD

D-

USB_PWR_EN

USB_VBUS

P21P19P17

P29

P29P27P25P23

P31

L2

L0603

C12

1u

C0603

P11

P53P51P49

P61P59P57P55

P63

P28

P12

P21

P16

Page 27: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 27 of 30 Rev 1.00

AN0037

6.3.2 Application Schematic

Figure 6-3 Application Schematic

6.3.3 External Interface

Figure 6-4 External Interface

This external interface is included with 6-ch PWM, 2-ch ADC and 2-ch ACMP. It could be used to connect external application board. User can develop their own application board to extend the test items by themselves.

External Motor Driver Interface

JP16

NC

1 23 45 67 89 1011 1213 1415 16

P31 PWM0_CH4

P27 PWM0_CH0

P29 PWM0_CH2P30 PWM0_CH3

P32 PWM0_CH5

P28 PWM0_CH1P6 ACMP1_NP9 ACMP1_P3

AVDDAVDD

ADAVSS ADAVSS

P64 ADC_CH9P1 ADC_CH12

R18 1k

R0603

CLK Output & PWM Capture

ADAVSS

ADC_CH4_A

P37 PE8 CLK_Output

GNDAVDD

PWM Output & PWM Capture

AVSS

JP11

NC

12VDD

VDD

VDD

P19 PD14 PWM1_CH2P17 PD12 PWM1_CH0

P51 PA1 PWM1_CH4

P61

CB3

2.2u

C0603

JP12

NC

12

I/O Test

P7P9

P1

P5P3

P39

P33

P15P13P11

P41

P45

P35P37

P47

P7P5P3P1

P43

P15P13P11P9

P39P37P35P33

P47P45P43P41

P4 PB7

P20P18

P28P26P24P22

P4P2

P32P30

P12P10P8P6

P36P34

P16P14

P44P42P40P38

P52P50

P48P46

P60P58P56P54

P3 PB6

JP10

NC

123

P64P62

P12

P6

P2P4

P14P16

P8P21

P27P10

P17

P31

P23

P20P22

P25

P29

P19

P28

P18

P32

P24

P30

P48

P40

P34

P46

P36

P26

P55

P49

P42

P38

P44 P59P57

P61

P51

P63

P60

P64

P56

P50

P62

P53

P19P17

P58

P52P54

P27P25P23P21

P51P49

P31P29

P59P57P55P53

VDD

P63P61

P62

R16

1k

R0603

DAC Test

JP15

NC

12

P57 PB0 DACP63 PB11 ADC_CH8

R13 1m

R0603

CB10

100n

C0603

CB11

22u

C0603

ADC_CH5_V

SPI Test

P58 PB1 ADC_CH1

JP13

NC

12

ADC CH1 & LDO Voltage

P2 PB5 SPI0_MOSI

P26 LDO

P60 PB3 SPI0_MISO

JP9

NC

12

P12 PD3 Timer1_EXT_Input

CB2

100n

C0603

I & V Monitor

U7

INA199

REF1

GND2

VCC3

IN_N4 IN_P5 OUT6

AVDD

Page 28: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 28 of 30 Rev 1.00

AN0037

7 Conclusion

When home appliances are under development, home appliances should follow the requirements specified in the IEC60730-1 standard for safety. Nuvoton provide an IEC60730-1 class B Software Test Library (STL) to implement MCU basic requirements specified in Annex H MCU part of the IEC60730-1 standard. It consists of several kinds of test items, including CPU register, Program Counter, WDT, Stack, Interrupt, RAM and Flash tests to detect the system fault/error. User can implement safety function based on the fault/error event to protect the system from dangers like fire hazard or motor rotor fault.

This STL collects common sets of tests dedicated mainly to generic blocks of M4 microcontroller family. User could take this application note to know the test items. According to the description of these test items, the user can include the STL package into a final project. In addition, the STL can be modified easily based on the application function of the product to achieve rapid development flow for IEC60730-1.

Finally, the user can implement a reliability and safety system compliant with IEC60730-1 safety standards.

Page 29: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 29 of 30 Rev 1.00

AN0037

Revision History

Date Revision Description

2019.09.30 1.00 1. Initially issued.

Page 30: Introduction to Nuvoton IEC60730-1 Class B STL · Sep 30, 2019 Page 4 of 30 Rev 1.00 AN0037 1 Overview IEC60730-1 is a safety standard for all home appliances sold in Europe. To accelerate

Sep 30, 2019 Page 30 of 30 Rev 1.00

AN0037

Important Notice

Nuvoton Products are neither intended nor warranted for usage in systems or equipment, any malfunction or failure of which may cause loss of human life, bodily injury or severe property damage. Such applications are deemed, “Insecure Usage”.

Insecure usage includes, but is not limited to: equipment for surgical implementation, atomic energy control instruments, airplane or spaceship instruments, the control or operation of dynamic, brake or safety systems designed for vehicular use, traffic signal instruments, all types of safety devices, and other applications intended to support or sustain life.

All Insecure Usage shall be made at customer’s risk, and in the event that third parties lay claims to Nuvoton as a result of customer’s Insecure Usage, customer shall indemnify the damages and liabilities thus incurred by Nuvoton.