Yahoo Groups archive

Lpc2000

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

Thread

pb with i2c interrupt with GCC

pb with i2c interrupt with GCC

2006-01-24 by sebfr74

Hi,
I modify actually an existing 8051 project to a LPC2138. I've quite 
finish to reprogram my product but I've got a problem with i2c 
interrupt in order to use a FRAM.
It's the only interrupt I use on this project, and when I try to 
write to the FRAM the LPC2138 reboot ??
I use GCC with Keil editor, and I use the exemple from the "insider 
guide" book for the i2c.

 This is my source code : (it's the call to i2c_transfer_byte() in 
main() who reboot....)

Thanks,
Sebastien

////////////////////////////////////////
#include <LPC22xx.H>


void I2CISR (void) __attribute__ ((interrupt));


void init_i2c()
{
	lock = 0;			
	PINSEL0  	 |= 0x50; 		
	I2SCLH 		 = 0x08;		
	I2SCLL 		 = 0x08;
}
//////////////////////////////
void I2CTransferByte(uint I2CAddr,uchar MemAddr,uchar count,uchar 
*data)
{
	while(lock == 1) watchdog();

	lock 		= 1;          

	I2CAddress 	= I2CAddr;		
	if(count >0) I2CData = data;

	I2Counter	= count;
	MemAddress	= MemAddr;
	I2CONCLR 	= 0x000000FF;	
	I2CONSET 	= 0x00000040; 	
	I2CONSET 	= 0x00000020; 	
}
/////////////////////////////////
void init_interrupt()
{
	VICVectCntl0 = 0x00000029;  		
	VICVectAddr0 = (unsigned long)I2CISR;	
	VICIntEnable = 0x00000200;			
}
////////////////////////////////
void watchdog()
{
	WDFEED = 0x000000AA; //Feed sequence pour relancer le watchdog
	WDFEED = 0x00000055;
}

///////////////////////////////////

void I2CISR (void) //I2C interrupt routine
{
	switch (I2STAT)					
	//Read result code and switch to next action
	{
		// Start and Send byte conditions
		case ( 0x08):				
	//Start bit
			I2CONCLR 	= 0x20;		
	//Clear start bit
			I2DAT   	= I2CAddress; 	//Send 
address and write bit
			break;

		case (0x18):				
	//Slave address+W, ACK
			I2DAT   	= MemAddress;	//Write 
Mem,ory start address to tx register
			break;

		case (0x20):				
	//Salve address +W, Not ACK
			I2DAT   	= I2CAddress; 	//Resend 
address and write bi
			break;

		case (0x28):
			if(I2Counter-->0)		
	//Data sent, Ack
			{
				I2DAT   	= *I2CData;
	//Write data to tx register
				I2CData++;
			}
			else
			{
				I2CONSET 	= 0x10;	
	//Stop condition
				lock = 0;               //Signal end 
of I2C activity
			}
			break;

		case (0x30)	:				
	//Data sent, NOT Ack
			I2DAT   	= *I2CData;	
	//Write data to tx register
			break;

		//Receive byte conditions
		case (0x40) :				
	//Slave Address +R, ACK
			I2CONSET 	= 0x04;		
	//Enable ACK for data byte
			break;

		case (0x48) :				
	//Slave Address +R, Not Ack
			I2CONSET 	= 0x20;		
	//Resend Start condition
			break;

		case (0x50) :				
	//Data Received, ACK 
			if(--I2Counter>0)
			{
				*I2CData 	= I2DAT;
				I2CData++;
			}
			else
			{
				I2CONSET 	= 0x10;	
	//Stop condition
				lock 		= 0;        //Signal 
end of I2C activity						
	
			}
			break;

		case (0x58):				
	//Data Received, Not Ack
			I2CONSET 	= 0x20;			// 
Resend Start condition
			break;

		default :
			break;

	}

	I2CONCLR 	= 0x08;				
	//Clear I2C interrupt flag
	VICVectAddr = 0x00000000;			//Clear 
interrupt in 
}

