Content originally posted in LPCWare by bkastel1 on Wed Jul 24 12:32:24 MST 2013
Hi,
first thanks for all the answers. I tested today Blinky example on another xpresso board I have and that didn't had my code on it and flashing is done without problems. Later I tested gain on the board that gave me problems (also full lpcxpresso board, not something I made) and I wasn't able to make Full erase - it reported an error about not being able to erase while core regs are active?? The only way to erase it was going into ISP mode. Then also this board was able to normally erase without ISP mode and flashing Blinky.axf on it. Up until I flashed my code again... Then again not possible to make full erase and/or flashing failed. So as soon as I tried flashing my own code I can do it only using Keil ULINK2 or thru serial bootloader but not using lpcxpresso. Here is the output after flashing:
Ni: LPCXpresso Debug Driver v5.2 (Jul 5 2013 11:31:21 - crt_emu_lpc11_13_nxp.exe build 15)
Pc: ( 0) Reading remote configuration
Nc: Looked for chip XML file in C:/nxp/LPCXpresso_5.2.6_2137/lpcxpresso/bin/LPC1114/302.xml
Nc: Looked for vendor directory XML file in C:/nxp/LPCXpresso_5.2.6_2137/lpcxpresso/bin/nxp_directory.xml
Nc: Found generic directory XML file in C:/nxp/LPCXpresso_5.2.6_2137/lpcxpresso/bin/crt_directory.xml
Pc: ( 5) Remote configuration complete
Pc: ( 30) Emulator Connected
Pc: ( 40) Debug Halt
Pc: ( 50) CPU ID
Nc: Emu(0): Conn&Reset. DpID: BB11477. Info: HID64HS12
Nc: SWD Frequency: 250 KHz. RTCK: False. Vector catch: False.
Nc: Packet delay: 0 Poll delay: 0.
Nc: Loaded LPC11_12_13_32K_8K.cfx: LPC11_12_13 (32K Flash, min 8K RAM) Apr 22 2013 12:14:02 On-chip Flash Memory
Nc: NXP: LPC1114/302 Part ID: 0x00000000
Pc: ( 65) Chip Setup Complete
Nt: Connected: was_reset=false. was_stopped=true
Cr:v Registered license, download limit of 128K
Pc: ( 70) License Check Complete
Nt: Loading ELF file 'Lumu_V1.axf' at location 00000000
Nt: Writing 6296 bytes to 0000 in Flash (assumed clock: 12.0MHz)
Pb: 1 of 1 ( 0) Writing pages 0-1 at 0x00000000 with 6296 bytes
Ps: ( 0) Page 0 at 00000000
Ps: ( 0) Page 0 at 00000000: 4096 bytes
Wc: Verify of Flash failed at 00000000.
Pb: (100) Writing Flash ended with an error.
Ed:05: File 'Lumu_V1.axf' load failure: Ef(5). Flash verify operation failed.
Nc: nSRST assert (if available)
Nc: Executing in user flash.
Then I did a mass erase and tried flashing Blinky again and no success. Only after going into ISP mode was I able to "regain" control over MCU and I was able to flash Blinky again. I tried using an lpcxpresso example to download (systick example) after I tried to flash my code with the Flash failed error and the result was:
15: Target error from Commit Flash write
Flash verify operation failed.
I had to go into ISP mode again to be able to download axf file (it looks like that in ISP mode I get the part "back" into normal behavior). So does anybody have an idea what might cause the problem? I have a feeling that is has to do with interrupt handlers - in my project I'm using I2C handler, timer16_0 IRQ, SysTick and GPIO. One of this causes this issue. If I have only I2C and timer16 all is ok. When I added SysTick (executing SysTick_Config(RELOAD_LOW);) Flash failed. And SysTick is very simple:
volatile uint32_t TimerTick;
/*----------------------------------------------------------------------------
SysTick IRQ: Executed periodically (10ms)
*----------------------------------------------------------------------------*/
void SysTick_Handler (void) {
TimerTick++;
}
Commeting out SysTick solved the problem. I tried adding gpio IRQ (I'm using gpio irq to measure time interval between two events on the gpio) but again flashing failed. Like I can only use two IRQ's or something. GPIO IRQ is:
void PIOINT1_IRQHandler(void)
{
uint32_t regVal;
regVal = GPIOIntStatus(PORT1, 10);
if (regVal)
{
if (!measureON) { /* no running measurement */
enable_timer32(0); /* start counting */
measureON = 1;
} else { /* we have running measurement */
disable_timer32(0);
timerMeasurements[p1_10_counter] = LPC_TMR32B0->TC; /* save current measurement */
p1_10_counter++;
if (p1_10_counter == 8) {
p1_10_counter = 0;
if (120 < timerMeasurements[1] && timerMeasurements[3] < 150) {
newSysTickVal = RELOAD_HIGH;
} else if (180 < timerMeasurements[5] && timerMeasurements[7] < 230 ) {
newSysTickVal = RELOAD_LOW;
}
}
reset_timer32(0);
measureON = 0;
}
GPIOIntClear(PORT1, 10);
}
return;
}
I'm using IRC for clock and then I also clock it down to 3MHz using:
profile.new_system_clock = 3000000UL; //in HZ
profile.current_system_clock = 12000000UL; //in Hz
profile.power_mode = PARAM_EFFICIENCY;
if (config_pll_power(&profile)) {
SystemInit();
while(1);
} else {
SystemCoreClock = profile.current_system_clock;
}
SystemCoreClockUpdate();
to save power. Can these interfere with normal operation of the MCU? So for sure there is something wrong with my code and I have no clue what. Most probably something with interrupts but no idea what. Can somebody give me an advice?
Thanks for your valuable insights.