Hello,
I'm using a NXP LPC1768 Cortex-M3 controller with KEIL MDK-ARM and uLink2-Debugger.
When I start my application from a higher address than 0 (VTOR > 0) the ADC gives back strange values. This is due to the ADC Trim register ADTRM.
During debugging: When I start my application from address 0x00 (VTOR=0x00), the ADTRM register is 0xF00. But when I start it from address 0x2000 (VTOR=0x2000), the ADTRM register is set to 0x000. The other application works. I can set ADTRM manually to 0xF00 (although it is not allowed by datasheet), then it works.
Can you explain me that behavior? When is ADTRM set during boot code? What can I do, to prevent this ADC malfunction?
Thank you for an answer,
DW.
This was the answer from NXP:
Hi,
It is best if the debugger can run through the boot rom after every reset (which will complete the remapping) and then stop at main or in the startup code as the user desires. The ROM sets up reset values of some user registers and also sets internal registers. If the whole boot code does not run before the user code, then the debugging environment won’t represent the run environment as closely as it could, for example having different Flash performance configurations or different reset values of power management registers, which could be misleading.
There is an option which can be set in the debugger (target options > debug > settings) to stop after the bootloader.
Hi Daniel,
Doesn't the debugger reset the micro? How are you jumping to 0x2000 when you start debugging? Are you using an INI file.
What NXP responded make sense to me. Your real app will need a bootloader at 0x0.
yes, the debugger should reset the controller. In the debugger settings the address range is set to 00002000H - 0007FFFFH and I am using an INI file:
SP=_RDWORD(0x2000); // Setup Stack Pointer PC=_RDWORD(0x2004); // Setup Program Counter _WDWORD(0xE000ED08, 0x2000); // Setup Vector Table Offset Register
The bootloader is at 0x00, but it's another project and I just want to debug the real application at 0x2000 (what generally works).
I would like to get an understanding of the things that happen at start-up and prevent other side-effects.