EmbeddedRelated.com
Forums

lpc2103 return from power down uart issue

Started by Daniel K Melchior March 29, 2012
Hi group,
I am a relatively new member to the group - just monitoring messages, and picking up useful information. Presently I have a problem with an lpc2103 project that others may be able to provide some insight. We have a very low power timer application using an lpc2103, in which we are setting an RTC alarm, and going into deep power down state. The application can be woken by an alarm, or one of the three EINT interrupts. EINT 1 will be connected to RS232 RTS which, when connected to a terminal will wake up and establish a serial connection for remote configuration of the timer.

I am using pole based uart communication (9600 baud). All other inputs are interrupt based. Everything operates as expected when booted from flash. The problem occurs when the application initiates a power down - waiting for an interrupt or alarm to wake up. Issuing a PCON = 0x2; command enters power down as expected. Issuing an interrupt through EINT 1 operates as expected, bringing the application to life. However, UART communications do not come back to life - it appears that the baud rate is incorrect because of the unintelligible characters received at the terminal attached to the serial port instead of the normal logon splash.

I have tried setting a flag on power down, checking the flag in the while 1 loop, and reinitializing the serial port (no change) as was suggested in and NXP app note AN10493. No luck. The debugger doesn't seem to run across a chip power down event, so at this point, I can't see where the code is going after restart. I can see that the application is running after restart because I have an alarm triggering every 60 seconds, and the serial string of garbage characters advances every 60 seconds.

I am using Keil 4.22 IDE, Ulink2 pod, and an MCB2103 eval board for development. I have downloaded and read NXP UM101561 user guide, and all of the application notes on Keil's and NXP's website - I have found very limited information on power down/restart other then AN10493 for USB. The MCB2103 has a button switch / RTS connected to EINT 1 (controlled by a jumper). The sample code provided by NXP for the lcp2100 family doesn't cover power down & restart, as near as I can tell.

Questions:

1. When the PCON = 2; command is executed, what has happened to the Program Counter upon restart - does it pick up after the request to power down, or does it start back up with the startup code?

2. Once the PCON=2; command is executed, the debugger becomes lost. Is there a way to debug across a power down transition using Keil's tool set?

3. It appears that the RTC configuration survives the the power down as evidenced by the alarm continuting to trigger. What happens to the rest of the processor registers across a power down?

4. The UM10161 user guide mentions the ability to enter deep power down through the RTC command PWRCTRL register. This register was not predefined in the lpc2103.h file. I added it, but the register does not seem to function on the processor I have on this MCB2103 board. The manual mentions that this functionality is only supported on "newer" lpc2103 processors. I have not been able to find any information on how new is "newer" - does the NXP monitor on this group know if there is a particular rev level for the chip to support this functionality.
Thanks very much for any assistance that you can provide.

Dan

An Engineer's Guide to the LPC2100 Series

The return from power down should occur on the instruction that follows the
one that put it into power down.

You likely need to reinitialize the PLL, as it is disabled when entering
powerdown, so if you are using it, that could be why your baud rate is off.

Startup code will not be run, unless a reset occurs.

AFAIK, since execution will resume after powerdown mode, all registers are
preserved, or it would not be possible to resume.

Mike
-----Original Message-----
From: l... [mailto:l...]On Behalf
Of Daniel K Melchior
Sent: Thursday, March 29, 2012 2:23 PM
To: l...
Subject: [lpc2000] lpc2103 return from power down uart issue
Hi group,
I am a relatively new member to the group - just monitoring messages, and
picking up useful information. Presently I have a problem with an lpc2103
project that others may be able to provide some insight. We have a very low
power timer application using an lpc2103, in which we are setting an RTC
alarm, and going into deep power down state. The application can be woken
by an alarm, or one of the three EINT interrupts. EINT 1 will be connected
to RS232 RTS which, when connected to a terminal will wake up and establish
a serial connection for remote configuration of the timer.

I am using pole based uart communication (9600 baud). All other inputs are
interrupt based. Everything operates as expected when booted from flash.
The problem occurs when the application initiates a power down - waiting for
an interrupt or alarm to wake up. Issuing a PCON = 0x2; command enters
power down as expected. Issuing an interrupt through EINT 1 operates as
expected, bringing the application to life. However, UART communications do
not come back to life - it appears that the baud rate is incorrect because
of the unintelligible characters received at the terminal attached to the
serial port instead of the normal logon splash.

I have tried setting a flag on power down, checking the flag in the while 1
loop, and reinitializing the serial port (no change) as was suggested in and
NXP app note AN10493. No luck. The debugger doesn't seem to run across a
chip power down event, so at this point, I can't see where the code is going
after restart. I can see that the application is running after restart
because I have an alarm triggering every 60 seconds, and the serial string
of garbage characters advances every 60 seconds.

I am using Keil 4.22 IDE, Ulink2 pod, and an MCB2103 eval board for
development. I have downloaded and read NXP UM101561 user guide, and all
of the application notes on Keil's and NXP's website - I have found very
limited information on power down/restart other then AN10493 for USB. The
MCB2103 has a button switch / RTS connected to EINT 1 (controlled by a
jumper). The sample code provided by NXP for the lcp2100 family doesn't
cover power down & restart, as near as I can tell.

