EmbeddedRelated.com
Forums

LPC2148 setting Uart0 at 12mhz pclk - not working

Started by ssonderhoff February 7, 2010
According to the manual going to sleep disconnects the PLL which must then be reconnected in software, this will not happen automatically. in the absence of that, cclk = osc frequency. The PLL configuration is not reset, but when I went to sleep at 60mhz and then actively reset them to the 12mhz immediately after waking up the cclk was set lower ( I timed LED flashes that indicated that the processor speed was around 1/5 of the before sleep rate) but Uart0 would only output garbage even after resetting the uart0 settings. These same settings worked fine if the cclk and uart0 were changed before sleep

ie:
cclk 60mhz ->sleep-> set 12mhz and uart = uart outputs garbage
cclk 60mhz -> set 12mhz and uart -> sleep = uart output is fine

Thanks,
Stefan

--- In l..., Sutton Mehaffey wrote:
>
> I just tried it. I had PCLK = CCLK = 12mhz (PLL off). I set it to
> 18mhz before sleep mode (PLL0CON = 1, and PLL0CFG set to some value).
> It was still 18mhz after EINT3 wake up, with the same PLL0 values. So,
> waking up after going to sleep mode does not reset PLL values. An
> actual reset (software or hardware) probably does.
>
>
>
> ssonderhoff wrote:
> >
> >
> > Going to sleep should disable PLL since you need to reset the PLL after
> > waking.
> > Also, disabling the PLL after wake up if it was put to sleep at the
> > higher cclk also did not resolve the Uart0 problem. It seems as though
> > you need to wake up the processor and set to the ?same? frequency that
> > it was prior to going to sleep, maybe this has something to do with how
> > I put it to sleep?. I have not tried setting the PLL to the fast cclk on
> > wakeup and then changing it to the lower
> > speed. I will try this evening.
> > Stefan
> >
> > --- In l... ,
> > Sutton Mehaffey wrote:
> > >
> > > I don't think that interrupt resets the PLL does it? You might need to
> > > reset it to OFF manually.
> > >
> > >
> > >
> > > ssonderhoff wrote:
> > > >
> > > >
> > > > I am using EINT3 (non vectored).
> > > >
> > > > Once cclk was changed to 12 mhz before going to sleep, the uart0
> > worked
> > > > fine before and after sleep. I have changed the baud rate up to 115200
> > > > and it still is working fine.
> > > >
> > > > --- In l...
> > ,
> > > > Sutton Mehaffey wrote:
> > > > >
> > > > > How are you waking the system back up? Pressing reset?
> > > > >
> > > > >
> > > > >
> > > > > ssonderhoff wrote:
> > > > > >
> > > > > >
> > > > > > Though I am not sure why. It turns out that if you shut off the
> > PLL
> > > > and
> > > > > > change UART) settings before you put the system to sleep, then the
> > > > > > output is the desired text. If you go to sleep and then run the
> > > > > > identical code the output is the garbled nonsense I was
> > getting. Any
> > > > > > Ideas why this might be the case?
> > > > > > Thanks All,
> > > > > > Stefan
> > > > > >
> > > > > > --- In l...
> >
> > > > ,
> > > > > > "ssonderhoff" wrote:
> > > > > > >
> > > > > > >
> > > > > > > The board comes with the bootloader loaded and I have loaded
> > all my
> > > > > > firmware using the bootlader. I would hate to overwrite the
> > bootloader
> > > > > > and not be able to program the board. my test program puts the
> > > > computer
> > > > > > to sleep and then on wake up resets PLL or not, sets uart and then
> > > > goes
> > > > > > into a loop and contsantly prints out a string. At 60mhz everythng
> > > > works
> > > > > > and 12, not so much.
> > > > > > > Stefan
> > > > > > >
> > > > > > >
> > > > > > > --- In l...
> >
> > > > ,
> > > > > > "Michael Anton" wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: l...
> >
> > > >
> > > > > > > > > [mailto:l...
> >
> > > >
> > > > > > ]On Behalf
> > > > > > > > > Of ssonderhoff
> > > > > > > > > Sent: Monday, February 08, 2010 10:54 PM
> > > > > > > > > To: l...
> >
> > > >
> > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz pclk -
> > > > > > > > > not working
> > > > > > > > > - Any Advice would be app.
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > Hi,
> > > > > > > > > The system boots up using a boot loader that allows the unit
> > > > > > > > > to act as a thumb drive and access an SD card as well as load
> > > > > > > > > firmware updates from the sd card. This code initializes the
> > > > > > > > > system and sets the initial PLL and is difficult and
> > > > > > > > > dangerous for me to change. the code used to set PLL in the
> > > > > > > > > bootloader's Boot_up and system_init routines are shown below
> > > > > > > > > shown below:
> > > > > > > > >
> > > > > > > >
> > > > > > > > Couldn't you write a piece of standalone test code, without
> > > > > > > > the bootloader, to test your routines when running at 12MHz?
> > > > > > > >
> > > > > > > > >
> > > > > > > > > void boot_up(void)
> > > > > > > > > {
> > > > > > > > > //Initialize the MCU clock PLL
> > > > > > > > > system_init();
> > > > > > > > >
> > > > > > > > > IODIR0 |= (1 << 31);
> > > > > > > > > IOCLR0 |= (1 << 31); //Turn on USB LED
> > > > > > > > >
> > > > > > > > > //Init UART0 for debug
> > > > > > > > > PINSEL0 |= 0x00000005; //enable uart0
> > > > > > > > > U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit, DLAB = 1
> > > > > > > > > U0DLM = 0x00;
> > > > > > > > > U0DLL = 0x20; // 115200 Baud Rate @ 58982400 VPB Clock
> > > > > > > >
> > > > > > > > So are you using a 58982400Hz clock, or 60MHz? If this is not
> > > > > > > > 60MHz, you will likely encounter USB problems, as obviously you
> > > > > > > > cannot reach 48MHz with enough accuracy either.
> > > > > > > >
> > > > > > > > > U0LCR = 0x03; // DLAB = 0
> > > > > > > > >
> > > > > > > > > //Init rprintf
> > > > > > > > > rprintf_devopen(putc_serial0);
> > > > > > > > > rprintf("\n\n\nUSB Bootloader v1.1\n");
> > > > > > > > >
> > > > > > > > > //IOSET0 |= (1 << 31); //Turn off USB LED
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > > /**********************************************************
> > > > > > > > > Initialize
> > > > > > > > > **********************************************************/
> > > > > > > > >
> > > > > > > > > #define PLOCK 0x400
> > > > > > > > >
> > > > > > > > > void system_init(void)
> > > > > > > > > {
> > > > > > > > > // Setting Multiplier and Divider values
> > > > > > > > > PLLCFG=0x24;
> > > > > > > > > feed();
> > > > > > > > >
> > > > > > > > > // Enabling the PLL */
> > > > > > > > > PLLCON=0x1;
> > > > > > > > > feed();
> > > > > > > > >
> > > > > > > > > // Wait for the PLL to lock to set frequency
> > > > > > > > > while(!(PLLSTAT & PLOCK)) ;
> > > > > > > > >
> > > > > > > > > // Connect the PLL as the clock source
> > > > > > > > > PLLCON=0x3;
> > > > > > > > > feed();
> > > > > > > > >
> > > > > > > > > // Enabling MAM and setting number of clocks used for
> > > > > > > > > Flash memory fetch (4 cclks in this case)
> > > > > > > > > //MAMTIM=0x3; //VCOM?
> > > > > > > > > MAMCR=0x2;
> > > > > > > > > MAMTIM=0x4; //Original
> > > > > > > >
> > > > > > > > It may not matter, but I usually change the MAM timing values
> > > > > > > > prior to enabling the PLL. My rational is that if the values
> > > > > > > > are set wrong when already running at 60MHz, how could I expect
> > > > > > > > to reliably set them? Since there is no guarantee that I
> > can read
> > > > > > > > from flash if they are set for a lower clock rate.
> > > > > > > >
> > > > > > > > >
> > > > > > > > > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > > > > > > > > VPBDIV=0x1;
> > > > > > > > > }
> > > > > > > > >
> > > > > > > > >
> > > > > > > >
> > > > > > > > Like I said before, your initialization looks fine, but I
> > > > suspect the
> > > > > > > > problem you are having might be elsewhere. So it would be
> > useful to
> > > > > > > > see the rest of your serial port code. Perhaps there is
> > some timing
> > > > > > > > issue that occurs when you run 5 times slower.
> > > > > > > >
> > > > > > > > When I developed my UART code, I had all sorts of problems
> > that
> > > > would
> > > > > > > > occur at times, with seemingly no explanation, until I
> > figured out
> > > > > > > > the problem. It was very non-obvious at the time.
> > > > > > > >
> > > > > > > > So, if you can, break this down into a small piece of code that
> > > > > > > > demonstrates the problem, I'll take a look at it.
> > > > > > > >
> > > > > > > > Mike
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > > --- In l...
> >
> > > >
> > > > > > , "Michael Anton"
> > wrote:
> > > > > > > > > >
> > > > > > > > > > Perhaps you could post the balance of your UART code. The
> > > > > > > > > initialization
> > > > > > > > > > looks fine to me.
> > > > > > > > > >
> > > > > > > > > > Have you tried using only 12MHz, and not going into 60MHz?
> > > > > > > > > Just to see if
> > > > > > > > > > it is the changing
> > > > > > > > > > between the clock speeds that has something to do with the
> > > > > > > > > behaviour you are
> > > > > > > > > > seeing.
> > > > > > > > > >
> > > > > > > > > > Mike
> > > > > > > > > >
> > > > > > > > > > -----Original Message-----
> > > > > > > > > > From: l...
> >
> > > >
> > > > > > > > > [mailto:l...
> >
> > > >
> > > > > > ]On Behalf Of
> > > > > > > > > > ssonderhoff
> > > > > > > > > > Sent: Monday, February 08, 2010 8:46 PM
> > > > > > > > > > To: l...
> >
> > > >
> > > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz
> > > > > > > > > pclk - not working -
> > > > > > > > > > Any Advice would be app.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > I will be appreciative for any insights, this is starting
> > > > > > > > > to get quite
> > > > > > > > > > frustrating.
> > > > > > > > > >
> > > > > > > > > > This is the code used to set the PLL to 60mhz. I modified
> > > > > > > > > it to not set
> > > > > > > > > > the PLL in slow mode (12mhz) on wake up and then eliminated
> > > > > > > > > going to this
> > > > > > > > > > code all together. all gave the same result. As i mentioned
> > > > > > earlier,
> > > > > > > > > > everything works fine at 60mhz, where as at 12 mhz it has
> > > > > > > > > not worked with or
> > > > > > > > > > without setting PLL. UART settings are in the previous
> > message
> > > > > > > > > >
> > > > > > > > > > Thanks again,
> > > > > > > > > > Stefan
> > > > > > > > > >
> > > > > > > > > > void PLL_init(int speed)
> > > > > > > > > > {
> > > > > > > > > >
> > > > > > > > > > if(speed==fast){PLLCFG=0x24;} // Setting
> > > > > > > > > Multiplier(5) and Divider(4)
> > > > > > > > > > so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > else{VPBDIV = 0x1; return;} //pclk = cclk PLLCFG=0x60
> > > > > > > > > >
> > > > > > > > > > feed();
> > > > > > > > > >
> > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > feed();
> > > > > > > > > >
> > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the PLL to lock
> > to set
> > > > > > > > > > frequency
> > > > > > > > > >
> > > > > > > > > > PLLCON=0x3;// Connect the PLL as the clock source
> > > > > > > > > > feed();
> > > > > > > > > > }
> > > > > > > > > > --- In l...
> >
> > > >
> > > > > > , "ssonderhoff"
> > > > > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > I removed the setting the PLL - after wake up I do not
> > > > set PLL -
> > > > > > > > > > > same problem - UART0 outputs garbage (see sample)
> > > > > > > > > > >
> > > > > > > > > > > 07*6@7*6@0w*4@0w*4.
> > > > > > > > > > >
> > > > > > > > > > > the light on the serial connection is blinking and the
> > > > > > > > > junk is being
> > > > > > > > > > output at a regular interval. these are the settings used
> > > > > > > > > to set the baud
> > > > > > > > > > rate to 9600 - They seem correct to me
> > > > > > > > > > >
> > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop bit, DLAB = 1
> > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > U0DLL = 0x4E; //lsb = 78
> > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > U0LCR &= ~(0x80); // turn off DLAB //U0LCR = x03;
> > > > > > > > > > > //VICIntEnClr = 0x00000040;
> > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > >
> > > > > > > > > > > I am at a loss and would appreciate any help
> > > > > > > > > > > Stefan
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > --- In l...
> >
> > > >
> > > > > > , Sutton Mehaffey sutton@ wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > I don't turn PLL on when I use PCLK=CCLK. Mine works
> > > > > > > > > fine. Try it and
> > > > > > > > > > > > see if it fixes your problem. I think you only need
> > > > > > > > > PLL on if you need
> > > > > > > > > > > > more speed than PCLK.
> > > > > > > > > > > >
> > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thanks for the reply. I am running at 12mhz, and
> > > > > > > > > the I have a
> > > > > > > > > > blinking
> > > > > > > > > > > > > light that confirms that this is the case, along
> > > > > > > > > with a decrease in
> > > > > > > > > > > > > power draw. I am setting the multiplier(M) to 1. I
> > > > > > > > > thought that you
> > > > > > > > > > > > > had to specify the M and P values as well as select
> > > > > > > > > the external
> > > > > > > > > > > > > oscillator. Could this be screwing things up? How
> > > > > > > > > does one avoid
> > > > > > > > > > using
> > > > > > > > > > > > > the PLL? on waking up from sleep mode, do you bother
> > > > setting
> > > > > > > > > > anything,
> > > > > > > > > > > > > or should you actively disable the PLL by setting
> > > > > > > > > PLLC and PLLE to
> > > > > > > > > > 0?
> > > > > > > > > > > > > I assume that Pclk would then = cclk.
> > > > > > > > > > > > >
> > > > > > > > > > > > > Thanks again for the advice
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In l...
> >
> > > >
> > > > > >
> > > > > > > > > ,
> > > > > > > > > > > > > Sutton Mehaffey wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > What's your Fosc? If it is 12, I don't think you
> > > > > > > > > need to activate
> > > > > > > > > > PLL0,
> > > > > > > > > > > > > > if that's your CCLK speed.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Perhaps I should re-state the question. The
> > > > > > > > > PLLCFG and UART)
> > > > > > > > > > settings
> > > > > > > > > > > > > > > seem to be correct - Please let me know if you
> > > > > > > > > can see some
> > > > > > > > > > > > > mistake - Is
> > > > > > > > > > > > > > > there anything else that could affect UART0
> > > > > > > > > after a cclk change.
> > > > > > > > > > The
> > > > > > > > > > > > > > > port is active, but the output is garbage. Any
> > > > > > > > > thoughts would be
> > > > > > > > > > > > > welcome.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In lpc2000@yahoogroups .com
> > > > > > > > > > ,
> > > > > > > > > > > > > > > "ssonderhoff" wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I am running the lpc2148 at a low clock speed
> > > > > > > > > of 12 mhz to
> > > > > > > > > > reduce
> > > > > > > > > > > > > > > power usage. This is working, the power
> > > > > > > > > consumption is down and
> > > > > > > > > > a
> > > > > > > > > > > > > light
> > > > > > > > > > > > > > > blinks at the correct rate. for each speed I
> > > > > > > > > reset the Uart0
> > > > > > > > > > > > > parameters
> > > > > > > > > > > > > > > to take the pclk into account (code below)
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > the PLL_int(code below) sets processor to
> > > > 12mhz(slow).
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > At 60mhz Everything is working fine fine and
> > > > > > > > > I can read the
> > > > > > > > > > output
> > > > > > > > > > > > > > > debug text without any problem.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > At 12 mhz it outputs nothing but garbage, I
> > > > > > > > > have tried setting
> > > > > > > > > > to
> > > > > > > > > > > > > > > different baud rates from low to high with the
> > > > > > > > > same result.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > The Uart settings were determined using the
> > > > > > > > > NXP lpc2000
> > > > > > > > > > calculator
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > I believe that I have faithfully followed the
> > > > > > > > > data sheet. Can
> > > > > > > > > > > > > anyone
> > > > > > > > > > > > > > > tell me what I am missing?
> > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > Stefan
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > //*********CODE* ********* *
> > > > > > > > > > > > > > > > void PLL_init(int speed) // sets clock speed
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > if(speed==fast) {PLLCFG=0x24; } // Setting
> > > > > > > > > Multiplier(5) and
> > > > > > > > > > > > > > > Divider(4) so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > > > > > > > else{PLLCFG= 0x60;VPBDIV = 0x1;} //Setting
> > > > > > > > > Multiplier(1) and
> > > > > > > > > > > > > > > Divider(8) 1xosc = 12mhz: pclk = cclk
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the
> > > > > > > > > PLL to lock to set
> > > > > > > > > > > > > frequency
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > PLLCON=0x3;/ / Connect the PLL as the clock
> > source
> > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > //********** ********* ********* *********
> > > > > > > > > ********* *********
> > > > > > > > > > > > > > > ********* ***
> > > > > > > > > > > > > > > > void setuart(int speed) //sets up UART0
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > if(speed==fast)
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > U0DLL = 0x20; //lsb = 32
> > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > U0LCR = 0x03; // 8 bit character length
> > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > else //initialize uart0 115200 buad 12mhz
> > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > U0DLL = 0x6; //lsb = 6
> > > > > > > > > > > > > > > > U0FDR = 0xC1; //fract divider divaddval(3:
> > 0) = 1 &
> > > > > > > > > > mulval(7:4) = 12
> > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > U0LCR = 0x03;
> > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --
> > > > > > > > > > > > > > Sutton Mehaffey
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >

An Engineer's Guide to the LPC2100 Series

I hear you and understand your issue. But, I put a breakpoint in my
code after wakeup and the values of PLL0 had not changed. I'm not using
any uarts, so I couldn't test any output. So, maybe even though the
PLL0 values don't change, maybe you still have to reinitialize it to get
it going. Don't have time to investigate, right now, however.

Sutton

ssonderhoff wrote:
>
>
> According to the manual going to sleep disconnects the PLL which must
> then be reconnected in software, this will not happen automatically. in
> the absence of that, cclk = osc frequency. The PLL configuration is not
> reset, but when I went to sleep at 60mhz and then actively reset them to
> the 12mhz immediately after waking up the cclk was set lower ( I timed
> LED flashes that indicated that the processor speed was around 1/5 of
> the before sleep rate) but Uart0 would only output garbage even after
> resetting the uart0 settings. These same settings worked fine if the
> cclk and uart0 were changed before sleep
>
> ie:
> cclk 60mhz ->sleep-> set 12mhz and uart = uart outputs garbage
> cclk 60mhz -> set 12mhz and uart -> sleep = uart output is fine
>
> Thanks,
> Stefan
>
> --- In l... ,
> Sutton Mehaffey wrote:
> >
> > I just tried it. I had PCLK = CCLK = 12mhz (PLL off). I set it to
> > 18mhz before sleep mode (PLL0CON = 1, and PLL0CFG set to some value).
> > It was still 18mhz after EINT3 wake up, with the same PLL0 values. So,
> > waking up after going to sleep mode does not reset PLL values. An
> > actual reset (software or hardware) probably does.
> >
> >
> >
> > ssonderhoff wrote:
> > >
> > >
> > > Going to sleep should disable PLL since you need to reset the PLL
> after
> > > waking.
> > > Also, disabling the PLL after wake up if it was put to sleep at the
> > > higher cclk also did not resolve the Uart0 problem. It seems as though
> > > you need to wake up the processor and set to the ?same? frequency that
> > > it was prior to going to sleep, maybe this has something to do with
> how
> > > I put it to sleep?. I have not tried setting the PLL to the fast
> cclk on
> > > wakeup and then changing it to the lower
> > > speed. I will try this evening.
> > > Stefan
> > >
> > > --- In l...
> ,
> > > Sutton Mehaffey wrote:
> > > >
> > > > I don't think that interrupt resets the PLL does it? You might
> need to
> > > > reset it to OFF manually.
> > > >
> > > >
> > > >
> > > > ssonderhoff wrote:
> > > > >
> > > > >
> > > > > I am using EINT3 (non vectored).
> > > > >
> > > > > Once cclk was changed to 12 mhz before going to sleep, the uart0
> > > worked
> > > > > fine before and after sleep. I have changed the baud rate up to
> 115200
> > > > > and it still is working fine.
> > > > >
> > > > > --- In l...
>
> > > ,
> > > > > Sutton Mehaffey wrote:
> > > > > >
> > > > > > How are you waking the system back up? Pressing reset?
> > > > > >
> > > > > >
> > > > > >
> > > > > > ssonderhoff wrote:
> > > > > > >
> > > > > > >
> > > > > > > Though I am not sure why. It turns out that if you shut off
> the
> > > PLL
> > > > > and
> > > > > > > change UART) settings before you put the system to sleep,
> then the
> > > > > > > output is the desired text. If you go to sleep and then run the
> > > > > > > identical code the output is the garbled nonsense I was
> > > getting. Any
> > > > > > > Ideas why this might be the case?
> > > > > > > Thanks All,
> > > > > > > Stefan
> > > > > > >
> > > > > > > --- In l...
>
> > >
> > > > > ,
> > > > > > > "ssonderhoff" wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > The board comes with the bootloader loaded and I have loaded
> > > all my
> > > > > > > firmware using the bootlader. I would hate to overwrite the
> > > bootloader
> > > > > > > and not be able to program the board. my test program puts the
> > > > > computer
> > > > > > > to sleep and then on wake up resets PLL or not, sets uart
> and then
> > > > > goes
> > > > > > > into a loop and contsantly prints out a string. At 60mhz
> everythng
> > > > > works
> > > > > > > and 12, not so much.
> > > > > > > > Stefan
> > > > > > > >
> > > > > > > >
> > > > > > > > --- In l...
>
> > >
> > > > > ,
> > > > > > > "Michael Anton" wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > -----Original Message-----
> > > > > > > > > > From: l...
>
> > >
> > > > >
>
> > > > > > > > > > [mailto:l...
>
> > >
> > > > >
> > > > > > > ]On Behalf
> > > > > > > > > > Of ssonderhoff
> > > > > > > > > > Sent: Monday, February 08, 2010 10:54 PM
> > > > > > > > > > To: l...
>
> > >
> > > > >
>
> > > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz
> pclk -
> > > > > > > > > > not working
> > > > > > > > > > - Any Advice would be app.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Hi,
> > > > > > > > > > The system boots up using a boot loader that allows
> the unit
> > > > > > > > > > to act as a thumb drive and access an SD card as well
> as load
> > > > > > > > > > firmware updates from the sd card. This code
> initializes the
> > > > > > > > > > system and sets the initial PLL and is difficult and
> > > > > > > > > > dangerous for me to change. the code used to set PLL
> in the
> > > > > > > > > > bootloader's Boot_up and system_init routines are
> shown below
> > > > > > > > > > shown below:
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Couldn't you write a piece of standalone test code, without
> > > > > > > > > the bootloader, to test your routines when running at
> 12MHz?
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > void boot_up(void)
> > > > > > > > > > {
> > > > > > > > > > //Initialize the MCU clock PLL
> > > > > > > > > > system_init();
> > > > > > > > > >
> > > > > > > > > > IODIR0 |= (1 << 31);
> > > > > > > > > > IOCLR0 |= (1 << 31); //Turn on USB LED
> > > > > > > > > >
> > > > > > > > > > //Init UART0 for debug
> > > > > > > > > > PINSEL0 |= 0x00000005; //enable uart0
> > > > > > > > > > U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit, DLAB = 1
> > > > > > > > > > U0DLM = 0x00;
> > > > > > > > > > U0DLL = 0x20; // 115200 Baud Rate @ 58982400 VPB Clock
> > > > > > > > >
> > > > > > > > > So are you using a 58982400Hz clock, or 60MHz? If this
> is not
> > > > > > > > > 60MHz, you will likely encounter USB problems, as
> obviously you
> > > > > > > > > cannot reach 48MHz with enough accuracy either.
> > > > > > > > >
> > > > > > > > > > U0LCR = 0x03; // DLAB = 0
> > > > > > > > > >
> > > > > > > > > > //Init rprintf
> > > > > > > > > > rprintf_devopen(putc_serial0);
> > > > > > > > > > rprintf("\n\n\nUSB Bootloader v1.1\n");
> > > > > > > > > >
> > > > > > > > > > //IOSET0 |= (1 << 31); //Turn off USB LED
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> /**********************************************************
> > > > > > > > > > Initialize
> > > > > > > > > >
> **********************************************************/
> > > > > > > > > >
> > > > > > > > > > #define PLOCK 0x400
> > > > > > > > > >
> > > > > > > > > > void system_init(void)
> > > > > > > > > > {
> > > > > > > > > > // Setting Multiplier and Divider values
> > > > > > > > > > PLLCFG=0x24;
> > > > > > > > > > feed();
> > > > > > > > > >
> > > > > > > > > > // Enabling the PLL */
> > > > > > > > > > PLLCON=0x1;
> > > > > > > > > > feed();
> > > > > > > > > >
> > > > > > > > > > // Wait for the PLL to lock to set frequency
> > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;
> > > > > > > > > >
> > > > > > > > > > // Connect the PLL as the clock source
> > > > > > > > > > PLLCON=0x3;
> > > > > > > > > > feed();
> > > > > > > > > >
> > > > > > > > > > // Enabling MAM and setting number of clocks used for
> > > > > > > > > > Flash memory fetch (4 cclks in this case)
> > > > > > > > > > //MAMTIM=0x3; //VCOM?
> > > > > > > > > > MAMCR=0x2;
> > > > > > > > > > MAMTIM=0x4; //Original
> > > > > > > > >
> > > > > > > > > It may not matter, but I usually change the MAM timing
> values
> > > > > > > > > prior to enabling the PLL. My rational is that if the
> values
> > > > > > > > > are set wrong when already running at 60MHz, how could
> I expect
> > > > > > > > > to reliably set them? Since there is no guarantee that I
> > > can read
> > > > > > > > > from flash if they are set for a lower clock rate.
> > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > > > > > > > > > VPBDIV=0x1;
> > > > > > > > > > }
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > Like I said before, your initialization looks fine, but I
> > > > > suspect the
> > > > > > > > > problem you are having might be elsewhere. So it would be
> > > useful to
> > > > > > > > > see the rest of your serial port code. Perhaps there is
> > > some timing
> > > > > > > > > issue that occurs when you run 5 times slower.
> > > > > > > > >
> > > > > > > > > When I developed my UART code, I had all sorts of problems
> > > that
> > > > > would
> > > > > > > > > occur at times, with seemingly no explanation, until I
> > > figured out
> > > > > > > > > the problem. It was very non-obvious at the time.
> > > > > > > > >
> > > > > > > > > So, if you can, break this down into a small piece of
> code that
> > > > > > > > > demonstrates the problem, I'll take a look at it.
> > > > > > > > >
> > > > > > > > > Mike
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > --- In l...
>
> > >
> > > > >
> > > > > > > , "Michael Anton"
> > > wrote:
> > > > > > > > > > >
> > > > > > > > > > > Perhaps you could post the balance of your UART
> code. The
> > > > > > > > > > initialization
> > > > > > > > > > > looks fine to me.
> > > > > > > > > > >
> > > > > > > > > > > Have you tried using only 12MHz, and not going into
> 60MHz?
> > > > > > > > > > Just to see if
> > > > > > > > > > > it is the changing
> > > > > > > > > > > between the clock speeds that has something to do
> with the
> > > > > > > > > > behaviour you are
> > > > > > > > > > > seeing.
> > > > > > > > > > >
> > > > > > > > > > > Mike
> > > > > > > > > > >
> > > > > > > > > > > -----Original Message-----
> > > > > > > > > > > From: l...
>
> > >
> > > > >
>
> > > > > > > > > > [mailto:l...
>
> > >
> > > > >
> > > > > > > ]On Behalf Of
> > > > > > > > > > > ssonderhoff
> > > > > > > > > > > Sent: Monday, February 08, 2010 8:46 PM
> > > > > > > > > > > To: l...
>
> > >
> > > > >
>
> > > > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz
> > > > > > > > > > pclk - not working -
> > > > > > > > > > > Any Advice would be app.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I will be appreciative for any insights, this is
> starting
> > > > > > > > > > to get quite
> > > > > > > > > > > frustrating.
> > > > > > > > > > >
> > > > > > > > > > > This is the code used to set the PLL to 60mhz. I
> modified
> > > > > > > > > > it to not set
> > > > > > > > > > > the PLL in slow mode (12mhz) on wake up and then
> eliminated
> > > > > > > > > > going to this
> > > > > > > > > > > code all together. all gave the same result. As i
> mentioned
> > > > > > > earlier,
> > > > > > > > > > > everything works fine at 60mhz, where as at 12 mhz
> it has
> > > > > > > > > > not worked with or
> > > > > > > > > > > without setting PLL. UART settings are in the previous
> > > message
> > > > > > > > > > >
> > > > > > > > > > > Thanks again,
> > > > > > > > > > > Stefan
> > > > > > > > > > >
> > > > > > > > > > > void PLL_init(int speed)
> > > > > > > > > > > {
> > > > > > > > > > >
> > > > > > > > > > > if(speed=t){PLLCFG=0x24;} // Setting
> > > > > > > > > > Multiplier(5) and Divider(4)
> > > > > > > > > > > so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > > else{VPBDIV = 0x1; return;} //pclk = cclk PLLCFG=0x60
> > > > > > > > > > >
> > > > > > > > > > > feed();
> > > > > > > > > > >
> > > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > > feed();
> > > > > > > > > > >
> > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the PLL to lock
> > > to set
> > > > > > > > > > > frequency
> > > > > > > > > > >
> > > > > > > > > > > PLLCON=0x3;// Connect the PLL as the clock source
> > > > > > > > > > > feed();
> > > > > > > > > > > }
> > > > > > > > > > > --- In l...
>
> > >
> > > > >
> > > > > > > , "ssonderhoff"
> > > > > > > > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > I removed the setting the PLL - after wake up I
> do not
> > > > > set PLL -
> > > > > > > > > > > > same problem - UART0 outputs garbage (see sample)
> > > > > > > > > > > >
> > > > > > > > > > > > 07*6@7*6@0w*4@0w*4.
> > > > > > > > > > > >
> > > > > > > > > > > > the light on the serial connection is blinking
> and the
> > > > > > > > > > junk is being
> > > > > > > > > > > output at a regular interval. these are the
> settings used
> > > > > > > > > > to set the baud
> > > > > > > > > > > rate to 9600 - They seem correct to me
> > > > > > > > > > > >
> > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop bit,
> DLAB = 1
> > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > U0DLL = 0x4E; //lsb = 78
> > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > U0LCR &= ~(0x80); // turn off DLAB //U0LCR = x03;
> > > > > > > > > > > > //VICIntEnClr = 0x00000040;
> > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > >
> > > > > > > > > > > > I am at a loss and would appreciate any help
> > > > > > > > > > > > Stefan
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > --- In l...
>
> > >
> > > > >
> > > > > > > , Sutton Mehaffey sutton@
> wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > I don't turn PLL on when I use PCLKK. Mine
> works
> > > > > > > > > > fine. Try it and
> > > > > > > > > > > > > see if it fixes your problem. I think you only need
> > > > > > > > > > PLL on if you need
> > > > > > > > > > > > > more speed than PCLK.
> > > > > > > > > > > > >
> > > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Thanks for the reply. I am running at 12mhz, and
> > > > > > > > > > the I have a
> > > > > > > > > > > blinking
> > > > > > > > > > > > > > light that confirms that this is the case, along
> > > > > > > > > > with a decrease in
> > > > > > > > > > > > > > power draw. I am setting the multiplier(M) to
> 1. I
> > > > > > > > > > thought that you
> > > > > > > > > > > > > > had to specify the M and P values as well as
> select
> > > > > > > > > > the external
> > > > > > > > > > > > > > oscillator. Could this be screwing things up? How
> > > > > > > > > > does one avoid
> > > > > > > > > > > using
> > > > > > > > > > > > > > the PLL? on waking up from sleep mode, do you
> bother
> > > > > setting
> > > > > > > > > > > anything,
> > > > > > > > > > > > > > or should you actively disable the PLL by setting
> > > > > > > > > > PLLC and PLLE to
> > > > > > > > > > > 0?
> > > > > > > > > > > > > > I assume that Pclk would then = cclk.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > Thanks again for the advice
> > > > > > > > > > > > > >
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > --- In l...
>
> > >
> > > > >
> > > > > > >
> > > > > > > > > > ,
> > > > > > > > > > > > > > Sutton Mehaffey wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > What's your Fosc? If it is 12, I don't
> think you
> > > > > > > > > > need to activate
> > > > > > > > > > > PLL0,
> > > > > > > > > > > > > > > if that's your CCLK speed.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > Perhaps I should re-state the question. The
> > > > > > > > > > PLLCFG and UART)
> > > > > > > > > > > settings
> > > > > > > > > > > > > > > > seem to be correct - Please let me know
> if you
> > > > > > > > > > can see some
> > > > > > > > > > > > > > mistake - Is
> > > > > > > > > > > > > > > > there anything else that could affect UART0
> > > > > > > > > > after a cclk change.
> > > > > > > > > > > The
> > > > > > > > > > > > > > > > port is active, but the output is
> garbage. Any
> > > > > > > > > > thoughts would be
> > > > > > > > > > > > > > welcome.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --- In lpc2000@yahoogroups .com
> > > > > > > > > > > ,
> > > > > > > > > > > > > > > > "ssonderhoff" wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I am running the lpc2148 at a low clock
> speed
> > > > > > > > > > of 12 mhz to
> > > > > > > > > > > reduce
> > > > > > > > > > > > > > > > power usage. This is working, the power
> > > > > > > > > > consumption is down and
> > > > > > > > > > > a
> > > > > > > > > > > > > > light
> > > > > > > > > > > > > > > > blinks at the correct rate. for each speed I
> > > > > > > > > > reset the Uart0
> > > > > > > > > > > > > > parameters
> > > > > > > > > > > > > > > > to take the pclk into account (code below)
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > the PLL_int(code below) sets processor to
> > > > > 12mhz(slow).
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > At 60mhz Everything is working fine
> fine and
> > > > > > > > > > I can read the
> > > > > > > > > > > output
> > > > > > > > > > > > > > > > debug text without any problem.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > At 12 mhz it outputs nothing but garbage, I
> > > > > > > > > > have tried setting
> > > > > > > > > > > to
> > > > > > > > > > > > > > > > different baud rates from low to high
> with the
> > > > > > > > > > same result.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > The Uart settings were determined using the
> > > > > > > > > > NXP lpc2000
> > > > > > > > > > > calculator
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > I believe that I have faithfully
> followed the
> > > > > > > > > > data sheet. Can
> > > > > > > > > > > > > > anyone
> > > > > > > > > > > > > > > > tell me what I am missing?
> > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > Stefan
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > //*********CODE* ********* *
> > > > > > > > > > > > > > > > > void PLL_init(int speed) // sets clock
> speed
> > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > if(speed=t) {PLLCFG=0x24; } // Setting
> > > > > > > > > > Multiplier(5) and
> > > > > > > > > > > > > > > > Divider(4) so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > > > > > > > > else{PLLCFG= 0x60;VPBDIV = 0x1;} //Setting
> > > > > > > > > > Multiplier(1) and
> > > > > > > > > > > > > > > > Divider(8) 1xosc = 12mhz: pclk = cclk
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the
> > > > > > > > > > PLL to lock to set
> > > > > > > > > > > > > > frequency
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > PLLCON=0x3;/ / Connect the PLL as the
> clock
> > > source
> > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > //********** ********* ********* *********
> > > > > > > > > > ********* *********
> > > > > > > > > > > > > > > > ********* ***
> > > > > > > > > > > > > > > > > void setuart(int speed) //sets up UART0
> > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > if(speed=t)
> > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > > U0DLL = 0x20; //lsb = 32
> > > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > > U0LCR = 0x03; // 8 bit character length
> > > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > else //initialize uart0 115200 buad 12mhz
> > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > > U0DLL = 0x6; //lsb = 6
> > > > > > > > > > > > > > > > > U0FDR = 0xC1; //fract divider divaddval(3:
> > > 0) = 1 &
> > > > > > > > > > > mulval(7:4) = 12
> > > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > > U0LCR = 0x03;
> > > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > Sutton Mehaffey
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
The why of it is still a bit of a mystery to me but I appreciate all your input
Thanks,
Stefan

