Yahoo Groups archive

Lpc2000

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

Message

Re: My LPC2106 won't return from function calls

2005-03-04 by charlesgrenz

Wheres the stack point to?

regards,
Charles


--- In lpc2000@yahoogroups.com, "ooggie01" <ooggie01@y...> wrote:
> 
> I'm trying to learn how to write C programs for my LPC-MT-2106 board 
> from Olimex.  I'm using the GNU toolchain for compiling/linking and 
> CrossWorks for programming the board.  I successfully got the LED to 
> blink; however, as soon as I introduced a function call, my code 
> won't work.  It still compiles/links/programs just fine, but the LED 
> won't change.  It seems like the processor never returns from any 
> function calls.  Any ideas why this may be?
> 
> I've included my code and makefile below.  The first program works 
> and the second one doesn't.
> 
> Thanks in advance!
> 
> Thomas
> 
> 
> 
> // led.c without function calls
> 
> /* General Purpose Input/Output (GPIO) */
> #define IOPIN	(*((volatile unsigned long *) 0xE0028000))
> #define IOSET	(*((volatile unsigned long *) 0xE0028004))
> #define IODIR	(*((volatile unsigned long *) 0xE0028008))	// 0-
> INPUT 1-OUTPUT
> #define IOCLR	(*((volatile unsigned long *) 0xE002800C))
> 
> #define LEDMASK 0x00001000	// LED	P0.12
> 
> unsigned int i;
> 
> int main()
> {
> 	IODIR = IODIR | LEDMASK;
> 	while(1)
> 	{
> 		IOCLR = IOCLR | LEDMASK;
> 		for( i = 0; i < 50000; i++ )
> 		{
> 		}
> 		IOSET = IOSET | LEDMASK;
> 		for( i = 0; i < 50000; i++ )
> 		{
> 		}
> 	}
> 	return 0;
> }
> // EOF
> 
> 
> // led.c with a function call
> 
> /* General Purpose Input/Output (GPIO) */
> #define IOPIN	(*((volatile unsigned long *) 0xE0028000))
> #define IOSET	(*((volatile unsigned long *) 0xE0028004))
> #define IODIR	(*((volatile unsigned long *) 0xE0028008))	// 0-
> INPUT 1-OUTPUT
> #define IOCLR	(*((volatile unsigned long *) 0xE002800C))
> 
> 
> #define LEDMASK 0x00001000	// LED	P0.12
> 
> void delay( unsigned int i )
> {
> 	for( i = 0; i < 50000; i++ )
> 	{
> 	}
> }
> 
> int main()
> {
> 	IODIR = IODIR | LEDMASK;
> 	while(1)
> 	{
> 		IOCLR = IOCLR | LEDMASK;
> 		delay( 50000 );
> 		IOSET = IOSET | LEDMASK;
> 		delay( 50000 );
> 	}
> 	return 0;
> }
> // EOF
> 
> 
> // makefile
> 
> arm-elf-gcc -c led.c -o led.o
> arm-elf-gcc -TLPCH40MB.LD -nostartfiles -o led.elf led.o

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.