Questions:

1. When the PCON = 2; command is executed, what has happened to the Program
Counter upon restart - does it pick up after the request to power down, or
does it start back up with the startup code?

2. Once the PCON=2; command is executed, the debugger becomes lost. Is
there a way to debug across a power down transition using Keil's tool set?

3. It appears that the RTC configuration survives the the power down as
evidenced by the alarm continuting to trigger. What happens to the rest of
the processor registers across a power down?

4. The UM10161 user guide mentions the ability to enter deep power down
through the RTC command PWRCTRL register. This register was not predefined
in the lpc2103.h file. I added it, but the register does not seem to
function on the processor I have on this MCB2103 board. The manual mentions
that this functionality is only supported on "newer" lpc2103 processors. I
have not been able to find any information on how new is "newer" - does the
NXP monitor on this group know if there is a particular rev level for the
chip to support this functionality.
Thanks very much for any assistance that you can provide.

Dan
Thanks Mike,
I instrumented a blinking led on the dev board, and could see that the blink frequency changed across the power down - indicating a change in clock frequency. That finally led me to the PLL in the manual, where it clearly states that the PLL must be restored to pre power down configuration after a power up. Made the changes, and all is well.

Dan
On Mar 30, 2012, at 1:45 AM, Michael Anton wrote:

> The return from power down should occur on the instruction that follows the
> one that put it into power down.
>
> You likely need to reinitialize the PLL, as it is disabled when entering
> powerdown, so if you are using it, that could be why your baud rate is off.
>
> Startup code will not be run, unless a reset occurs.
>
> AFAIK, since execution will resume after powerdown mode, all registers are
> preserved, or it would not be possible to resume.
>
> Mike
> -----Original Message-----
> From: l... [mailto:l...]On Behalf
> Of Daniel K Melchior
> Sent: Thursday, March 29, 2012 2:23 PM
> To: l...
> Subject: [lpc2000] lpc2103 return from power down uart issue
> Hi group,
> I am a relatively new member to the group - just monitoring messages, and
> picking up useful information. Presently I have a problem with an lpc2103
> project that others may be able to provide some insight. We have a very low
> power timer application using an lpc2103, in which we are setting an RTC
> alarm, and going into deep power down state. The application can be woken
> by an alarm, or one of the three EINT interrupts. EINT 1 will be connected
> to RS232 RTS which, when connected to a terminal will wake up and establish
> a serial connection for remote configuration of the timer.
>
> I am using pole based uart communication (9600 baud). All other inputs are
> interrupt based. Everything operates as expected when booted from flash.
> The problem occurs when the application initiates a power down - waiting for
> an interrupt or alarm to wake up. Issuing a PCON = 0x2; command enters
> power down as expected. Issuing an interrupt through EINT 1 operates as
> expected, bringing the application to life. However, UART communications do
> not come back to life - it appears that the baud rate is incorrect because
> of the unintelligible characters received at the terminal attached to the
> serial port instead of the normal logon splash.
>
> I have tried setting a flag on power down, checking the flag in the while 1
> loop, and reinitializing the serial port (no change) as was suggested in and
> NXP app note AN10493. No luck. The debugger doesn't seem to run across a
> chip power down event, so at this point, I can't see where the code is going
> after restart. I can see that the application is running after restart
> because I have an alarm triggering every 60 seconds, and the serial string
> of garbage characters advances every 60 seconds.
>
> I am using Keil 4.22 IDE, Ulink2 pod, and an MCB2103 eval board for
> development. I have downloaded and read NXP UM101561 user guide, and all
> of the application notes on Keil's and NXP's website - I have found very
> limited information on power down/restart other then AN10493 for USB. The
> MCB2103 has a button switch / RTS connected to EINT 1 (controlled by a
> jumper). The sample code provided by NXP for the lcp2100 family doesn't
> cover power down & restart, as near as I can tell.
>
> Questions:
>
> 1. When the PCON = 2; command is executed, what has happened to the Program
> Counter upon restart - does it pick up after the request to power down, or
> does it start back up with the startup code?
>
> 2. Once the PCON=2; command is executed, the debugger becomes lost. Is
> there a way to debug across a power down transition using Keil's tool set?
>
> 3. It appears that the RTC configuration survives the the power down as
> evidenced by the alarm continuting to trigger. What happens to the rest of
> the processor registers across a power down?
>
> 4. The UM10161 user guide mentions the ability to enter deep power down
> through the RTC command PWRCTRL register. This register was not predefined
> in the lpc2103.h file. I added it, but the register does not seem to
> function on the processor I have on this MCB2103 board. The manual mentions
> that this functionality is only supported on "newer" lpc2103 processors. I
> have not been able to find any information on how new is "newer" - does the
> NXP monitor on this group know if there is a particular rev level for the
> chip to support this functionality.
> Thanks very much for any assistance that you can provide.
>
> Dan
>
I am back with another question.