--- In l..., Sutton Mehaffey wrote:
>
> I hear you and understand your issue. But, I put a breakpoint in my
> code after wakeup and the values of PLL0 had not changed. I'm not using
> any uarts, so I couldn't test any output. So, maybe even though the
> PLL0 values don't change, maybe you still have to reinitialize it to get
> it going. Don't have time to investigate, right now, however.
>
> Sutton
>
> ssonderhoff wrote:
> >
> >
> > According to the manual going to sleep disconnects the PLL which must
> > then be reconnected in software, this will not happen automatically. in
> > the absence of that, cclk = osc frequency. The PLL configuration is not
> > reset, but when I went to sleep at 60mhz and then actively reset them to
> > the 12mhz immediately after waking up the cclk was set lower ( I timed
> > LED flashes that indicated that the processor speed was around 1/5 of
> > the before sleep rate) but Uart0 would only output garbage even after
> > resetting the uart0 settings. These same settings worked fine if the
> > cclk and uart0 were changed before sleep
> >
> > ie:
> > cclk 60mhz ->sleep-> set 12mhz and uart = uart outputs garbage
> > cclk 60mhz -> set 12mhz and uart -> sleep = uart output is fine
> >
> > Thanks,
> > Stefan
> >
> > --- In l... ,
> > Sutton Mehaffey wrote:
> > >
> > > I just tried it. I had PCLK = CCLK = 12mhz (PLL off). I set it to
> > > 18mhz before sleep mode (PLL0CON = 1, and PLL0CFG set to some value).
> > > It was still 18mhz after EINT3 wake up, with the same PLL0 values. So,
> > > waking up after going to sleep mode does not reset PLL values. An
> > > actual reset (software or hardware) probably does.
> > >
> > >
> > >
> > > ssonderhoff wrote:
> > > >
> > > >
> > > > Going to sleep should disable PLL since you need to reset the PLL
> > after
> > > > waking.
> > > > Also, disabling the PLL after wake up if it was put to sleep at the
> > > > higher cclk also did not resolve the Uart0 problem. It seems as though
> > > > you need to wake up the processor and set to the ?same? frequency that
> > > > it was prior to going to sleep, maybe this has something to do with
> > how
> > > > I put it to sleep?. I have not tried setting the PLL to the fast
> > cclk on
> > > > wakeup and then changing it to the lower
> > > > speed. I will try this evening.
> > > > Stefan
> > > >
> > > > --- In l...
> > ,
> > > > Sutton Mehaffey wrote:
> > > > >
> > > > > I don't think that interrupt resets the PLL does it? You might
> > need to
> > > > > reset it to OFF manually.
> > > > >
> > > > >
> > > > >
> > > > > ssonderhoff wrote:
> > > > > >
> > > > > >
> > > > > > I am using EINT3 (non vectored).
> > > > > >
> > > > > > Once cclk was changed to 12 mhz before going to sleep, the uart0
> > > > worked
> > > > > > fine before and after sleep. I have changed the baud rate up to
> > 115200
> > > > > > and it still is working fine.
> > > > > >
> > > > > > --- In l...
> >
> > > > ,
> > > > > > Sutton Mehaffey wrote:
> > > > > > >
> > > > > > > How are you waking the system back up? Pressing reset?
> > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > ssonderhoff wrote:
> > > > > > > >
> > > > > > > >
> > > > > > > > Though I am not sure why. It turns out that if you shut off
> > the
> > > > PLL
> > > > > > and
> > > > > > > > change UART) settings before you put the system to sleep,
> > then the
> > > > > > > > output is the desired text. If you go to sleep and then run the
> > > > > > > > identical code the output is the garbled nonsense I was
> > > > getting. Any
> > > > > > > > Ideas why this might be the case?
> > > > > > > > Thanks All,
> > > > > > > > Stefan
> > > > > > > >
> > > > > > > > --- In l...
> >
> > > >
> > > > > > ,
> > > > > > > > "ssonderhoff" wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > The board comes with the bootloader loaded and I have loaded
> > > > all my
> > > > > > > > firmware using the bootlader. I would hate to overwrite the
> > > > bootloader
> > > > > > > > and not be able to program the board. my test program puts the
> > > > > > computer
> > > > > > > > to sleep and then on wake up resets PLL or not, sets uart
> > and then
> > > > > > goes
> > > > > > > > into a loop and contsantly prints out a string. At 60mhz
> > everythng
> > > > > > works
> > > > > > > > and 12, not so much.
> > > > > > > > > Stefan
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --- In l...
> >
> > > >
> > > > > > ,
> > > > > > > > "Michael Anton" wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > -----Original Message-----
> > > > > > > > > > > From: l...
> >
> > > >
> > > > > >
> >
> > > > > > > > > > > [mailto:l...
> >
> > > >
> > > > > >
> > > > > > > > ]On Behalf
> > > > > > > > > > > Of ssonderhoff
> > > > > > > > > > > Sent: Monday, February 08, 2010 10:54 PM
> > > > > > > > > > > To: l...
> >
> > > >
> > > > > >
> >
> > > > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz
> > pclk -
> > > > > > > > > > > not working
> > > > > > > > > > > - Any Advice would be app.
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > Hi,
> > > > > > > > > > > The system boots up using a boot loader that allows
> > the unit
> > > > > > > > > > > to act as a thumb drive and access an SD card as well
> > as load
> > > > > > > > > > > firmware updates from the sd card. This code
> > initializes the
> > > > > > > > > > > system and sets the initial PLL and is difficult and
> > > > > > > > > > > dangerous for me to change. the code used to set PLL
> > in the
> > > > > > > > > > > bootloader's Boot_up and system_init routines are
> > shown below
> > > > > > > > > > > shown below:
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Couldn't you write a piece of standalone test code, without
> > > > > > > > > > the bootloader, to test your routines when running at
> > 12MHz?
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > void boot_up(void)
> > > > > > > > > > > {
> > > > > > > > > > > //Initialize the MCU clock PLL
> > > > > > > > > > > system_init();
> > > > > > > > > > >
> > > > > > > > > > > IODIR0 |= (1 << 31);
> > > > > > > > > > > IOCLR0 |= (1 << 31); //Turn on USB LED
> > > > > > > > > > >
> > > > > > > > > > > //Init UART0 for debug
> > > > > > > > > > > PINSEL0 |= 0x00000005; //enable uart0
> > > > > > > > > > > U0LCR = 0x83; // 8 bits, no Parity, 1 Stop bit, DLAB = 1
> > > > > > > > > > > U0DLM = 0x00;
> > > > > > > > > > > U0DLL = 0x20; // 115200 Baud Rate @ 58982400 VPB Clock
> > > > > > > > > >
> > > > > > > > > > So are you using a 58982400Hz clock, or 60MHz? If this
> > is not
> > > > > > > > > > 60MHz, you will likely encounter USB problems, as
> > obviously you
> > > > > > > > > > cannot reach 48MHz with enough accuracy either.
> > > > > > > > > >
> > > > > > > > > > > U0LCR = 0x03; // DLAB = 0
> > > > > > > > > > >
> > > > > > > > > > > //Init rprintf
> > > > > > > > > > > rprintf_devopen(putc_serial0);
> > > > > > > > > > > rprintf("\n\n\nUSB Bootloader v1.1\n");
> > > > > > > > > > >
> > > > > > > > > > > //IOSET0 |= (1 << 31); //Turn off USB LED
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > >
> > /**********************************************************
> > > > > > > > > > > Initialize
> > > > > > > > > > >
> > **********************************************************/
> > > > > > > > > > >
> > > > > > > > > > > #define PLOCK 0x400
> > > > > > > > > > >
> > > > > > > > > > > void system_init(void)
> > > > > > > > > > > {
> > > > > > > > > > > // Setting Multiplier and Divider values
> > > > > > > > > > > PLLCFG=0x24;
> > > > > > > > > > > feed();
> > > > > > > > > > >
> > > > > > > > > > > // Enabling the PLL */
> > > > > > > > > > > PLLCON=0x1;
> > > > > > > > > > > feed();
> > > > > > > > > > >
> > > > > > > > > > > // Wait for the PLL to lock to set frequency
> > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;
> > > > > > > > > > >
> > > > > > > > > > > // Connect the PLL as the clock source
> > > > > > > > > > > PLLCON=0x3;
> > > > > > > > > > > feed();
> > > > > > > > > > >
> > > > > > > > > > > // Enabling MAM and setting number of clocks used for
> > > > > > > > > > > Flash memory fetch (4 cclks in this case)
> > > > > > > > > > > //MAMTIM=0x3; //VCOM?
> > > > > > > > > > > MAMCR=0x2;
> > > > > > > > > > > MAMTIM=0x4; //Original
> > > > > > > > > >
> > > > > > > > > > It may not matter, but I usually change the MAM timing
> > values
> > > > > > > > > > prior to enabling the PLL. My rational is that if the
> > values
> > > > > > > > > > are set wrong when already running at 60MHz, how could
> > I expect
> > > > > > > > > > to reliably set them? Since there is no guarantee that I
> > > > can read
> > > > > > > > > > from flash if they are set for a lower clock rate.
> > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > // Setting peripheral Clock (pclk) to System Clock (cclk)
> > > > > > > > > > > VPBDIV=0x1;
> > > > > > > > > > > }
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Like I said before, your initialization looks fine, but I
> > > > > > suspect the
> > > > > > > > > > problem you are having might be elsewhere. So it would be
> > > > useful to
> > > > > > > > > > see the rest of your serial port code. Perhaps there is
> > > > some timing
> > > > > > > > > > issue that occurs when you run 5 times slower.
> > > > > > > > > >
> > > > > > > > > > When I developed my UART code, I had all sorts of problems
> > > > that
> > > > > > would
> > > > > > > > > > occur at times, with seemingly no explanation, until I
> > > > figured out
> > > > > > > > > > the problem. It was very non-obvious at the time.
> > > > > > > > > >
> > > > > > > > > > So, if you can, break this down into a small piece of
> > code that
> > > > > > > > > > demonstrates the problem, I'll take a look at it.
> > > > > > > > > >
> > > > > > > > > > Mike
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > > --- In l...
> >
> > > >
> > > > > >
> > > > > > > > , "Michael Anton"
> > > > wrote:
> > > > > > > > > > > >
> > > > > > > > > > > > Perhaps you could post the balance of your UART
> > code. The
> > > > > > > > > > > initialization
> > > > > > > > > > > > looks fine to me.
> > > > > > > > > > > >
> > > > > > > > > > > > Have you tried using only 12MHz, and not going into
> > 60MHz?
> > > > > > > > > > > Just to see if
> > > > > > > > > > > > it is the changing
> > > > > > > > > > > > between the clock speeds that has something to do
> > with the
> > > > > > > > > > > behaviour you are
> > > > > > > > > > > > seeing.
> > > > > > > > > > > >
> > > > > > > > > > > > Mike
> > > > > > > > > > > >
> > > > > > > > > > > > -----Original Message-----
> > > > > > > > > > > > From: l...
> >
> > > >
> > > > > >
> >
> > > > > > > > > > > [mailto:l...
> >
> > > >
> > > > > >
> > > > > > > > ]On Behalf Of
> > > > > > > > > > > > ssonderhoff
> > > > > > > > > > > > Sent: Monday, February 08, 2010 8:46 PM
> > > > > > > > > > > > To: l...
> >
> > > >
> > > > > >
> >
> > > > > > > > > > > > Subject: [lpc2000] Re: LPC2148 setting Uart0 at 12mhz
> > > > > > > > > > > pclk - not working -
> > > > > > > > > > > > Any Advice would be app.
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > >
> > > > > > > > > > > > I will be appreciative for any insights, this is
> > starting
> > > > > > > > > > > to get quite
> > > > > > > > > > > > frustrating.
> > > > > > > > > > > >
> > > > > > > > > > > > This is the code used to set the PLL to 60mhz. I
> > modified
> > > > > > > > > > > it to not set
> > > > > > > > > > > > the PLL in slow mode (12mhz) on wake up and then
> > eliminated
> > > > > > > > > > > going to this
> > > > > > > > > > > > code all together. all gave the same result. As i
> > mentioned
> > > > > > > > earlier,
> > > > > > > > > > > > everything works fine at 60mhz, where as at 12 mhz
> > it has
> > > > > > > > > > > not worked with or
> > > > > > > > > > > > without setting PLL. UART settings are in the previous
> > > > message
> > > > > > > > > > > >
> > > > > > > > > > > > Thanks again,
> > > > > > > > > > > > Stefan
> > > > > > > > > > > >
> > > > > > > > > > > > void PLL_init(int speed)
> > > > > > > > > > > > {
> > > > > > > > > > > >
> > > > > > > > > > > > if(speed==fast){PLLCFG=0x24;} // Setting
> > > > > > > > > > > Multiplier(5) and Divider(4)
> > > > > > > > > > > > so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > > > else{VPBDIV = 0x1; return;} //pclk = cclk PLLCFG=0x60
> > > > > > > > > > > >
> > > > > > > > > > > > feed();
> > > > > > > > > > > >
> > > > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > > > feed();
> > > > > > > > > > > >
> > > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the PLL to lock
> > > > to set
> > > > > > > > > > > > frequency
> > > > > > > > > > > >
> > > > > > > > > > > > PLLCON=0x3;// Connect the PLL as the clock source
> > > > > > > > > > > > feed();
> > > > > > > > > > > > }
> > > > > > > > > > > > --- In l...
> >
> > > >
> > > > > >
> > > > > > > > , "ssonderhoff"
> > > > > > > > > > > wrote:
> > > > > > > > > > > > >
> > > > > > > > > > > > > I removed the setting the PLL - after wake up I
> > do not
> > > > > > set PLL -
> > > > > > > > > > > > > same problem - UART0 outputs garbage (see sample)
> > > > > > > > > > > > >
> > > > > > > > > > > > > 07*6@7*6@0w*4@0w*4.
> > > > > > > > > > > > >
> > > > > > > > > > > > > the light on the serial connection is blinking
> > and the
> > > > > > > > > > > junk is being
> > > > > > > > > > > > output at a regular interval. these are the
> > settings used
> > > > > > > > > > > to set the baud
> > > > > > > > > > > > rate to 9600 - They seem correct to me
> > > > > > > > > > > > >
> > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop bit,
> > DLAB = 1
> > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > U0DLL = 0x4E; //lsb = 78
> > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > U0LCR &= ~(0x80); // turn off DLAB //U0LCR = x03;
> > > > > > > > > > > > > //VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > >
> > > > > > > > > > > > > I am at a loss and would appreciate any help
> > > > > > > > > > > > > Stefan
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > >
> > > > > > > > > > > > > --- In l...
> >
> > > >
> > > > > >
> > > > > > > > , Sutton Mehaffey sutton@
> > wrote:
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > I don't turn PLL on when I use PCLK=CCLK. Mine
> > works
> > > > > > > > > > > fine. Try it and
> > > > > > > > > > > > > > see if it fixes your problem. I think you only need
> > > > > > > > > > > PLL on if you need
> > > > > > > > > > > > > > more speed than PCLK.
> > > > > > > > > > > > > >
> > > > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Thanks for the reply. I am running at 12mhz, and
> > > > > > > > > > > the I have a
> > > > > > > > > > > > blinking
> > > > > > > > > > > > > > > light that confirms that this is the case, along
> > > > > > > > > > > with a decrease in
> > > > > > > > > > > > > > > power draw. I am setting the multiplier(M) to
> > 1. I
> > > > > > > > > > > thought that you
> > > > > > > > > > > > > > > had to specify the M and P values as well as
> > select
> > > > > > > > > > > the external
> > > > > > > > > > > > > > > oscillator. Could this be screwing things up? How
> > > > > > > > > > > does one avoid
> > > > > > > > > > > > using
> > > > > > > > > > > > > > > the PLL? on waking up from sleep mode, do you
> > bother
> > > > > > setting
> > > > > > > > > > > > anything,
> > > > > > > > > > > > > > > or should you actively disable the PLL by setting
> > > > > > > > > > > PLLC and PLLE to
> > > > > > > > > > > > 0?
> > > > > > > > > > > > > > > I assume that Pclk would then = cclk.
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > Thanks again for the advice
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > --- In l...
> >
> > > >
> > > > > >
> > > > > > > >
> > > > > > > > > > > ,
> > > > > > > > > > > > > > > Sutton Mehaffey wrote:
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > What's your Fosc? If it is 12, I don't
> > think you
> > > > > > > > > > > need to activate
> > > > > > > > > > > > PLL0,
> > > > > > > > > > > > > > > > if that's your CCLK speed.
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > ssonderhoff wrote:
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > Perhaps I should re-state the question. The
> > > > > > > > > > > PLLCFG and UART)
> > > > > > > > > > > > settings
> > > > > > > > > > > > > > > > > seem to be correct - Please let me know
> > if you
> > > > > > > > > > > can see some
> > > > > > > > > > > > > > > mistake - Is
> > > > > > > > > > > > > > > > > there anything else that could affect UART0
> > > > > > > > > > > after a cclk change.
> > > > > > > > > > > > The
> > > > > > > > > > > > > > > > > port is active, but the output is
> > garbage. Any
> > > > > > > > > > > thoughts would be
> > > > > > > > > > > > > > > welcome.
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > --- In lpc2000@yahoogroups .com
> > > > > > > > > > > > ,
> > > > > > > > > > > > > > > > > "ssonderhoff" wrote:
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I am running the lpc2148 at a low clock
> > speed
> > > > > > > > > > > of 12 mhz to
> > > > > > > > > > > > reduce
> > > > > > > > > > > > > > > > > power usage. This is working, the power
> > > > > > > > > > > consumption is down and
> > > > > > > > > > > > a
> > > > > > > > > > > > > > > light
> > > > > > > > > > > > > > > > > blinks at the correct rate. for each speed I
> > > > > > > > > > > reset the Uart0
> > > > > > > > > > > > > > > parameters
> > > > > > > > > > > > > > > > > to take the pclk into account (code below)
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > the PLL_int(code below) sets processor to
> > > > > > 12mhz(slow).
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At 60mhz Everything is working fine
> > fine and
> > > > > > > > > > > I can read the
> > > > > > > > > > > > output
> > > > > > > > > > > > > > > > > debug text without any problem.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > At 12 mhz it outputs nothing but garbage, I
> > > > > > > > > > > have tried setting
> > > > > > > > > > > > to
> > > > > > > > > > > > > > > > > different baud rates from low to high
> > with the
> > > > > > > > > > > same result.
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > The Uart settings were determined using the
> > > > > > > > > > > NXP lpc2000
> > > > > > > > > > > > calculator
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > I believe that I have faithfully
> > followed the
> > > > > > > > > > > data sheet. Can
> > > > > > > > > > > > > > > anyone
> > > > > > > > > > > > > > > > > tell me what I am missing?
> > > > > > > > > > > > > > > > > > Thanks,
> > > > > > > > > > > > > > > > > > Stefan
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > //*********CODE* ********* *
> > > > > > > > > > > > > > > > > > void PLL_init(int speed) // sets clock
> > speed
> > > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > if(speed==fast) {PLLCFG=0x24; } // Setting
> > > > > > > > > > > Multiplier(5) and
> > > > > > > > > > > > > > > > > Divider(4) so 5xosc (12mhz) = 60 mhz
> > > > > > > > > > > > > > > > > > else{PLLCFG= 0x60;VPBDIV = 0x1;} //Setting
> > > > > > > > > > > Multiplier(1) and
> > > > > > > > > > > > > > > > > Divider(8) 1xosc = 12mhz: pclk = cclk
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > PLLCON=0x1; // Enabling the PLL
> > > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > while(!(PLLSTAT & PLOCK)) ;// Wait for the
> > > > > > > > > > > PLL to lock to set
> > > > > > > > > > > > > > > frequency
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > PLLCON=0x3;/ / Connect the PLL as the
> > clock
> > > > source
> > > > > > > > > > > > > > > > > > feed();
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > > //********** ********* ********* *********
> > > > > > > > > > > ********* *********
> > > > > > > > > > > > > > > > > ********* ***
> > > > > > > > > > > > > > > > > > void setuart(int speed) //sets up UART0
> > > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > if(speed==fast)
> > > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > > > U0DLL = 0x20; //lsb = 32
> > > > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > > > U0LCR = 0x03; // 8 bit character length
> > > > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > > else //initialize uart0 115200 buad 12mhz
> > > > > > > > > > > > > > > > > > {
> > > > > > > > > > > > > > > > > > U0LCR = 0x83; // 8 bits, no parity, 1 stop
> > > > > > > > > > > bit, DLAB = 1
> > > > > > > > > > > > > > > > > > U0DLM = 0x00; //msb = 0
> > > > > > > > > > > > > > > > > > U0DLL = 0x6; //lsb = 6
> > > > > > > > > > > > > > > > > > U0FDR = 0xC1; //fract divider divaddval(3:
> > > > 0) = 1 &
> > > > > > > > > > > > mulval(7:4) = 12
> > > > > > > > > > > > > > > > > > U0FCR = 0x07; // enable and reset
> > > > > > > > > > > > > > > > > > U0LCR = 0x03;
> > > > > > > > > > > > > > > > > > VICIntEnClr = 0x00000040;
> > > > > > > > > > > > > > > > > > U0IER = 0x00;
> > > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > > > }
> > > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > >
> > > > > > > > > > > > > > > > --
> > > > > > > > > > > > > > > > Sutton Mehaffey
> > > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > >
Just to be clear - on wakeup from sleep, you call the PLL init function which waits for PLL lock, right? i.e. it's not enough to simply re-connect the PLL, you need to wait for the PLL to lock and THEN connect (which I assume you are doing, but I didn't see your sleep/wakeup code).

