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.oMessage
Re: My LPC2106 won't return from function calls
2005-03-04 by charlesgrenz
Attachments
- No local attachments were found for this message.