As was pointed out by Mike in the previous question in this thread, I needed to restore the PLL configuration upon returning from a power down. I picked up this code from PowerDown_USB Keil example:

void Reset_MainClock (void)
{
/* Set system timers for each component */
//VPBDIV = 1;

PLLCON = 1;
PLLCFG = 0x45; /* MSEL = 5, PSEL = 2 Note: must */
/* matche PLL config in Startup.s */
PLLFEED = 0xaa;
PLLFEED = 0x55;
while((PLLSTAT & (1 << 10)) == 0);
PLLCON = 3;
PLLFEED = 0xaa;
PLLFEED = 0x55;
return;
}

This did appear to solve my problem with the UART. However, upon closer examination, the lpc2103 resets after exiting this function. Reset would also re-run the start up code, and configure the PLL. Any ideas why this function would force a processor reset?

Thanks for what ever insight you can provide

Dan
On Mar 30, 2012, at 12:11 PM, Daniel K Melchior wrote:

> Thanks Mike,
> I instrumented a blinking led on the dev board, and could see that the blink frequency changed across the power down - indicating a change in clock frequency. That finally led me to the PLL in the manual, where it clearly states that the PLL must be restored to pre power down configuration after a power up. Made the changes, and all is well.
>
> Dan
> On Mar 30, 2012, at 1:45 AM, Michael Anton wrote:
>
>> The return from power down should occur on the instruction that follows the
>> one that put it into power down.
>>
>> You likely need to reinitialize the PLL, as it is disabled when entering
>> powerdown, so if you are using it, that could be why your baud rate is off.
>>
>> Startup code will not be run, unless a reset occurs.
>>
>> AFAIK, since execution will resume after powerdown mode, all registers are
>> preserved, or it would not be possible to resume.
>>
>> Mike
>> -----Original Message-----
>> From: l... [mailto:l...]On Behalf
>> Of Daniel K Melchior
>> Sent: Thursday, March 29, 2012 2:23 PM
>> To: l...
>> Subject: [lpc2000] lpc2103 return from power down uart issue
>> Hi group,
>> I am a relatively new member to the group - just monitoring messages, and
>> picking up useful information. Presently I have a problem with an lpc2103
>> project that others may be able to provide some insight. We have a very low
>> power timer application using an lpc2103, in which we are setting an RTC
>> alarm, and going into deep power down state. The application can be woken
>> by an alarm, or one of the three EINT interrupts. EINT 1 will be connected
>> to RS232 RTS which, when connected to a terminal will wake up and establish
>> a serial connection for remote configuration of the timer.
>>
>> I am using pole based uart communication (9600 baud). All other inputs are
>> interrupt based. Everything operates as expected when booted from flash.
>> The problem occurs when the application initiates a power down - waiting for
>> an interrupt or alarm to wake up. Issuing a PCON = 0x2; command enters
>> power down as expected. Issuing an interrupt through EINT 1 operates as
>> expected, bringing the application to life. However, UART communications do
>> not come back to life - it appears that the baud rate is incorrect because
>> of the unintelligible characters received at the terminal attached to the
>> serial port instead of the normal logon splash.
>>
>> I have tried setting a flag on power down, checking the flag in the while 1
>> loop, and reinitializing the serial port (no change) as was suggested in and
>> NXP app note AN10493. No luck. The debugger doesn't seem to run across a
>> chip power down event, so at this point, I can't see where the code is going
>> after restart. I can see that the application is running after restart
>> because I have an alarm triggering every 60 seconds, and the serial string
>> of garbage characters advances every 60 seconds.
>>
>> I am using Keil 4.22 IDE, Ulink2 pod, and an MCB2103 eval board for
>> development. I have downloaded and read NXP UM101561 user guide, and all
>> of the application notes on Keil's and NXP's website - I have found very
>> limited information on power down/restart other then AN10493 for USB. The
>> MCB2103 has a button switch / RTS connected to EINT 1 (controlled by a
>> jumper). The sample code provided by NXP for the lcp2100 family doesn't
>> cover power down & restart, as near as I can tell.
>>
>> Questions:
>>
>> 1. When the PCON = 2; command is executed, what has happened to the Program
>> Counter upon restart - does it pick up after the request to power down, or
>> does it start back up with the startup code?
>>
>> 2. Once the PCON=2; command is executed, the debugger becomes lost. Is
>> there a way to debug across a power down transition using Keil's tool set?
>>
>> 3. It appears that the RTC configuration survives the the power down as
>> evidenced by the alarm continuting to trigger. What happens to the rest of
>> the processor registers across a power down?
>>
>> 4. The UM10161 user guide mentions the ability to enter deep power down
>> through the RTC command PWRCTRL register. This register was not predefined
>> in the lpc2103.h file. I added it, but the register does not seem to
>> function on the processor I have on this MCB2103 board. The manual mentions
>> that this functionality is only supported on "newer" lpc2103 processors. I
>> have not been able to find any information on how new is "newer" - does the
>> NXP monitor on this group know if there is a particular rev level for the
>> chip to support this functionality.
>> Thanks very much for any assistance that you can provide.
>>
>> Dan
>>