
AN3006 Software recommendations
Doc ID 15988 Rev 1 9/12
5 Software recommendations
The standard software techniques for improving EMC performance described in the AN1015
application note (“Software techniques for improving microcontroller EMC performance”)
also apply to the STM8A product family.
This section lists the STM8A specifications related to the software techniques written in the
AN1015. It gives the values for STM8A products, although it is strongly recommended to
read the AN1015 carefully in order to safely implement the software recommendations.
5.1 Critical bytes
It is recommended avoiding the following critical bytes in your code:
●0x8E: opcode for HALT (instruction used to enter low power modes)
●0x8F: opcode for WFI (instruction Wait For Interrupt)
●0x82, 0xAC: opcode for INT (instruction used to jump into an interrupt routine)
●0x8B: opcode for SWBRK (software breakpoint instruction used to stall the CPU in
debug mode)
These critical bytes can be generated by the linker when computing the address destination
of a branch instruction (JUMP or CALL) in absolute or relative addressing modes. To
remove such critical bytes you can simply insert a NOP instruction before the target
address. For further explanation, refer to the AN1015 application note.
5.2 Illegal opcodes
To better control unexpected jumps, it is recommended to fill unused memory areas with
TRAP opcode (0x83).
Besides, if you want to generate an illegal opcode reset, the simpler illegal opcodes are the
following: 0x05, 0x0B, 0x71 and 0x75.
With pre-opcode, the list is longer:
●0x7220..0x722F, 0x7231, 0x7232, 0x7235, 0x723B, 0x7241, 0x7242, 0x7245, 0x724B,
0x7251, 0x7252, 0x7255, 0x725B, 0x7261, 0x7262, 0x7265, 0x726B, 0x7280..0x728E,
0x7290..0x72A1, 0x72A3..0x72A8, 0x72AA..0x72AF, 0x72B1, 0x72B3..0x72B8,
0x72BA, 0x72BC..0x72BF, 0x72E0..0x72EF, 0x72F1, 0x72F3..0x72F8, 0x72FA,
0x72FC..0x72FF
●0x9000, 0x9003..0x900F, 0x9020..0x9027, 0x902A, 0x902B, 0x9030..0x903F, 0x9041,
0x9045, 0x904B, 0x9051, 0x9055,0x905B, 0x9061, 0x9065,0x906B, 0x9071, 0x9072,
0x9075, 0x907B, 0x9080..0x9084, 0x9086..0x9088, 0x908A..0x908F, 0x9090..0x9092,
0x9098..0x909D, 0x90A0..0x90A2, 0x9090A4..0x90A6, 0x90A8..0x90AD,
0x90B0..0x90B2, 0x90B4..0x90BD, 0x90C0..0x90C2, 0x90C4..0x90CD
●0x9100..0x915F, 0x9161, 0x9162, 0x9165, 0x916B,0x9170..0x91A6, 0x91A8..0x91AE,
0x91B0..0x91C2, 0x91C4..0x91CD, 0x91E0,0x91FF
●0x9200..0x922F, 0x9231, 0x9232, 0x9235, 0x923B, 0x9240..0x925F, 0x9261, 0x9262,
0x9265, 0x926B, 0x9270..0x928C, 0x928E..0x92A6, 0x92A8..0x92AB, 0x92AD,
0x92AE, 0x92B0..0x92BB, 0x92BE, 0x92BF, 0x92E0..0x92FF.