
Спасибо.
С тем, что был в комплекте в IAR 4.42A не шилось в отладчике вообще. Местами поправил (чтоб ширина зиписываемых регистров соответствовала мануалу). Один раз с горем пополам прошилось.
Сейчас мой выглядит вот так:
Код
execUserFlashInit()
{
// Disable the PLL.
__writeMemory8(0x00000000, 0xE01FC080, "Memory"); // PLLCON = 0
// Qualify the PLL change.
__writeMemory8(0x000000AA, 0xE01FC08C, "Memory"); // PLLFEED = 0xAA
__writeMemory8(0x00000055, 0xE01FC08C, "Memory"); // PLLFEED = 0x55
// Enable main clock (LPC23xx only).
__writeMemory32(0x00000020, 0xE01FC1A0, "Memory"); // SCS.OSCEN = 1
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// Switch to main clock instead of internal RC for stable JTAG auto-speed (LPC23xx only).
__writeMemory8(0x00000001, 0xE01FC10C, "Memory"); // CLKSRCSEL = 1
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// Make sure that the flash memory system is correctly setup.
__writeMemory8(0x00000000, 0xE01FC000, "Memory"); // MAMCR = 0
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__writeMemory8(0x00000007, 0xE01FC004, "Memory"); // MAMTIM = 7
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__writeMemory8(0x00000002, 0xE01FC000, "Memory"); // MAMCR = 2
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// If the MAM values was wrong, a dummy read is necessary to get the flash memory in sync.
__writeMemory8(0x00000001, 0xE01FC040, "Memory"); // MEMMAP = 1
__readMemory32(0x00000000, "Memory");
}
{
// Disable the PLL.
__writeMemory8(0x00000000, 0xE01FC080, "Memory"); // PLLCON = 0
// Qualify the PLL change.
__writeMemory8(0x000000AA, 0xE01FC08C, "Memory"); // PLLFEED = 0xAA
__writeMemory8(0x00000055, 0xE01FC08C, "Memory"); // PLLFEED = 0x55
// Enable main clock (LPC23xx only).
__writeMemory32(0x00000020, 0xE01FC1A0, "Memory"); // SCS.OSCEN = 1
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// Switch to main clock instead of internal RC for stable JTAG auto-speed (LPC23xx only).
__writeMemory8(0x00000001, 0xE01FC10C, "Memory"); // CLKSRCSEL = 1
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// Make sure that the flash memory system is correctly setup.
__writeMemory8(0x00000000, 0xE01FC000, "Memory"); // MAMCR = 0
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__writeMemory8(0x00000007, 0xE01FC004, "Memory"); // MAMTIM = 7
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__writeMemory8(0x00000002, 0xE01FC000, "Memory"); // MAMCR = 2
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
__sleep(50000); // Give the oscillator some startup time (50 ms)
// If the MAM values was wrong, a dummy read is necessary to get the flash memory in sync.
__writeMemory8(0x00000001, 0xE01FC040, "Memory"); // MEMMAP = 1
__readMemory32(0x00000000, "Memory");
}