EmbeddedRelated.com
Forums

FIQ Newbie Help needed

Started by dba008nz April 11, 2009
I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm. Uart1 receives ASCII caharcters from a GPS at 19200 baud, and I am trying to get the FIQ interrupt to run every time there is a data comming into Uart1, but it does not work. I think the problem maybe to do with the FIQ vector address, and I don't know how to point it to 0x0000001C from where the FIQ jumps to. Any help would be gratefull. Cheers Doug.
#include
#include
#include "LPC21xx.h"
#include "armVIC.h"

char ReceivedByte = 0;
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));

int main (void)
{
PINSEL0 = 0xCC051505;
PINSEL1 = 0x00400001;
IODIR0 |= 0x00000884;
IOSET0 = 0x00000080;
S0SPCR = 0x08;
S0SPCR = 0x30;

// Uart1 setup, buad 19200 //
U1LCR = 0x83;
U1DLM = 0x00;
U1DLL = 0xC0;
U1FCR = 0x01;
U1LCR = 0x03;
VICIntSelect |= 0x00000080;
VICIntEnable |= 0x00000080;
VICVectCntl0 = 0x27;
VICVectAddr0 = (unsigned int)FIQ_Routine;
U1IER = 0x01;
enableFIQ();
while (1);
}

void FIQ_Routine(void)
{
char temp;
ReceivedByte =U1RBR;
temp = U1IIR;
VICVectAddr = 0;
}

An Engineer's Guide to the LPC2100 Series

There's some example code in the LPC2148 demo package at
http://jcwren.com/arm

On Fri, Apr 10, 2009 at 4:24 PM, dba008nz wrote:

> I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm. Uart1
> receives ASCII caharcters from a GPS at 19200 baud, and I am trying to get
> the FIQ interrupt to run every time there is a data comming into Uart1, but
> it does not work. I think the problem maybe to do with the FIQ vector
> address, and I don't know how to point it to 0x0000001C from where the FIQ
> jumps to. Any help would be gratefull. Cheers Doug.
>
> #include
> #include
> #include "LPC21xx.h"
> #include "armVIC.h"
>
> char ReceivedByte = 0;
> void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
>
> int main (void)
> {
> PINSEL0 = 0xCC051505;
> PINSEL1 = 0x00400001;
> IODIR0 |= 0x00000884;
> IOSET0 = 0x00000080;
> S0SPCR = 0x08;
> S0SPCR = 0x30;
>
> // Uart1 setup, buad 19200 //
> U1LCR = 0x83;
> U1DLM = 0x00;
> U1DLL = 0xC0;
> U1FCR = 0x01;
> U1LCR = 0x03;
> VICIntSelect |= 0x00000080;
> VICIntEnable |= 0x00000080;
> VICVectCntl0 = 0x27;
> VICVectAddr0 = (unsigned int)FIQ_Routine;
> U1IER = 0x01;
> enableFIQ();
> while (1);
> }
>
> void FIQ_Routine(void)
> {
> char temp;
> ReceivedByte =U1RBR;
> temp = U1IIR;
> VICVectAddr = 0;
> }
>
>
>


Try to compile with -O0 , winarm's gcc is a little bit buggy ':)

Miguel Ángel

On 11/04/2009, at 13:53, "J.C. Wren" wrote:

> There's some example code in the LPC2148 demo package at
> http://jcwren.com/arm
>
> On Fri, Apr 10, 2009 at 4:24 PM, dba008nz
> wrote:
>
> >
> >
> > I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm.
> Uart1
> > receives ASCII caharcters from a GPS at 19200 baud, and I am
> trying to get
> > the FIQ interrupt to run every time there is a data comming into
> Uart1, but
> > it does not work. I think the problem maybe to do with the FIQ
> vector
> > address, and I don't know how to point it to 0x0000001C from where
> the FIQ
> > jumps to. Any help would be gratefull. Cheers Doug.
> >
> > #include
> > #include
> > #include "LPC21xx.h"
> > #include "armVIC.h"
> >
> > char ReceivedByte = 0;
> > void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
> >
> > int main (void)
> > {
> > PINSEL0 = 0xCC051505;
> > PINSEL1 = 0x00400001;
> > IODIR0 |= 0x00000884;
> > IOSET0 = 0x00000080;
> > S0SPCR = 0x08;
> > S0SPCR = 0x30;
> >
> > // Uart1 setup, buad 19200 //
> > U1LCR = 0x83;
> > U1DLM = 0x00;
> > U1DLL = 0xC0;
> > U1FCR = 0x01;
> > U1LCR = 0x03;
> > VICIntSelect |= 0x00000080;
> > VICIntEnable |= 0x00000080;
> > VICVectCntl0 = 0x27;
> > VICVectAddr0 = (unsigned int)FIQ_Routine;
> > U1IER = 0x01;
> > enableFIQ();
> > while (1);
> > }
> >
> > void FIQ_Routine(void)
> > {
> > char temp;
> > ReceivedByte =U1RBR;
> > temp = U1IIR;
> > VICVectAddr = 0;
> > }
> >
> >
> >
>
>