/////////////////////
void main(void)
{
	init_interrupt();
	init_i2c();

	while(1){
		watchdog();
		I2CTransferByte(0xA0,0,4,message);		
	//write data to the I2C Memory
	}
}

[lpc2000] pb getting EA's examples to compile (general gcc-arm help!)

2006-01-24 by Sean

Hello everyone.  I realize that this isn't necessarily the most appropriate 
forum for this, but it is the most responsive :)

I'm having troubles trying to get some of the samples for my dev kit to 
compile properly.  I installed everything as per defaults, but that didn't 
seem to set up a lot of necessary environment variables.  I'm trying to 
compile the uart_irq sample.

I have updated the executable path to be able to find make and the 
compilers, then it couldn't find any header files, so I updated the make 
files to include all necessary paths to find header files, then I got 
problems finding -lgcc and -lc, so I added -L flags to the makefile to 
point to (what I think are the correct) library paths, but now I get this:

------------------------------------------------
make[1]: Entering directory `uart_irq/startup'
rm -f .depend
make[1]: Leaving directory `uart_irq/startup'
make[1]: Entering directory `uart_irq/irq_code'
rm -f .depend
make[1]: Leaving directory `uart_irq/irq_code'
rm -f .depend
arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker input 
file unused because linking not done
arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker input 
file unused because linking not done
arm-elf-gcc -c -mcpu=arm7tdmi -mthumb-interwork -I./startup 
-I/Progra~1/gnuarm/arm-elf/include -I 
/Progra~1/gnuarm/lib/gcc/arm-elf/3.4.3/include -DEL -DGCC -mthumb-interwork 
-mthumb -DTHUMB_CSTART -DTHUMB_INTERWORK 
-L/Progra~1/GNUARM/lib/gcc/arm-elf/3.4.3/thumb/interwork /Progra~
1/GNUARM/arm-elf/lib/thumb/interwork -DLPC2148  -Os -gdwarf-2 -Wall 
-Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-arith 
-Wswitch -Wreturn-type -Wa,-ahlms=main.lst -o main.o main.c
arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker input 
file unused because linking not done
cc1: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: No such file or directory
cc1: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [main.o] Error 1
------------------------------------------------

yay segfault!

I'll admit, I'm a windows guy, I use command line a lot, but I have very 
little experience with cygwin and gnu utilities.  I have a licence to the 
ARM SDK 2.51 so I will probably try to use that in the future, but for now 
I'd just like to get the sample apps compiling and loaded.

Any ideas anyone?

Thanks!

-- Sean

Re: pb getting EA's examples to compile (general gcc-arm help!)

2006-01-24 by rtstofer

I am just guessing but I will bet your makefile is now very 
incorrect.  Why don't you post that file if it is a reasonable 
length.

Mine looks like this (but Yahoo will trash it):

NAME = Playstation Controller

CC = arm-elf-gcc
LD = arm-elf-ld -v
AR = arm-elf-ar
AS = arm-elf-as
CP = arm-elf-objcopy
OD = arm-elf-objdump

ARCHIVE1= "C:/Program Files/GNUARM/lib/gcc/arm-elf/3.4.3"
ARCHIVE2= "C:/Program Files/GNUARM/arm-elf/lib"
LIBFLAGS= -L${ARCHIVE2} -lc -lg -lm -L$(ARCHIVE1) -lgcc 
CFLAGS  = -I./ -c -fno-common -O0 -g -Wa,-ahls=$*.lst -Wall
AFLAGS  = -ahls -mapcs-32 -o crt.o
LFLAGS  =  -Map main.map -Tmain.cmd
CPFLAGS = -O ihex
ODFLAGS = -x --syms

objects = main.o conio.o spi.o timer.o interrupt.o setup.o

all: test

