Reply by Shashank Maheshwari August 30, 20122012-08-30
Thanks for the reply triffid.hunter. I really appreciate that.

however following is the pseudo code

*PD mode* --> *External Interrupt* [ *setup PLL0 ()* -> *transmit UART ()*->
*reset EXTINT bit* ] --> *PD mode*

within that the *transmit UART () *function is the following :
{
PCONP |= 0x00000010; // power up UART1
U1THR = ch;

while( *!(U1LSR & 0x20)* ) // *this is U1LSR -> TEMT,
same as U0LSR->TEMT on lpc1769*
IO1SET |= 0x00a00000; // LEDs are attached to this port so
this is just for visual reference
IO1CLR |= 0x00f00000; // LEDs are attached...
}

Hence I *do* wait for UART buffer to be empty before it goes in PD mode.

I would like to add that those IOSET in above function is for the LEDs.
LEDs are active while processor is waiting for the UART to be empty. And as
soon as it is empty the LEDs turn off.

Usually with successful UART transmission the LED set and clear is fast
enough that it can not be noticed. However with sleep mode active I can see
those LEDs blink for a fraction of second. I do not understand why that is
happening.

I would really appreciate your help.

Regards
Shashank

On Thu, Aug 30, 2012 at 8:26 PM, Triffid Hunter wrote:

> **
> are you waiting for the uart to finish transmitting before powering down?
>
> I'm not familiar with lpc2148 but in lpc1769 you can poll U0LSR->TEMT
> (transmitter empty)
> On Fri, Aug 31, 2012 at 12:11 AM, Shashank Maheshwari
> wrote:
> > Hi guys
> >
> > I have been using LPC2148 connected with a digital hall effect
> > sensor(external interrupt) and ZigBee(UART interface).
> >
> > It should work in the manner such that it always stays in PD mode.
> Whenever
> > external interrupt from Hall Effect Sensor is triggered it should wake up
> > transmit a character on UART and go back to PD mode.
> >
> > 1.The system works perfectly when I do not use the power down mode.
> > 2.However when I use power down mode the LEDs in the external interrupt
> > function blik as required telling that the system wakes up from PD by
> > extint however no UART transmission takes place. (????)
> > (ie. when I remove the PCON & PCONP lines from the while(1) loop in main
> > the system works perfectly however with those lines included there is no
> > UART transmission)
> >
> > Below is the code for the same :
> >
> > int main (void)
> > {
> > setup_hardware(); //sets up UART1 extint1 extint2 & other
> > while(1)
> > {
> > PCONP = 0x00; // clock source disable for all peripherals
> > PCON = 0x02; // PD mode
> > }
> > return 0;
> > }
> >
> > void setup_extint1(void)
> > {
> > VICVectCntl0 = 0x0000002F;
> > VICVectAddr0 = (unsigned)EXTINT1VectoredIRQ;
> > EXTMODE |= 0x02;
> > EXTPOLAR |= 0x00;
> > EXTWAKE |= 0x02;
> > PINSEL0 |= 0x20000000;
> > VICIntEnable |= 0x00008000;
> > EXTINT = 0x02;
> > }
> > void EXTINT1VectoredIRQ (void) __irq
> > {
> > setup_PLL0(); // setup pll0 after wake up from PD mode
> > IO1SET = 0x000f0000;
> > UART1Tx('o');
> > EXTINT = 0x02;
> > VICVectAddr = 0x00000000;
> > }
> > void UART1Tx (int ch)
> > {
> > PCONP |= 0x00000010;
> > while( !(U1LSR & 0x20) )
> > IO1SET |= 0x00a00000;
> > U1THR = ch;
> > IO1CLR |= 0x00f00000;
> > }
> >
> >
> > I have been stuck at this for a really long time and tried every possible
> > thing that I can think of.I would really appreciate and it would be
> > immensely helpful if somebody could help me out with this issue.
> >
> > Regards
> > Shashank
> > // I apologize for the long post however I did not want to miss out any
> > details that would make the understanding of the problem complex !
> >
> >
> >
> >
> >
> >
> >
> >
> >

An Engineer's Guide to the LPC2100 Series

Reply by Triffid Hunter August 30, 20122012-08-30
are you waiting for the uart to finish transmitting before powering down?

I'm not familiar with lpc2148 but in lpc1769 you can poll U0LSR->TEMT
(transmitter empty)

On Fri, Aug 31, 2012 at 12:11 AM, Shashank Maheshwari
wrote:
> Hi guys
>
> I have been using LPC2148 connected with a digital hall effect
> sensor(external interrupt) and ZigBee(UART interface).
>
> It should work in the manner such that it always stays in PD mode. Whenever
> external interrupt from Hall Effect Sensor is triggered it should wake up
> transmit a character on UART and go back to PD mode.
>
> 1.The system works perfectly when I do not use the power down mode.
> 2.However when I use power down mode the LEDs in the external interrupt
> function blik as required telling that the system wakes up from PD by
> extint however no UART transmission takes place. (????)
> (ie. when I remove the PCON & PCONP lines from the while(1) loop in main
> the system works perfectly however with those lines included there is no
> UART transmission)
>
> Below is the code for the same :
>
> int main (void)
> {
> setup_hardware(); //sets up UART1 extint1 extint2 & other
> while(1)
> {
> PCONP = 0x00; // clock source disable for all peripherals
> PCON = 0x02; // PD mode
> }
> return 0;
> }
>
> void setup_extint1(void)
> {
> VICVectCntl0 = 0x0000002F;
> VICVectAddr0 = (unsigned)EXTINT1VectoredIRQ;
> EXTMODE |= 0x02;
> EXTPOLAR |= 0x00;
> EXTWAKE |= 0x02;
> PINSEL0 |= 0x20000000;
> VICIntEnable |= 0x00008000;
> EXTINT = 0x02;
> }
> void EXTINT1VectoredIRQ (void) __irq
> {
> setup_PLL0(); // setup pll0 after wake up from PD mode
> IO1SET = 0x000f0000;
> UART1Tx('o');
> EXTINT = 0x02;
> VICVectAddr = 0x00000000;
> }
> void UART1Tx (int ch)
> {
> PCONP |= 0x00000010;
> while( !(U1LSR & 0x20) )
> IO1SET |= 0x00a00000;
> U1THR = ch;
> IO1CLR |= 0x00f00000;
> }
> I have been stuck at this for a really long time and tried every possible
> thing that I can think of.I would really appreciate and it would be
> immensely helpful if somebody could help me out with this issue.
>
> Regards
> Shashank
> // I apologize for the long post however I did not want to miss out any
> details that would make the understanding of the problem complex !
>
>
>
Reply by Shashank Maheshwari August 30, 20122012-08-30
Hi guys

I have been using LPC2148 connected with a digital hall effect
sensor(external interrupt) and ZigBee(UART interface).

It should work in the manner such that it always stays in PD mode. Whenever
external interrupt from Hall Effect Sensor is triggered it should wake up
transmit a character on UART and go back to PD mode.

1.The system works perfectly when I do not use the power down mode.
2.However when I use power down mode the LEDs in the external interrupt
function blik as required telling that the system wakes up from PD by
extint however no UART transmission takes place. (????)
(ie. when I remove the PCON & PCONP lines from the while(1) loop in main
the system works perfectly however with those lines included there is no
UART transmission)

Below is the code for the same :

int main (void)
{
setup_hardware(); //sets up UART1 extint1 extint2 & other
while(1)
{
PCONP = 0x00; // clock source disable for all peripherals
PCON = 0x02; // PD mode
}
return 0;
}

void setup_extint1(void)
{
VICVectCntl0 = 0x0000002F;
VICVectAddr0 = (unsigned)EXTINT1VectoredIRQ;
EXTMODE |= 0x02;
EXTPOLAR |= 0x00;
EXTWAKE |= 0x02;
PINSEL0 |= 0x20000000;
VICIntEnable |= 0x00008000;
EXTINT = 0x02;
}
void EXTINT1VectoredIRQ (void) __irq
{
setup_PLL0(); // setup pll0 after wake up from PD mode
IO1SET = 0x000f0000;
UART1Tx('o');
EXTINT = 0x02;
VICVectAddr = 0x00000000;
}
void UART1Tx (int ch)
{
PCONP |= 0x00000010;
while( !(U1LSR & 0x20) )
IO1SET |= 0x00a00000;
U1THR = ch;
IO1CLR |= 0x00f00000;
}
I have been stuck at this for a really long time and tried every possible
thing that I can think of.I would really appreciate and it would be
immensely helpful if somebody could help me out with this issue.

Regards
Shashank
// I apologize for the long post however I did not want to miss out any
details that would make the understanding of the problem complex !