How do I add this -O0? I'm using Programmers Notepad 2. I don't see how I can add options to the complier?

I still think my problem is to do with the way I have defined the FIQ vector address.

Cheers Doug.

--- In l..., Miguel Ángel wrote:
>
> Try to compile with -O0 , winarm's gcc is a little bit buggy ':)
>
> Miguel Ángel
>
> On 11/04/2009, at 13:53, "J.C. Wren" wrote:
>
> >
> >
> > There's some example code in the LPC2148 demo package at
> > http://jcwren.com/arm
> >
> > On Fri, Apr 10, 2009 at 4:24 PM, dba008nz
> > wrote:
> >
> > >
> > >
> > > I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm.
> > Uart1
> > > receives ASCII caharcters from a GPS at 19200 baud, and I am
> > trying to get
> > > the FIQ interrupt to run every time there is a data comming into
> > Uart1, but
> > > it does not work. I think the problem maybe to do with the FIQ
> > vector
> > > address, and I don't know how to point it to 0x0000001C from where
> > the FIQ
> > > jumps to. Any help would be gratefull. Cheers Doug.
> > >
> > > #include
> > > #include
> > > #include "LPC21xx.h"
> > > #include "armVIC.h"
> > >
> > > char ReceivedByte = 0;
> > > void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
> > >
> > > int main (void)
> > > {
> > > PINSEL0 = 0xCC051505;
> > > PINSEL1 = 0x00400001;
> > > IODIR0 |= 0x00000884;
> > > IOSET0 = 0x00000080;
> > > S0SPCR = 0x08;
> > > S0SPCR = 0x30;
> > >
> > > // Uart1 setup, buad 19200 //
> > > U1LCR = 0x83;
> > > U1DLM = 0x00;
> > > U1DLL = 0xC0;
> > > U1FCR = 0x01;
> > > U1LCR = 0x03;
> > > VICIntSelect |= 0x00000080;
> > > VICIntEnable |= 0x00000080;
> > > VICVectCntl0 = 0x27;
> > > VICVectAddr0 = (unsigned int)FIQ_Routine;
> > > U1IER = 0x01;
> > > enableFIQ();
> > > while (1);
> > > }
> > >
> > > void FIQ_Routine(void)
> > > {
> > > char temp;
> > > ReceivedByte =U1RBR;
> > > temp = U1IIR;
> > > VICVectAddr = 0;
> > > }
> > >
> > >
> > >
> >
> >
> >
> >
>
>
>
>

Thanks for the reply. I will go over your example again tomorrow, as I am struggling with trying to understand it tonight. Remember I am a newbie.

Cheers Doug.

--- In l..., "J.C. Wren" wrote:
>
> There's some example code in the LPC2148 demo package at
> http://jcwren.com/arm
>
> On Fri, Apr 10, 2009 at 4:24 PM, dba008nz wrote:
>
> >
> >
> > I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm. Uart1
> > receives ASCII caharcters from a GPS at 19200 baud, and I am trying to get
> > the FIQ interrupt to run every time there is a data comming into Uart1, but
> > it does not work. I think the problem maybe to do with the FIQ vector
> > address, and I don't know how to point it to 0x0000001C from where the FIQ
> > jumps to. Any help would be gratefull. Cheers Doug.
> >
> > #include
> > #include
> > #include "LPC21xx.h"
> > #include "armVIC.h"
> >
> > char ReceivedByte = 0;
> > void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
> >
> > int main (void)
> > {
> > PINSEL0 = 0xCC051505;
> > PINSEL1 = 0x00400001;
> > IODIR0 |= 0x00000884;
> > IOSET0 = 0x00000080;
> > S0SPCR = 0x08;
> > S0SPCR = 0x30;
> >
> > // Uart1 setup, buad 19200 //
> > U1LCR = 0x83;
> > U1DLM = 0x00;
> > U1DLL = 0xC0;
> > U1FCR = 0x01;
> > U1LCR = 0x03;
> > VICIntSelect |= 0x00000080;
> > VICIntEnable |= 0x00000080;
> > VICVectCntl0 = 0x27;
> > VICVectAddr0 = (unsigned int)FIQ_Routine;
> > U1IER = 0x01;
> > enableFIQ();
> > while (1);
> > }
> >
> > void FIQ_Routine(void)
> > {
> > char temp;
> > ReceivedByte =U1RBR;
> > temp = U1IIR;
> > VICVectAddr = 0;
> > }
> >
> >
> >
>
>

