📄 hcs08unsecure.cmd
字号:
// HCS908 erasing + unsecuring command file:
// These commands mass erase the chip then program the security byte to 0xFE (unsecured state + backdoor key mechanism enabled).
// Evaluate the clock divider to set in FCDIV register:
// An average programming clock of 175 kHz is chosen.
// If the bus frequency is less than 10 MHz, the value to store
// in FECDIV is equal to " bus frequency (kHz) / 175 ".
// If the bus frequency is higher than 10 MHz, the value to store
// in FECDIV is equal to " bus frequency (kHz) / 1400 + 0x40 (to set PRDIV8 flag)".
// Datasheet proposed values:
//
// bus frequency FECDIV value (decimal)
//
// 20 MHz 76
// 10 MHz 49
// 8 MHz 39
// 4 MHz 19
// 2 MHz 9
// 1 MHz 4
// 200 kHz 0
// 150 kHz 0
define FCDIV 19
FLASH release
wb 0x1802 3 // disable COP clearing SIMOPT register + set BKGDPE and RSTPE (when available)
wb 0x1825 0x30 // clear FPVIOL and FACCERR in FSTAT register
wb 0x1824 0xff // remove all flash protections clearing FPROT register
wb 0x1820 FCDIV // set clock divider FCDIV register
// Please see below to find how to evaluate this constant value.
//mass erase flash
wb 0x1825 0x30 // clear FPVIOL and FACCERR in FSTAT register
wb 0xc000 0 // (dummy) write to flash array to buffer address and data
wb 0x1826 0x41 // write MASS ERASE command in FCMD register
wb 0x1825 0x80 // set FCBEF in FSTAT register to execute the command
wait 20
//blankcheck flash
wb 0x1825 0x30 // clear FPVIOL and FACCERR in FSTAT register
wb 0xc000 0 // (dummy) write to flash array to buffer address and data
wb 0x1826 0x5 // write BLANK CHECK command in FCMD register
wb 0x1825 0x80 // set FCBEF in FSTAT register to execute the command
wait 20
//reprogram Security byte to Unsecure state
wb 0x1820 FCDIV // set clock divider FCDIV register
wb 0x1825 0x30 // clear FPVIOL and FACCERR in FSTAT register
wb 0xffbf 0xfe // write NVFEOPT register in flash array to UNSECURED state with Backdoor Key Mechanism enabled
wb 0x1826 0x20 // write BYTE PROGRAM command in FCMD register
wb 0x1825 0x80 // set FCBEF in FSTAT register to execute the command
wait 10
reset
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -