4.6.1.10 Errata Option

The -merrata=type option allows specification of software workarounds to documented silicon errata issues. A default set of errata apply to each device, but this set can be adjusted by using this option and the arguments presented in the table below.

Table 4-12. Errata Workarounds
Type#Avoided Issue
40000Program memory accesses/jumps across 4000h address boundary
fastints1Fast interrupt shadow registers corruption
lfsr2Broken LFSR instruction
minus403Program memory reads at -40 degrees
reset4goto instruction cannot exist at Reset vector
bsr155Flag problems when BSR holds value 15
daw6Broken DAW instruction
eedatard7Read EEDAT in immediate instruction after RD set
eeadr8Don't set RD bit immediately after loading EEADR
ee_lvd9LVD must stabilize before writing EEPROM
fl_lvd10LVD must stabilize before writing Flash
tblwtint11Clear interrupt registers before tblwt instruction
fw400012Flash write exe must act on opposite side of 4000h boundary
resetram13RAM contents can corrupt if async. Reset occurs during write access
fetch14Corruptible instruction fetch. – applies FFFFh (nop) at required locations
clocksw15Code corruption if switching to external oscillator clock source – applies switch to HFINTOSC high-power mode first
branch16The PC might become invalid when restoring from an interrupt during a bra or brw instruction — avoids branch instructions
brknop217Hardware breakpoints might be affected by bra instruction — avoids branching to the following location
nvmreg18The program will access data flash rather than program flash memory after a reset — adjusts the NVMCON register
bsr6319Corrupted execution of movff instruction when the BSR holds 63

At present, workarounds are mainly employed for PIC18 devices, but the clocksw and branch errata are only applicable for some enhanced Mid-range devices.

To disable all software workarounds, use the following.

-merrata=none

To maintain all the default workarounds but disable the jump across 4000 errata, for example, use the following:

-merrata=default,-4000

The value assigned to the preprocessor macro _ERRATA_TYPES (see Predefined Macros) indicates the errata applied. Each errata listed in Table 4-12 table represents one bit position in the macro’s value, with the topmost errata in the table being the least significant. That bit position in the _ERRATA_TYPES macro is set if the corresponding errata is applied. The header file <errata.h> contains definitions for each errata value, for example ERRATA_4000 and ERRATA_FETCH, which can be used with the compiler-defined _ERRATA_TYPES macro to determine which erratas are in effect.