Hi,
I think that IAR has not updated their LPC17xx.mac file to work with the latest LPC1758 version, since the following error is raised :
C:\Program Files (x86)\IAR Systems\Embedded Workbench 8.4\arm/config/flashloader/NXP/LPC17xx.mac(40,17): Error: Operation error.
However I’m not sure what needs to be changed to make it work.
Can anyone help me with this?
__var FLASHCFG;
__var MEMMAP;
__var CLKSRCSEL;
__var SCS;
__var CCLKSEL;
__var PLL0CON;
execUserFlashInit()
{
// Save registers contents
FLASHCFG = __readMemory32(0x400FC000, "Memory");
MEMMAP = __readMemory32(0x400FC040, "Memory");
CLKSRCSEL = __readMemory32(0x400FC10C, "Memory");
SCS = __readMemory32(0x400FC1A0, "Memory");
CCLKSEL = __readMemory32(0x400FC104, "Memory");
PLL0CON = __readMemory32(0x400FC080, "Memory");
// Disable the PLL.
__writeMemory32(0x00000000, 0x400FC080, "Memory"); // PLL0CON = 0
// Qualify the PLL change.
__writeMemory32(0x000000AA, 0x400FC08C, "Memory"); // PLL0FEED = 0xAA
__writeMemory32(0x00000055, 0x400FC08C, "Memory"); // PLL0FEED = 0x55
__writeMemory32(0x00000000, 0x400FC104, "Memory"); // CCLKSEL=0
// Enable main clock
__writeMemory32(0x00000020, 0x400FC1A0, "Memory"); // SCS.OSCEN = 1
__delay(1); //Reading status is unstable
// Wait on OSCSTAT bit, set when oscillator is ready.
//while(!(__readMemory32(0x400FC1A0, "Memory") & 0x40))
// Switch to main clock instead of internal RC for stable JTAG auto-speed
__writeMemory32(0x00000001, 0x400FC10C, "Memory"); // CLKSRCSEL = 1
// Make sure that the flash memory system is correctly setup.
__writeMemory32(0x3A , 0x400FC000, "Memory"); // FLASHCFG = 0x3A;
// If the MAM values was wrong, a dummy read is necessary to get the flash memory in sync.
__writeMemory32(0x00000001, 0x400FC040, "Memory"); // MEMMAP = 1
__readMemory32(0x00000000, "Memory");
}
execUserFlashExit()
{
// Restore modified registers
__writeMemory32(CLKSRCSEL, 0x400FC10C, "Memory");
__writeMemory32(PLL0CON, 0x400FC080, "Memory");
// Qualify the PLL change.
__writeMemory32(0x000000AA, 0x400FC08C, "Memory");
__writeMemory32(0x00000055, 0x400FC08C, "Memory");
__writeMemory32(CCLKSEL, 0x400FC104, "Memory");
__writeMemory32(SCS, 0x400FC1A0, "Memory");
if (SCS & 0x20)
{
__delay(1); //Reading status is unstable
// Wait on OSCSTAT bit, set when oscillator is ready.
//while(!(__readMemory32(0x400FC1A0, "Memory") & 0x40));
}
__writeMemory32(FLASHCFG, 0x400FC000, "Memory");
__writeMemory32(MEMMAP, 0x400FC040, "Memory");
// Dummy read to get the flash memory in sync
__readMemory32(0x00000000, "Memory");
}