Also, are you very sure that your "feed()" function is not interrupted during the wake-up call? That could thwart the PLL-connect. You should keep your UART interrupts disabled until after the PLL has been re-initialised (after wake from sleep). Again, I assume this is what you're doing.

You should be able to do the PLL init to whatever speed you want, on wakeup - what you do to it before sleeping should not matter (*should* I guess being the key word here!). Very odd. Please post if you ever find out exactly what's going on.

regards,
Brian

I just noticed that your pll init function (as posted earlier) has an early "return" in the low-speed path - it is not setting the PLL up at all.

I definitely will update it if find the source of this behavior.
I do feed, wait for the PLL to stabilize before the connecting and the second feed. I cannot see how the feed function could be interrupted in my case. UART is not configured until after the PLL is initialized

UART, and pretty much everything else is shut down during sleep in PCONP. I tried connecting the PLL & UART both before and after external devices we activated but the outcome was the same.
Stefan
--- In l..., "brian_myers888" wrote:
>
> Just to be clear - on wakeup from sleep, you call the PLL init function which waits for PLL lock, right? i.e. it's not enough to simply re-connect the PLL, you need to wait for the PLL to lock and THEN connect (which I assume you are doing, but I didn't see your sleep/wakeup code).
>
> Also, are you very sure that your "feed()" function is not interrupted during the wake-up call? That could thwart the PLL-connect. You should keep your UART interrupts disabled until after the PLL has been re-initialised (after wake from sleep). Again, I assume this is what you're doing.
>
> You should be able to do the PLL init to whatever speed you want, on wakeup - what you do to it before sleeping should not matter (*should* I guess being the key word here!). Very odd. Please post if you ever find out exactly what's going on.
>
> regards,
> Brian
>

This is true, and was one of the many attempts made. I tried setting up PLL and then leaving it disconnected, as in this case, since at 12mhz cclk = osc. Both methods gave the same result according to the change speed afterwake -> uart0 produces junk

I am currently using this now that the speed was changed before sleep and it works fine.

--- In l..., "brian_myers888" wrote:
>
> I just noticed that your pll init function (as posted earlier) has an early "return" in the low-speed path - it is not setting the PLL up at all.
>