1 /******************************************************************************/
\r
2 /* LPC43XX-FLASH-DEBUG.INI: External Memory Interface initialization for */
\r
3 /* LPC43xx first revision (Sept 2011). */
\r
4 /* The purpose is to be able to debug a program */
\r
5 /* located in the external flash. */
\r
6 /******************************************************************************/
\r
7 FUNC void Pre_Setup (void) {
\r
9 /* configure M0 for infinite loop */
\r
10 _WDWORD(0x10080000,0x00001F00); /* dummy stack pointer */
\r
11 _WDWORD(0x10080004,0x000000D5); /* reset handler */
\r
12 _WDWORD(0x100800D4,0xE7FEE7FE); /* jump to itself instruction for M0a */
\r
13 _WDWORD(0x40043404,0x10080000); /* M0 shadow pointer. */
\r
15 /* release M0 from reset to allow Jtag access */
\r
16 _WDWORD(0x40053104,(~(_RDWORD(0x40053154))) & (~(1<<24)));
\r
18 // u32Val = (~(u32REG) & (~(1 << 24))); // clear the control bit
\r
19 // LPC_RGU->RESET_CTRL1 = (~( LPC_RGU->RESET_ACTIVE_STATUS1 )) & (0 << 24); //Release M0
\r
24 FUNC void Setup (void)
\r
26 // With the values used here, the program had to be linked to CS0 memory
\r
27 // located at 0x1C000000 in the LPC43xx.
\r
29 /* This would be used in case there is a 16-byte header in the image */
\r
33 SP = _RDWORD(0x1c000100); // Setup Stack Pointer
\r
34 PC = _RDWORD(0x1C000104); // Setup Program Counter
\r
36 _WDWORD(0xE000ED08, 0x1C000100); // Setup Vector Table Offset Register
\r
41 /* This is used for plain images, without a 16-byte header */
\r
43 SP = _RDWORD(0x1C000000); // Setup Stack Pointer
\r
44 PC = _RDWORD(0x1C000004); // Setup Program Counter
\r
46 _WDWORD(0xE000ED08, 0x1C000000); // Setup Vector Table Offset Register
\r
51 FUNC void emc_setup (void)
\r
53 // bus signals for external memory
\r
54 _WDWORD(0x4008609C, 0x000000F3); /* P1_7: D0 (function 3) */
\r
55 _WDWORD(0x400860A0, 0x000000F3); /* P1_8: D1 (function 3) */
\r
56 _WDWORD(0x400860A4, 0x000000F3); /* P1_9: D2 (function 3) */
\r
57 _WDWORD(0x400860A8, 0x000000F3); /* P1_10: D3 (function 3) */
\r
58 _WDWORD(0x400860AC, 0x000000F3); /* P1_11: D4 (function 3) */
\r
59 _WDWORD(0x400860B0, 0x000000F3); /* P1_12: D5 (function 3) */
\r
60 _WDWORD(0x400860B4, 0x000000F3); /* P1_13: D6 (function 3) */
\r
61 _WDWORD(0x400860B8, 0x000000F3); /* P1_14: D7 (function 3) */
\r
62 _WDWORD(0x40086280, 0x000000F2); /* P5_0: D12 (function 2) */
\r
63 _WDWORD(0x40086284, 0x000000F2); /* P5_1: D13 (function 2) */
\r
64 _WDWORD(0x40086288, 0x000000F2); /* P5_2: D14 (function 2) */
\r
65 _WDWORD(0x4008628C, 0x000000F2); /* P5_3: D15 (function 2) */
\r
66 _WDWORD(0x40086290, 0x000000F2); /* P5_4: D8 (function 2) */
\r
67 _WDWORD(0x40086294, 0x000000F2); /* P5_5: D9 (function 2) */
\r
68 _WDWORD(0x40086298, 0x000000F2); /* P5_6: D10 (function 2) */
\r
69 _WDWORD(0x4008629C, 0x000000F2); /* P5_7: D11 (function 2) */
\r
70 _WDWORD(0x40086688, 0x000000F2); /* PD_2: D16 (function 2) */
\r
71 _WDWORD(0x4008668C, 0x000000F2); /* PD_3: D17 (function 2) */
\r
72 _WDWORD(0x40086690, 0x000000F2); /* PD_4: D18 (function 2) */
\r
73 _WDWORD(0x40086694, 0x000000F2); /* PD_5: D19 (function 2) */
\r
74 _WDWORD(0x40086698, 0x000000F2); /* PD_6: D20 (function 2) */
\r
75 _WDWORD(0x4008669C, 0x000000F2); /* PD_7: D21 (function 2) */
\r
76 _WDWORD(0x400866A0, 0x000000F2); /* PD_8: D22 (function 2) */
\r
77 _WDWORD(0x400866A4, 0x000000F2); /* PD_9: D23 (function 2) */
\r
78 _WDWORD(0x40086714, 0x000000F3); /* PE_5: D24 (function 3) */
\r
79 _WDWORD(0x40086718, 0x000000F3); /* PE_6: D25 (function 3) */
\r
80 _WDWORD(0x4008671C, 0x000000F3); /* PE_7: D26 (function 3) */
\r
81 _WDWORD(0x40086720, 0x000000F3); /* PE_8: D27 (function 3) */
\r
82 _WDWORD(0x40086724, 0x000000F3); /* PE_9: D28 (function 3) */
\r
83 _WDWORD(0x40086728, 0x000000F3); /* PE_10: D29 (function 3) */
\r
84 _WDWORD(0x4008672C, 0x000000F3); /* PE_11: D30 (function 3) */
\r
85 _WDWORD(0x40086730, 0x000000F3); /* PE_12: D31 (function 3) */
\r
87 _WDWORD(0x40086124, 0x000000F3); /* P2_9: A0 (function 3) */
\r
88 _WDWORD(0x40086128, 0x000000F3); /* P2_10: A1 (function 3) */
\r
89 _WDWORD(0x4008612C, 0x000000F3); /* P2_11: A2 (function 3) */
\r
90 _WDWORD(0x40086130, 0x000000F3); /* P2_12: A3 (function 3) */
\r
91 _WDWORD(0x40086134, 0x000000F3); /* P2_13: A4 (function 3) */
\r
92 _WDWORD(0x40086080, 0x000000F2); /* P1_0: A5 (function 2) */
\r
93 _WDWORD(0x40086084, 0x000000F2); /* P1_1: A6 (function 2) */
\r
94 _WDWORD(0x40086088, 0x000000F2); /* P1_2: A7 (function 2) */
\r
95 _WDWORD(0x40086120, 0x000000F3); /* P2_8: A8 (function 3) */
\r
96 _WDWORD(0x4008611C, 0x000000F3); /* P2_7: A9 (function 3) */
\r
97 _WDWORD(0x40086118, 0x000000F2); /* P2_6: A10 (function 2) */
\r
98 _WDWORD(0x40086108, 0x000000F2); /* P2_2: A11 (function 2) */
\r
99 _WDWORD(0x40086104, 0x000000F2); /* P2_1: A12 (function 2) */
\r
100 _WDWORD(0x40086100, 0x000000F2); /* P2_0: A13 (function 2) */
\r
101 _WDWORD(0x40086320, 0x000000F1); /* P6_8: A14 (function 1) */
\r
102 _WDWORD(0x4008631C, 0x000000F1); /* P6_7: A15 (function 1) */
\r
103 _WDWORD(0x400866C0, 0x000000F2); /* PD_16: A16 (function 2) */
\r
104 _WDWORD(0x400866BC, 0x000000F2); /* PD_15: A17 (function 2) */
\r
105 _WDWORD(0x40086700, 0x000000F3); /* PE_0: A18 (function 3) */
\r
106 _WDWORD(0x40086704, 0x000000F3); /* PE_1: A19 (function 3) */
\r
107 _WDWORD(0x40086708, 0x000000F3); /* PE_2: A20 (function 3) */
\r
108 _WDWORD(0x4008670C, 0x000000F3); /* PE_3: A21 (function 3) */
\r
109 _WDWORD(0x40086710, 0x000000F3); /* PE_4: A22 (function 3) */
\r
111 // control signals for static memory
\r
112 _WDWORD(0x40086094, 0x000000F3); /* P1_5: CS0 (function 3) */
\r
113 _WDWORD(0x400866B0, 0x000000F2); /* PD_12: CS2 (function 2) */
\r
114 _WDWORD(0x40086098, 0x000000F3); /* P1_6: WE (function 3) */
\r
115 _WDWORD(0x4008608C, 0x000000F3); /* P1_3: OE (function 3) */
\r
116 _WDWORD(0x40086090, 0x000000F3); /* P1_4: BLS0 (function 3) */
\r
117 _WDWORD(0x40086318, 0x000000F1); /* P6_6: BLS1 (function 1) */
\r
119 // configure EMC static memory registers
\r
120 _WDWORD(0x40005000, 0x00000001); /* Enable the EMC block */
\r
122 _WDWORD(0x40005200, 0x00000081); /* CS0: 16 bit, WE */
\r
123 _WDWORD(0x40005208, 0x00000000); /* CS0: WAITOEN = 0 */
\r
124 _WDWORD(0x4000520C, 0x00000008); /* CS0: WAITRD = 8 @120MHz for 70ns flash */
\r
126 _WDWORD(0x40005240, 0x00000081); /* CS2: 16 bit, WE */
\r
127 _WDWORD(0x40005248, 0x00000000); /* CS2: WAITOEN = 0 */
\r
128 _WDWORD(0x4000524C, 0x00000007); /* CS2: WAITRD = 7 */
\r
133 /******************************************************************************/
\r
137 /******************************************************************************/
\r
143 // Just set up the memory interface to enable the correct access to the external
\r
144 // flash memory on CS0.
\r
148 // Download the image. This is not a physical download as the image is
\r
149 // (already) in the flash.
\r
150 // If working with ULINK devices an alternative is to check the checkbox "Load Application at Startup" in the
\r
151 // debug settings of µVision (comment the LOAD instruction out).
\r
152 // This mechanism is not used here, because somehow it does not work with the JLINK devices.
\r
153 LOAD Flash\LPC43xx_M4_FLASH.axf INCREMENTAL
\r
159 // Setup for running from a specific memory location
\r