HT8 UL60730 Safety Library -- Program Counter Register Test D/N: AN0385E Introduction In general, the UL/CSA 60730 safety standard applies to automatic electrical controls for use in, on, or in association with equipment for household and similar use, including controls for heating, air-conditioning and similar applications. The equipment may use electricity, gas, oil, solid fuel, solar thermal energy, etc., or a combination thereof. This Standard applies to the inherent safety; to the operating values, operating times, and operating sequence where such are associated with equipment safety; and to the testing of automatic electrical control devices used in, or in association with, household or similar equipment. Annex H of the UL/CSA 60730 safety standard defines three classes of control software for appliances: 1. Class A control functions which are not intended to be relied upon for the safety of the equipment. 2. Class B software that includes code intended to prevent hazards if a fault, other than a software fault, occurs in the appliance. 3. Class C software that includes code intended to prevent hazards without the use of other protective devices. 1 / 5 AN0385E
Class B Safety Library The HT8 UL60730 Safety Library is open-source software intended be integrated in the end product application software and called upon power-on initialization and/or periodically within the application to achieve the periodic self-test safety requirements in UL/CSA 60730-1 Annex H.11.12 for software/control Class B. 2 / 5 AN0385E
Program Counter Register Test Introduction The device contains a WDT function, which is provided to prevent Program Counter malfunction or program sequences from jumping to unknown locations, due to certain uncontrollable external events such as electrical noise. When the Program Counter malfunctions, a Watchdog Timer time-out will occur which will initialise a device reset and set the status bit TO. The program will set I/O port pf2 output high to inform users that a Program Counter malfunction has occurred. MCU Internal Function Description Program Counter Principle The Program Counter is an MCU internal register which is used to indicate the present instruction sequence execution. The Program counter may store the present instruction or keep track of the address of the next instruction to be executed. It is automatically incremented by one each time an instruction is executed, so instructions can be properly fetched from memory. For instructions, such as jump and call instructions, the program sequence will be interrupted and new data content will be loaded into the Program Counter. The Program Counter is immediately incremented after fetching the program instruction. This means that the destination address of the jump instruction is obtained by the operator of the jump instruction adding the next instruction address. The actual operation situation of the Program Counter is illustrated in the following figure: The main program will call the sub subroutine when executing the aa line, the PC aa address. Push the bb address onto the stack. The program will jump to execute the sub subroutine, PC yy Execute the return instruction (RET) at the end of the sub subroutine. Pop the bb address from the stack. Return to the main program at location bb to continue with program execution, PC bb 3 / 5 AN0385E
Program Counter Error Detection Flowchart 4 / 5 AN0385E
Program Counter Error Detection Flowchart Description Step 1 Set _wdtc = 0x50 to enable the Watchdog Timer function and to select a Watchdog Timer timeout period of 7.8125ms. Jump to step 2. (Note: Users can select different Watchdog Timer time-out periods according to their requirements.) Step 2 Is Watchdog time-out flag (TO) =1? Yes, set pf2=1. Watchdog Timer overflow occurs due to a Program Counter malfunction. Jump to step 3. No, jump to step 3. Step 3 Program Counter malfunctions or jumps to an unknown location? Yes, Watchdog Timer overflows which automatically resets the device and sets the TO flag. Jump to step 1. No, jump to step 4. Step 4 Use the CLR WDT instruction to clear the Watchdog Timer. Jump to step 5. Step 5 Execute user code first and then jump back to step 3. 5 / 5 AN0385E