clean:
  -rm *.o *.lst *.dmp *.hex *.map *.out
	
test: main.out
 @ echo "...copying"
 $(CP) $(CPFLAGS) main.out main.hex
 $(OD) $(ODFLAGS) main.out > main.dmp

main.out: main.cmd crt.o $(objects)
 @ echo "..linking"
 $(LD) $(LFLAGS) -o main.out crt.o $(objects) $(LIBFLAGS)

crt.o: crt.s
 @ echo ".assembling"
 $(AS) $(AFLAGS) crt.s > crt.lst

$(objects): %.o: %.c
 @ echo ".compiling " $<
 $(CC) -c $(CFLAGS) $< -o $@

main.o: main.c setup.h spi.h conio.h timer.h lpc210x.h
conio.o: conio.c conio.h lpc210x.h
setup.o: setup.c setup.h spi.h lpc210x.h
spi.o: spi.c spi.h lpc210x.h
timer.o: timer.c timer.h
interrupt.o: interrupt.c interrupt.h lpc210x.h

The important part is the ARCHIVE1 and ARCHIVE2 paths and the 
LIBFLAGS definition.  The linker won't scan back and forth (without 
help) so the libraries have to be specified in the proper order.

Don't try to copy this file directly.  Make wants certain fields 
separated by TABS and they are now SPACES.

Richard




--- In lpc2000@yahoogroups.com, Sean <embeddedrelated@w...> wrote:
>
> Hello everyone.  I realize that this isn't necessarily the most 
appropriate 
> forum for this, but it is the most responsive :)
> 
> I'm having troubles trying to get some of the samples for my dev 
kit to 
> compile properly.  I installed everything as per defaults, but 
that didn't 
> seem to set up a lot of necessary environment variables.  I'm 
trying to 
> compile the uart_irq sample.
> 
> I have updated the executable path to be able to find make and the 
> compilers, then it couldn't find any header files, so I updated 
the make 
> files to include all necessary paths to find header files, then I 
got 
> problems finding -lgcc and -lc, so I added -L flags to the 
makefile to 
> point to (what I think are the correct) library paths, but now I 
get this:
> 
> ------------------------------------------------
> make[1]: Entering directory `uart_irq/startup'
> rm -f .depend
> make[1]: Leaving directory `uart_irq/startup'
> make[1]: Entering directory `uart_irq/irq_code'
> rm -f .depend
> make[1]: Leaving directory `uart_irq/irq_code'
> rm -f .depend
> arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker 
input 
> file unused because linking not done
> arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker 
input 
> file unused because linking not done
> arm-elf-gcc -c -mcpu=arm7tdmi -mthumb-interwork -I./startup 
> -I/Progra~1/gnuarm/arm-elf/include -I 
> /Progra~1/gnuarm/lib/gcc/arm-elf/3.4.3/include -DEL -DGCC -mthumb-
interwork 
> -mthumb -DTHUMB_CSTART -DTHUMB_INTERWORK 
> -L/Progra~1/GNUARM/lib/gcc/arm-elf/3.4.3/thumb/interwork /Progra~
> 1/GNUARM/arm-elf/lib/thumb/interwork -DLPC2148  -Os -gdwarf-2 -
Wall 
> -Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-
arith 
> -Wswitch -Wreturn-type -Wa,-ahlms=main.lst -o main.o main.c
> arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker 
input 
> file unused because linking not done
> cc1: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: No such file or 
directory
> cc1: internal compiler error: Segmentation fault
> Please submit a full bug report,
> with preprocessed source if appropriate.
> See <URL:http://gcc.gnu.org/bugs.html> for instructions.
> make: *** [main.o] Error 1
> ------------------------------------------------
> 
> yay segfault!
> 
> I'll admit, I'm a windows guy, I use command line a lot, but I 
have very 
> little experience with cygwin and gnu utilities.  I have a licence 
to the 
> ARM SDK 2.51 so I will probably try to use that in the future, but 
for now 
Show quoted textHide quoted text
> I'd just like to get the sample apps compiling and loaded.
> 
> Any ideas anyone?
> 
> Thanks!
> 
> -- Sean
>