Its in the make file in a form off

CFLAGS = -I./ -O0 -c -fno-common -g -msoft-float -mcpu=arm7tdmi
CFLAGS += -Wa,-adhlns=$(subst $(suffix $<),.lst,$<)

main.o: main.c
@ echo ".compiling main.c"
$(CC) $(CFLAGS) main.c

Regards

Jean-Jacques

--- In l..., "dba008nz" wrote:
>
> How do I add this -O0? I'm using Programmers Notepad 2. I don't see how I can add options to the complier?
>
> I still think my problem is to do with the way I have defined the FIQ vector address.
>
> Cheers Doug.
>
>
>
> --- In l..., Miguel Ángel wrote:
> >
> > Try to compile with -O0 , winarm's gcc is a little bit buggy ':)
> >
> > Miguel Ángel
> >
> > On 11/04/2009, at 13:53, "J.C. Wren" wrote:
> >
> > >
> > >
> > > There's some example code in the LPC2148 demo package at
> > > http://jcwren.com/arm
> > >
> > > On Fri, Apr 10, 2009 at 4:24 PM, dba008nz
> > > wrote:
> > >
> > > >
> > > >
> > > > I'm trying to get FIQ interrupt to work on a LPC2148 using Winarm.
> > > Uart1
> > > > receives ASCII caharcters from a GPS at 19200 baud, and I am
> > > trying to get
> > > > the FIQ interrupt to run every time there is a data comming into
> > > Uart1, but
> > > > it does not work. I think the problem maybe to do with the FIQ
> > > vector
> > > > address, and I don't know how to point it to 0x0000001C from where
> > > the FIQ
> > > > jumps to. Any help would be gratefull. Cheers Doug.
> > > >
> > > > #include
> > > > #include
> > > > #include "LPC21xx.h"
> > > > #include "armVIC.h"
> > > >
> > > > char ReceivedByte = 0;
> > > > void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
> > > >
> > > > int main (void)
> > > > {
> > > > PINSEL0 = 0xCC051505;
> > > > PINSEL1 = 0x00400001;
> > > > IODIR0 |= 0x00000884;
> > > > IOSET0 = 0x00000080;
> > > > S0SPCR = 0x08;
> > > > S0SPCR = 0x30;
> > > >
> > > > // Uart1 setup, buad 19200 //
> > > > U1LCR = 0x83;
> > > > U1DLM = 0x00;
> > > > U1DLL = 0xC0;
> > > > U1FCR = 0x01;
> > > > U1LCR = 0x03;
> > > > VICIntSelect |= 0x00000080;
> > > > VICIntEnable |= 0x00000080;
> > > > VICVectCntl0 = 0x27;
> > > > VICVectAddr0 = (unsigned int)FIQ_Routine;
> > > > U1IER = 0x01;
> > > > enableFIQ();
> > > > while (1);
> > > > }
> > > >
> > > > void FIQ_Routine(void)
> > > > {
> > > > char temp;
> > > > ReceivedByte =U1RBR;
> > > > temp = U1IIR;
> > > > VICVectAddr = 0;
> > > > }
> > > >
> > > >
> > > >
> > >
> > >
> > >
> > >
> >
> >
> >
>

dba008nz wrote:

> VICVectCntl0 = 0x27;
> VICVectAddr0 = (unsigned int)FIQ_Routine;

You shouldn't use the VIC to vector FIQ. There is only one
FIQ vector, and it's hard wired in the vector block. Make
sure it's set up there and don't try to install FIQ vectors
in the VIC.

Most likely the FIQ vector isn't pointing to your FIQ service
routine. Look for a startup file named crt.s, startup.s, init.s,
or some such... it'll have the vectors. While going through
the startup code, give yourself some slack and make sure it
installs a 32 byte FIQ stack, or so.

Good luck!