blob: b54edfaf3fadc592e01a393c599ce35ca7469091 [file] [log] [blame]
/******************************************************************************/
/* LPC43XX-FLASH-PROGRAM.INI: External Memory Interface initialization for */
/* LPC43xx first revision (Sept 2011). */
/* The purpose is to be able to program the */
/* external flash using the KEIL ┬ÁVision utility. */
/******************************************************************************/
FUNC void emc_setup (void)
{
// bus signals for external memory
_WDWORD(0x4008609C, 0x000000F3); /* P1_7: D0 (function 3) */
_WDWORD(0x400860A0, 0x000000F3); /* P1_8: D1 (function 3) */
_WDWORD(0x400860A4, 0x000000F3); /* P1_9: D2 (function 3) */
_WDWORD(0x400860A8, 0x000000F3); /* P1_10: D3 (function 3) */
_WDWORD(0x400860AC, 0x000000F3); /* P1_11: D4 (function 3) */
_WDWORD(0x400860B0, 0x000000F3); /* P1_12: D5 (function 3) */
_WDWORD(0x400860B4, 0x000000F3); /* P1_13: D6 (function 3) */
_WDWORD(0x400860B8, 0x000000F3); /* P1_14: D7 (function 3) */
_WDWORD(0x40086280, 0x000000F2); /* P5_0: D12 (function 2) */
_WDWORD(0x40086284, 0x000000F2); /* P5_1: D13 (function 2) */
_WDWORD(0x40086288, 0x000000F2); /* P5_2: D14 (function 2) */
_WDWORD(0x4008628C, 0x000000F2); /* P5_3: D15 (function 2) */
_WDWORD(0x40086290, 0x000000F2); /* P5_4: D8 (function 2) */
_WDWORD(0x40086294, 0x000000F2); /* P5_5: D9 (function 2) */
_WDWORD(0x40086298, 0x000000F2); /* P5_6: D10 (function 2) */
_WDWORD(0x4008629C, 0x000000F2); /* P5_7: D11 (function 2) */
_WDWORD(0x40086688, 0x000000F2); /* PD_2: D16 (function 2) */
_WDWORD(0x4008668C, 0x000000F2); /* PD_3: D17 (function 2) */
_WDWORD(0x40086690, 0x000000F2); /* PD_4: D18 (function 2) */
_WDWORD(0x40086694, 0x000000F2); /* PD_5: D19 (function 2) */
_WDWORD(0x40086698, 0x000000F2); /* PD_6: D20 (function 2) */
_WDWORD(0x4008669C, 0x000000F2); /* PD_7: D21 (function 2) */
_WDWORD(0x400866A0, 0x000000F2); /* PD_8: D22 (function 2) */
_WDWORD(0x400866A4, 0x000000F2); /* PD_9: D23 (function 2) */
_WDWORD(0x40086714, 0x000000F3); /* PE_5: D24 (function 3) */
_WDWORD(0x40086718, 0x000000F3); /* PE_6: D25 (function 3) */
_WDWORD(0x4008671C, 0x000000F3); /* PE_7: D26 (function 3) */
_WDWORD(0x40086720, 0x000000F3); /* PE_8: D27 (function 3) */
_WDWORD(0x40086724, 0x000000F3); /* PE_9: D28 (function 3) */
_WDWORD(0x40086728, 0x000000F3); /* PE_10: D29 (function 3) */
_WDWORD(0x4008672C, 0x000000F3); /* PE_11: D30 (function 3) */
_WDWORD(0x40086730, 0x000000F3); /* PE_12: D31 (function 3) */
_WDWORD(0x40086124, 0x000000F3); /* P2_9: A0 (function 3) */
_WDWORD(0x40086128, 0x000000F3); /* P2_10: A1 (function 3) */
_WDWORD(0x4008612C, 0x000000F3); /* P2_11: A2 (function 3) */
_WDWORD(0x40086130, 0x000000F3); /* P2_12: A3 (function 3) */
_WDWORD(0x40086134, 0x000000F3); /* P2_13: A4 (function 3) */
_WDWORD(0x40086080, 0x000000F2); /* P1_0: A5 (function 2) */
_WDWORD(0x40086084, 0x000000F2); /* P1_1: A6 (function 2) */
_WDWORD(0x40086088, 0x000000F2); /* P1_2: A7 (function 2) */
_WDWORD(0x40086120, 0x000000F3); /* P2_8: A8 (function 3) */
_WDWORD(0x4008611C, 0x000000F3); /* P2_7: A9 (function 3) */
_WDWORD(0x40086118, 0x000000F2); /* P2_6: A10 (function 2) */
_WDWORD(0x40086108, 0x000000F2); /* P2_2: A11 (function 2) */
_WDWORD(0x40086104, 0x000000F2); /* P2_1: A12 (function 2) */
_WDWORD(0x40086100, 0x000000F2); /* P2_0: A13 (function 2) */
_WDWORD(0x40086320, 0x000000F1); /* P6_8: A14 (function 1) */
_WDWORD(0x4008631C, 0x000000F1); /* P6_7: A15 (function 1) */
_WDWORD(0x400866C0, 0x000000F2); /* PD_16: A16 (function 2) */
_WDWORD(0x400866BC, 0x000000F2); /* PD_15: A17 (function 2) */
_WDWORD(0x40086700, 0x000000F3); /* PE_0: A18 (function 3) */
_WDWORD(0x40086704, 0x000000F3); /* PE_1: A19 (function 3) */
_WDWORD(0x40086708, 0x000000F3); /* PE_2: A20 (function 3) */
_WDWORD(0x4008670C, 0x000000F3); /* PE_3: A21 (function 3) */
_WDWORD(0x40086710, 0x000000F3); /* PE_4: A22 (function 3) */
// signals for static memory
_WDWORD(0x40086094, 0x000000F3); /* P1_5: CS0 (function 3) */
_WDWORD(0x400866B0, 0x000000F2); /* PD_12: CS2 (function 2) */
_WDWORD(0x40086098, 0x000000F3); /* P1_6: WE (function 3) */
_WDWORD(0x4008608C, 0x000000F3); /* P1_3: OE (function 3) */
_WDWORD(0x40086090, 0x000000F3); /* P1_4: BLS0 (function 3) */
_WDWORD(0x40086318, 0x000000F1); /* P6_6: BLS1 (function 1) */
// configure EMC static memory registers
_WDWORD(0x40005000, 0x00000001); /* Enable */
_WDWORD(0x40005200, 0x00000081); /* CS0: 16 bit, WE */
_WDWORD(0x40005208, 0x00000000); /* CS0: WAITOEN = 0 */
_WDWORD(0x4000520C, 0x00000008); /* CS0: WAITRD = 8 */
_WDWORD(0x40005240, 0x00000081); /* CS2: 16 bit, WE */
_WDWORD(0x40005248, 0x00000000); /* CS2: WAITOEN = 0 */
_WDWORD(0x4000524C, 0x00000007); /* CS2: WAITRD = 7 */
}
/******************************************************************************/
/* */
/* */
/* */
/******************************************************************************/
_sleep_(100);
// Just set up the memory interface to enable the correct access to the external
// flash memory on CS0.
emc_setup();