Part # Application Note General Purpose Products 8-Bit Microcontrollers AN1015 datasheet

Part Manufacturer: ST Microelectronics

ST Microelectronics

Part Description: Software techniques for improving microcontroller EMC performance


Part Details:

AN1015 APPLICATION NOTE SOFTWARE TECHNIQUES FOR IMPROVING MICROCONTROLLER EMC PERFORMANCE by Microcontroller Division Applications 1 INTRODUCTION A major contributor to improved EMC performance in microcontroller-based electronics sys-tems is the design of hardened software. To achieve this goal, you have to include EMC considerations as early as possible in the de-sign phase of your project. EMC-oriented software increases the security and the reliability of your application. EMC-hardened software is inexpensive to implement, it improves the MCU s immunity performanceand saves hardware costs. You should consider EMC disturbances to analog or digital data asparameters that must be managed by the MCU software just like any other application param-eter. Examples of software disturbances: ­ Microcontroller not responding ­ Program Counter runaway ­ Execution of unexpected instructions ­ Bad address pointing ­ Bad execution of subroutines ­ Parasitic reset ­ Parasitic interrupts ­ I/O deprogramming AN1015/0701 1/14 1 SOFTWARE TECHNIQUES FOR IMPROVING EMC PERFORMANCE Examples of the consequences of failing software: ­ Unexpected commands ­ Loss of context ­ Unexpected branch in process ­ Loss of interrupts ­ Loss of data integrity ­ Wrong input measurement values This application note describes software techniques divided into two categories: ­ Preventive techniques ­ Auto-recovery techniques You can implement preventive techniques in existing programs. Their purpose is to avoid vis-ible disturbances at user level. The software must include auto-recovery routines. When a runaway condition is detected, arecovery subroutine is used to take the decision to stop program execution, optionally give awarning and then return automatically to normal operations. This operation may be absolutelytransparent to the user of the application. 2 PREVENTIVE TECHNIQUES You can easily implement these techniques in an existing program as they do not require anychange to the structure of the software. 2.1 USING THE WATCHDOG CORRECTLY The watchdog is the most efficient tool you have available for ensuring that the MCU can re-cover from software runaway failures. Its principle is very simple: it is a timer which generates an MCU reset at the end of count. The only way of preventing the Watchdog resetting the mi-crocontroller is to refresh the counter periodically in the program. But to make the watchdog work at its full potential, you have to insert the enable and refreshinstructions in your software in the right way. Figure 1 shows the classic examples of bad watchdog implementation: To do it the right way, the golden rules are: ­ Enable the watchdog as soon as possible after reset, or use the Hardware Watchdog option if its available. ­ Never refresh the watchdog in an interrupt routine. 2/14 1 SOFTWARE TECHNIQUES FOR IMPROVING EMC PERFORMANCE It is very important to optimize the period between the two refresh instructions according to theduration of the various routines, including the interrupt rountines. The minimum use of the watchdog resets the MCU, this means that the program executioncontext is lost as well as the application data s integrity. After reset, in addition to enabling the watchdog, on some MCUs you can use the reset flagsto distinguish between a Power On or Low Voltage reset and a Watchdog reset (refer to Sec-tion 3.3. for more details)Figure 1. Classic Examples of Bad Watchdog Usage INIT WDG ENABLE


Please click the following link to download the datasheet:

Application Note General Purpose Products 8-Bit Microcontrollers AN1015.pdf Datasheet