Can't Debug LPC4357-M4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can't Debug LPC4357-M4

313 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TahaSN on Thu Apr 16 14:11:45 MST 2015
Hi,

We populated a custom board which includes LPC4357 and when I tried to program the chip using IAR debug, it stopped on the main function as usual but then when I ran the code it gave me an error that it failed to get the CPU status and closed the debugger. I tried the same code on another custom board and it works fine. We thought that it went into some code protection mode, so I tried to boot into ISP mode by putting P2_7, P1_1, P1_2, P2_8 and P2_9 low in order to boot from USART0 mode. But I still didnt get anything back from there.

I also tried to use Flash Magic software (I haven't used it before) in order to get some kind of access but I got nothing. I did realise that when the uC is in USART0 mode, I am able to program the device but it never runs the code. Do you guys have any idea what can be wrong because I am currently out of ideas. Please let me know if you need some other information in order to help me out. I will try my best to provide the information as quickly as I can.

Thanks
Taha
Labels (1)
0 Kudos
3 Replies

285 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TahaSN on Fri Apr 17 07:41:08 MST 2015
Hi Bavarian, as you recommended, I put an infinite loop in the main before setting up anything and it was working. Then I added the function which sets up the clock to external oscillator and uses pll to boost the frequency upto 204MHz. I narrowed down the problem to the following code.

void System_ClockSetup(void)
{
/* Switch Main System Clock to Crystal */
Chip_Clock_EnableCrystal();
[color=#c00]Chip_Clock_SetBaseClock(CLK_BASE_MX, CLKIN_CRYSTAL, true, false);[/color]

/* Setup PLL for 100MHz and Switch Main System Clock */
Chip_Clock_SetupMainPLLHz(CLKIN_CRYSTAL, OscRateIn, 100 * 1000000, 100 * 1000000);
Chip_Clock_SetBaseClock(CLK_BASE_MX, CLKIN_MAINPLL, true, false);

/* Setup PLL for Maximum Clock */
Chip_Clock_SetupMainPLLHz(CLKIN_CRYSTAL, OscRateIn, MAX_CLOCK_FREQ, MAX_CLOCK_FREQ);

/* Setup the Base Clock Sources */
for (int i = 0; i < (sizeof(InitClkStates) / sizeof(InitClkStates[0])); i++) 
{
Chip_Clock_SetBaseClock(InitClkStates.clk, InitClkStates.clkin, InitClkStates.autoblock_enab, InitClkStates.powerdn);
}
}


void Chip_Clock_SetBaseClock(CHIP_CGU_BASE_CLK_T BaseClock, CHIP_CGU_CLKIN_T Input, bool autoblocken, bool powerdn)
{
uint32_t reg = LPC_CGU->BASE_CLK[BaseClock];

if (BaseClock < CLK_BASE_NONE) {
if (Input != CLKINPUT_PD) {
/* Mask off fields we plan to update */
reg &= ~((0x1F << 24) | 1 | (1 << 11));

if (autoblocken) {
reg |= (1 << 11);
}
if (powerdn) {
reg |= (1 << 0);
}

/* Set clock source */
reg |= (Input << 24);

[color=#c00]LPC_CGU->BASE_CLK[BaseClock] = reg;[/color]
}
}
else {
LPC_CGU->BASE_CLK[BaseClock] = reg | 1;/* Power down this base clock */
}
}


the debugger cannot execute the colored statement and give me error at that particular statement. The value of reg at that particular instance was 0x06000800 which seems to be fine.

I also checked the continuity of xtal pins to the crystal and it seems fine. I also swapped the crystal with a new one but still the same problem.

Any ideas??
0 Kudos

285 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by bavarian on Fri Apr 17 04:26:59 MST 2015
My comments & recommendations:

- don't run to main() with the debugger
- insert a long wait loop right at the beginning of the C code, to make sure that the chip doesn't execute any critical code before the debugger is able to stop the core.
- if you then can step through the code, the hardware isn't that wrong  ;-)
- do you use the external memory interface? Which resistor values did you use for the bootstrap pins (which belong to the EMC i/f) ?

Regards,
NXP Support Team
0 Kudos

285 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by xianghuiwang on Thu Apr 16 22:27:41 MST 2015
I would recommend you step in main in assembly mode and compare the instruction execution  between the functioning and unfunctioning board. Are the two customer boards an identical design? Details in the error message is also needed for further assistance.
0 Kudos