Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Message

Re: Problem with GNUARM 3.4.3

2005-02-16 by Rick Collins

--- In lpc2000@yahoogroups.com, "Anton Erasmus" <antone@s...> wrote:
> I have now investigated further and it looks like a start-up
problem.
> I noticed that the number of rubbish characters sent was the number
> of characters in the actual string. The uart0Puts routine outputs
until a
> 0 is reached, hence if the pointer to the data was corrupted, then
the
> chances that it outputs the same number of characters are extremely
> unlikely. When I changed the main routine to the following:
> 
> void foo(void)
> {
>   uart0Puts("\r\nHello World!\r\n");
> }
> 
> int main(void)
> {
>   uint32_t startTime;
> 
>   sysInit();
> #if defined(UART0_TX_INT_MODE) || defined(UART0_RX_INT_MODE)
>   enableIRQ();
> #endif
>   startTime = getSysTICs();
>   foo();
> 
>   for (;;)
>     {
>     do
>       {
>       int ch;
> 
>       if ((ch = uart0Getch()) >= 0)
>       {
>         if(ch=='~')
>           foo();
>         uart0Putch(ch);
>       }
>       }
>     while (getElapsedSysTICs(startTime) < HALF_SEC);
> 
>     IOPIN ^= LED2_BIT;
> 
>     startTime += HALF_SEC;
>     }
> 
>   return 0;
> }
> 
> The first time foo() is called I get garbage out - although the
right number of chars.
> When I press ~, the right string is displayed every time. It looks
like the PLL might not 
> have locked properly or something else is causing the baudrate to be
incorrect at 
> startup. My circuit uses an external 14.7456MHz crystal oscillator
as the clock source.
> Using the PLL, I set the CPU clock to 58.9824MHz.

You can distinguish between a problem that requires time to fix it,
like a xtal startup time and an initialization problem by adding a
startup delay.  If this fixed the problem, you have something wrong
that fixes itself with time.  

I will say that a wrong baud rate is unlikely to result in the correct
number of characters.  Normally a baud rate that is off enough to
garble the characters will give you more or fewer characters as well.
 

So my guess is that something in the code is not initialized correctly
and gets fixed after some data is run through the port. 
 Very possibly a problem with passing a data pointer.  This may happen
after the character is checked for null, so it gets the count
correct.  

Another way to easily distinguish the two is to call foo() twice.  If
the second call is output corectly, then there is clearly an init
problem.

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.