Re: [lpc2000] Re: pb getting EA's examples to compile (general gcc-arm help!)

2006-01-24 by Sean

I found the problem, but thanks for your suggestion.

The error message that I was getting:

cc1: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: No such file or directory

was confusing because the directory existed.  However I forgot to precede 
that library path declaration with -L in the makefile.  A bit of a 
misleading error message, but ok.

-- Sean

At 12:51 PM 1/24/2006, you wrote:
Show quoted textHide quoted text
>I am just guessing but I will bet your makefile is now very
>incorrect.  Why don't you post that file if it is a reasonable
>length.
>
>Mine looks like this (but Yahoo will trash it):
>
>NAME = Playstation Controller
>
>CC = arm-elf-gcc
>LD = arm-elf-ld -v
>AR = arm-elf-ar
>AS = arm-elf-as
>CP = arm-elf-objcopy
>OD = arm-elf-objdump
>
>ARCHIVE1= "C:/Program Files/GNUARM/lib/gcc/arm-elf/3.4.3"
>ARCHIVE2= "C:/Program Files/GNUARM/arm-elf/lib"
>LIBFLAGS= -L${ARCHIVE2} -lc -lg -lm -L$(ARCHIVE1) -lgcc
>CFLAGS  = -I./ -c -fno-common -O0 -g -Wa,-ahls=$*.lst -Wall
>AFLAGS  = -ahls -mapcs-32 -o crt.o
>LFLAGS  =  -Map main.map -Tmain.cmd
>CPFLAGS = -O ihex
>ODFLAGS = -x --syms
>
>objects = main.o conio.o spi.o timer.o interrupt.o setup.o
>
>all: test
>
>clean:
>   -rm *.o *.lst *.dmp *.hex *.map *.out
>
>test: main.out
>@ echo "...copying"
>$(CP) $(CPFLAGS) main.out main.hex
>$(OD) $(ODFLAGS) main.out > main.dmp
>
>main.out: main.cmd crt.o $(objects)
>@ echo "..linking"
>$(LD) $(LFLAGS) -o main.out crt.o $(objects) $(LIBFLAGS)
>
>crt.o: crt.s
>@ echo ".assembling"
>$(AS) $(AFLAGS) crt.s > crt.lst
>
>$(objects): %.o: %.c
>@ echo ".compiling " $<
>$(CC) -c $(CFLAGS) $< -o $@
>
>main.o: main.c setup.h spi.h conio.h timer.h lpc210x.h
>conio.o: conio.c conio.h lpc210x.h
>setup.o: setup.c setup.h spi.h lpc210x.h
>spi.o: spi.c spi.h lpc210x.h
>timer.o: timer.c timer.h
>interrupt.o: interrupt.c interrupt.h lpc210x.h
>
>The important part is the ARCHIVE1 and ARCHIVE2 paths and the
>LIBFLAGS definition.  The linker won't scan back and forth (without
>help) so the libraries have to be specified in the proper order.
>
>Don't try to copy this file directly.  Make wants certain fields
>separated by TABS and they are now SPACES.
>
>Richard
>
>
>
>
>--- In lpc2000@yahoogroups.com, Sean <embeddedrelated@w...> wrote:
> >
> > Hello everyone.  I realize that this isn't necessarily the most
>appropriate
> > forum for this, but it is the most responsive :)
> >
> > I'm having troubles trying to get some of the samples for my dev
>kit to
> > compile properly.  I installed everything as per defaults, but
>that didn't
> > seem to set up a lot of necessary environment variables.  I'm
>trying to
> > compile the uart_irq sample.
> >
> > I have updated the executable path to be able to find make and the
> > compilers, then it couldn't find any header files, so I updated
>the make
> > files to include all necessary paths to find header files, then I
>got
> > problems finding -lgcc and -lc, so I added -L flags to the
>makefile to
> > point to (what I think are the correct) library paths, but now I
>get this:
> >
> > ------------------------------------------------
> > make[1]: Entering directory `uart_irq/startup'
> > rm -f .depend
> > make[1]: Leaving directory `uart_irq/startup'
> > make[1]: Entering directory `uart_irq/irq_code'
> > rm -f .depend
> > make[1]: Leaving directory `uart_irq/irq_code'
> > rm -f .depend
> > arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker
>input
> > file unused because linking not done
> > arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker
>input
> > file unused because linking not done
> > arm-elf-gcc -c -mcpu=arm7tdmi -mthumb-interwork -I./startup
> > -I/Progra~1/gnuarm/arm-elf/include -I
> > /Progra~1/gnuarm/lib/gcc/arm-elf/3.4.3/include -DEL -DGCC -mthumb-
>interwork
> > -mthumb -DTHUMB_CSTART -DTHUMB_INTERWORK
> > -L/Progra~1/GNUARM/lib/gcc/arm-elf/3.4.3/thumb/interwork /Progra~
> > 1/GNUARM/arm-elf/lib/thumb/interwork -DLPC2148  -Os -gdwarf-2 -
>Wall
> > -Wcast-align -Wcast-qual -Wimplicit -Wnested-externs -Wpointer-
>arith
> > -Wswitch -Wreturn-type -Wa,-ahlms=main.lst -o main.o main.c
> > arm-elf-gcc: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: linker
>input
> > file unused because linking not done
> > cc1: /Progra~1/GNUARM/arm-elf/lib/thumb/interwork: No such file or
>directory
> > cc1: internal compiler error: Segmentation fault
> > Please submit a full bug report,
> > with preprocessed source if appropriate.
> > See <URL:http://gcc.gnu.org/bugs.html> for instructions.
> > make: *** [main.o] Error 1
> > ------------------------------------------------
> >
> > yay segfault!
> >
> > I'll admit, I'm a windows guy, I use command line a lot, but I
>have very
> > little experience with cygwin and gnu utilities.  I have a licence
>to the
> > ARM SDK 2.51 so I will probably try to use that in the future, but
>for now
> > I'd just like to get the sample apps compiling and loaded.
> >
> > Any ideas anyone?
> >
> > Thanks!
> >
> > -- Sean
> >
>
>
>
>
>
>
>SPONSORED LINKS
><http://groups.yahoo.com/gads?t=ms&k=Microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=mfaAujKZXA2Z_vxre9sGnQ>Microcontrollers 
><http://groups.yahoo.com/gads?t=ms&k=Microprocessor&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=9jjd2D3GOLIESVQssLmLsA>Microprocessor 
><http://groups.yahoo.com/gads?t=ms&k=Intel+microprocessors&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=OMnZuqMZX95mgutt4B-tDw>Intel 
>microprocessors
><http://groups.yahoo.com/gads?t=ms&k=Pic+microcontrollers&w1=Microcontrollers&w2=Microprocessor&w3=Intel+microprocessors&w4=Pic+microcontrollers&c=4&s=95&.sig=Malspbd0T4Rq3M4Q0nHrfw>Pic 
>microcontrollers
>
>
>----------
>YAHOO! GROUPS LINKS
>
>    *  Visit your group "<http://groups.yahoo.com/group/lpc2000>lpc2000" 
> on the web.
>    *
>    *  To unsubscribe from this group, send an email to:
>    * 
> <mailto:lpc2000-unsubscribe@yahoogroups.com?subject=Unsubscribe>lpc2000-unsubscribe@yahoogroups.com 
>
>    *
>    *  Your use of Yahoo! Groups is subject to the 
> <http://docs.yahoo.com/info/terms/>Yahoo! Terms of Service.
>
>
>----------

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.