AnsweredAssumed Answered

LPC822 write to PINENABLE0 results in bogus values

Question asked by Thomas Rogg on May 4, 2018
Latest reply on May 9, 2018 by Kerry Zhou

Hello everyone,

 

I am running my program on a LPC822M101JHI33.

The programs entry point is at 0x200, enabling me to run it directly from the bootloader without reset via "G 512 T"

 

In the program I am doing the following steps:

 

Setting stack pointer (msr msp, msr psp) to end of RAM

Writing 2 to 0x40048000, enabling my own interrupt vectors, and no longer those of the bootloader

The normal C startup things: etext => data, clear of bss

Next,the following LPCOpen calls:

Chip_SystemInit();

SystemCoreClockUpdate();
Chip_GPIO_Init(PC_GPIO_PORT);

SysTick_Config(SystemCoreClock / 1000);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_IOCON);
for (int i = 0; i < 12; i++) // just in case bootloader resets stuff
LPC_SWM->PINASSIGN[i] = 0xFFFFFFFF;

 

Next, I want to disable the fixed PINs SWDIO and SWCLK:

Chip_SWM_DisableFixedPin(SWM_FIXED_SWCLK);
Chip_SWM_DisableFixedPin(SWM_FIXED_SWDIO);

 

Every once in a while (about every 3rd reset) this writes bogus stuff into PINENABLE0, instead of just setting the 2 bits of PINENABLE0 to 1. This breaks GPIO in general (and most probably also other stuff).

 

If I do not do the 2 Chip_SWM_DisableFixedPin calls, the rest of the program runs fine. With lots of GPIO Stuff, UART communication, and SysTick handling.

 

Can anybody help so I can use the two pins of SWCLK and SWDIO for GPIO? Is it because of the bootloader? What's it setting which I have to reset first? Or is it a different problem

 

Thank you!

 

Thomas

Outcomes