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.
Regards
Anton Erasmus
On 15 Feb 2005 at 23:29, Anton Erasmus wrote:
>
> On 15 Feb 2005 at 20:02, Rick Collins wrote:
>
> >
> >
> > Why don't you ask this in the gnuarm group?
> >
> > http://groups.yahoo.com/group/gnuarm
> >
> > There are tons of good people who can likely answer your question.
>
> I am not sure if it is an actual compiler problem, and not some linker
> script problem or some other finger problem. Since the example code is
> LPC specific, I thought others might have compiled it succesfully with
> gcc 3.4.3. If it is not some LPC specific problem, I will ask in the
> gnuarm group.
>
>
> > Also, I am curious, which web site did you use to download the code?
> > Did you do your own compile of the tools?
>
> I used the binary tools from http://www.gnuarm.com. Both the
> Windows/cygwin binary and the linux binary. I also built the compiler
> using the script and sources from Rod Moffitt's site. The problem is
> the same, both when compiled as ARM only code and ARM/THUMB code.
>
> Regards
> Anton Erasmus
>
> >
> > --- In lpc2000@yahoogroups.com, "Anton Erasmus" <antone@s...> wrote:
> > > Hi, > > I have installed the latest GNUARM which is based on gcc
> > 3.4.3. > I downloaded the UT040803A.zip uart example from the files
> > > area. > I compiled and downloaded the code to a LPC2292 board. The
> > code > runs as expected except for one thing. In stead of printing
> > "Hello World!", > it displays garbage. > The main routine is as
> > follows: > > int main(void) > { > uint32_t startTime; > >
> > sysInit(); > #if defined(UART0_TX_INT_MODE) ||
> > defined(UART0_RX_INT_MODE) > enableIRQ(); > #endif > startTime =
> > getSysTICs(); > uart0Puts("\r\nHello World!\r\n"); > > for (;;)
> > >
> > { > do > { > int ch; > > if ((ch =
> > uart0Getch()) >= 0) > uart0Putch(ch); > } > while
> > (getElapsedSysTICs(startTime) < HALF_SEC); > > IOPIN ^=
> > LED2_BIT;
> > > > startTime += HALF_SEC; > } > > return 0; > } > > The
> > section after the uart0Puts works. When I press a key on the serial
> > terminal, it is > echoed correctly back. So it seems that the baud
> > rate etc. is correct. If I compile the > code with no optimisation
> > (Default is set to O2), then it prints the "Hello World!" as >
> > expected. If I add a uart0Putch('U') before the uart0Puts, the U is
> > printed. If I add more, > then sometimes the "Hello World!" is
> > printed correctly. I have looked in the hex file > generated, and
> > the ASCII data is put in the .rodata section as expected. It looks
> > as if > the ASCII strings are aligned at 4 byte boundaries, so I do
> > not think it is an alignment > problem. > Has anyone else had
> > problems with literal strings using gcc 3.4.3 ? Any suggestions on >
> > where I can look to find the problem would be appreciated. > >
> > Regards > Anton Erasmus
> > > > > -- > A J Erasmus
> >
> >
> >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
>
> --
> A J Erasmus
>
>
>
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
--
A J Erasmus