LPC82x enabling MTB without patches to runtime code

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by Shoichi Kojima on Tue Jan 19 05:26:35 MST 2016

I'm trying to utilize MTB on LPC824.
Not as well as LPC81x, it has clock gate for MTB block.
bit26 of SYSCON->SYSCLKCTRL is the control bit to enable it.

I've been using Keil MDK-ARM and uVision debugger.
Normally, under this environment, debugger initialization file script allows
register modification interruptively at RESET operation, such as after
Flash download completion before I make it run.
So, usually I do not need to patch my code just to enable MTB.

But, with LPC824, this procedure does not work as expected.....
As far as I tracked the boot process of LPC824, in any boot mode cases,
some portion of boot ROM runs and it carelessly over-write SYSCON-SYSAHBCLKCTRL
with value 0xDF, which clears the clock enabling to MTB..
Initially at power-up, that register is read as 0x1F. Maybe this is the native
hardware reset value and the value 0xDF (which is described in User manual)
is the one that the ROM code determines.

Does anyone know the smat way to enable (keep-enabling) MTB without code
patch after Flash downloading before make it run ?