]> git.sur5r.net Git - freertos/blob - Demo/HCS12_CodeWarrior_banked/cmd/P&E_ICD_Erase_unsecure_hcs12.cmd
Start to re-arrange files to include FreeRTOS+ in main download.
[freertos] / Demo / HCS12_CodeWarrior_banked / cmd / P&E_ICD_Erase_unsecure_hcs12.cmd
1 // HCS12 Core erasing + unsecuring command file:\r
2 // These commands mass erase the chip then program the security byte to 0xFE (unsecured state).\r
3 \r
4 // Evaluate the clock divider to set in ECLKDIV/FCLKDIV registers:\r
5 \r
6 // An average programming clock of 175 kHz is chosen.\r
7 \r
8 // If the oscillator frequency is less than 10 MHz, the value to store\r
9 // in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) / 175 ".\r
10 \r
11 // If the oscillator frequency is higher than 10 MHz, the value to store\r
12 // in ECLKDIV/FCLKDIV is equal to " oscillator frequency (kHz) / 1400  + 0x40 (to set PRDIV8 flag)".\r
13 \r
14 // Datasheet proposed values:\r
15 //\r
16 // oscillator frequency     ECLKDIV/FCLKDIV value (hexadecimal)\r
17 //\r
18 //  16 MHz                $49\r
19 //   8 MHz                $27\r
20 //   4 MHz                $13\r
21 //   2 MHz                $9\r
22 //   1 MHz                $4\r
23 \r
24 define CLKDIV 0x49\r
25 \r
26 FLASH MEMUNMAP   // do not interact with regular flash programming monitor\r
27 \r
28 //mass erase flash\r
29 wb 0x100 CLKDIV  // set FCLKDIV clock divider\r
30 wb 0x103 0       // FCFNG select block 0\r
31 wb 0x102 0x10    // set the WRALL bit in FTSTMOD to affect all blocks\r
32 wb 0x104 0xFF    // FPROT all protection disabled\r
33 wb 0x105 0x30    // clear PVIOL and ACCERR in FSTAT register\r
34 ww 0x108 0xD000  // write to FADDR address register\r
35 ww 0x10A 0x0000  // write to FDATA data register\r
36 wb 0x106 0x41    // write MASS ERASE command in FCMD register\r
37 wb 0x105 0x80    // clear CBEIF in FSTAT register to execute the command\r
38 wait 20          // wait for command to complete\r
39 \r
40 //mass erase eeprom\r
41 wb 0x110 CLKDIV  // set ECLKDV clock divider\r
42 wb 0x114 0xFF    // EPROT all protection disabled\r
43 wb 0x115 0x30    // clear PVIOL and ACCERR in ESTAT register\r
44 ww 0x118 0x0400  // write to EADDR eeprom address register\r
45 ww 0x11A 0x0000  // write to EDATA eeprom data register\r
46 wb 0x116 0x41    // write MASS ERASE command in ECMD register\r
47 wb 0x115 0x80    // clear CBEIF in ESTAT register to execute the command\r
48 wait 20          // wait for command to complete\r
49 \r
50 reset\r
51 \r
52 //reprogram Security byte to Unsecure state\r
53 wb 0x100 CLKDIV  // set FCLKDIV clock divider\r
54 wb 0x103 0       // FCFNG select block 0\r
55 wb 0x104 0xFF    // FPROT all protection disabled\r
56 wb 0x105 0x30    // clear PVIOL and ACCERR in FSTAT register\r
57 ww 0xFF0E 0xFFFE // write security byte to "Unsecured" state\r
58 wb 0x106 0x20    // write MEMORY PROGRAM command in FCMD register\r
59 wb 0x105 0x80    // clear CBEIF in FSTAT register to execute the command\r
60 wait 20          // wait for command to complete\r
61 \r
62 reset\r
63 \r
64 FLASH MEMMAP     // restore regular flash programming monitor\r
65 undef CLKDIV     // undefine variable\r
66 \r