EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

VIC on the LPC2478

Started by "jim.deas" August 21, 2009
Can someone give me a hand with the VIC on this chip? I want to attach a GPIO to trigger an interrupt just to get the feel of the chip.
I init' the chips like this.
'---------------------
//Set a mask for the two buttons on the development card
PINSEL5 = 0x00;//Set P2[16]-P1[31] to GPIO
PINMODE5 = 0x00;//Set pull up resistor enabled
FIO2MASK = ~(BUT1_MASK | BUT2_MASK);

//Install a Vector interrupt on Ext3 (shared with GPIO interrupts)
VICSoftIntClr=0xffffffff; //Clear any software interrupts
IO2_INT_EN_F = BUT1_MASK;//Allow Button 1 falling edge
VICVectPri17 = 0x0000000F; //Select Lowest Priority
VICVectAddr17 = (unsigned)IntVectoredIRQExt3; //The INT routine
VICIntEnClr = 0xffffffff; //Clear all interrupts
VICIntEnable = 0x000020000; //Enable EXT3 interrupts
VICIntSelect = 0x00;//No FIRQ's
'---------------------
I can see IO2_INT_STAT_F change when I press the button but the system never vectors to the routine.

An Engineer's Guide to the LPC2100 Series

Which chip are you using? On ARM7, you would not have 17 vector slots.
But if your chip has 17 slots, and you want to associate channel 17 (EINT3),
then you need to add one more expression
VICVectCntl17 = 0x31;
which will invoke your VIC when the interrupt occurs
Also, you need to enable the interrupt pin using PINSEL.
Hope this helps
Regards,
Prerak
On Sat, Aug 22, 2009 at 4:59 AM, jim.deas wrote:

> Can someone give me a hand with the VIC on this chip? I want to attach a
> GPIO to trigger an interrupt just to get the feel of the chip.
> I init' the chips like this.
> '---------------------
> //Set a mask for the two buttons on the development card
> PINSEL5 = 0x00;//Set P2[16]-P1[31] to GPIO
> PINMODE5 = 0x00;//Set pull up resistor enabled
> FIO2MASK = ~(BUT1_MASK | BUT2_MASK);
>
> //Install a Vector interrupt on Ext3 (shared with GPIO interrupts)
> VICSoftIntClr=0xffffffff; //Clear any software interrupts
> IO2_INT_EN_F = BUT1_MASK;//Allow Button 1 falling edge
> VICVectPri17 = 0x0000000F; //Select Lowest Priority
> VICVectAddr17 = (unsigned)IntVectoredIRQExt3; //The INT routine
> VICIntEnClr = 0xffffffff; //Clear all interrupts
> VICIntEnable = 0x000020000; //Enable EXT3 interrupts
> VICIntSelect = 0x00;//No FIRQ's
> '---------------------
> I can see IO2_INT_STAT_F change when I press the button but the system
> never vectors to the routine.
>
>
>


--- In l..., "jim.deas" wrote:
>
> Can someone give me a hand with the VIC on this chip? I want to attach a GPIO to trigger an interrupt just to get the feel of the chip.
> I init' the chips like this.
> '---------------------
> //Set a mask for the two buttons on the development card
> PINSEL5 = 0x00;//Set P2[16]-P1[31] to GPIO
> PINMODE5 = 0x00;//Set pull up resistor enabled
> FIO2MASK = ~(BUT1_MASK | BUT2_MASK);
>
> //Install a Vector interrupt on Ext3 (shared with GPIO interrupts)
> VICSoftIntClr=0xffffffff; //Clear any software interrupts
> IO2_INT_EN_F = BUT1_MASK;//Allow Button 1 falling edge
> VICVectPri17 = 0x0000000F; //Select Lowest Priority
> VICVectAddr17 = (unsigned)IntVectoredIRQExt3; //The INT routine
> VICIntEnClr = 0xffffffff; //Clear all interrupts
> VICIntEnable = 0x000020000; //Enable EXT3 interrupts
> VICIntSelect = 0x00;//No FIRQ's
> '---------------------
> I can see IO2_INT_STAT_F change when I press the button but the system never vectors to the routine.
>
Hello Jim,

To use a pin for IRQ, you must set the pin as EINT in your PINSEL statement. Then you would usually set the mode and polarity registers EXTMODE and EXTPOL (unless you're ok with the default.)

I've been meaning to experiment with what happens when I read the FIOPIN register for a pin configured as EINT. The docs kinda sorta _seem_ to suggest that the reading will be valid...

disclaimer: I'm not actually familiar with the 2478. I'm going by how the 2418 behaves. The VIC controllers are not the same; the 2418 has only 16 vector channels and lacks the VICVectPriXX registers. So there is remote possibility that the PINSEL requirement does not apply.

-Hugh
--- In l..., "hsutherland2@..." wrote:
>
> --- In l..., "jim.deas" wrote:
> >
> > Can someone give me a hand with the VIC on this chip? I want to attach a GPIO to trigger an interrupt just to get the feel of the chip.

On the smaller chips (eg LPC2148) you must enable interrupts for the chip itself. Regardless of how well you set up the VIC, if the core isn't set to accept interrupts, nothing will happen.

In the startup code, just before the branch to main, there is a line like:

MSR CPSR_c,#MODE_SVC /* enable interrupts */

This enables interrupts in the supervisor mode and leaves the device in supervisor mode.

Previous in the code, the supervisor stack had been set with something like:

msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
mov sp, r0
sub r0, r0, #SVC_STACK_SIZE

Setting the I & F bits has the effect of disabling interrupts in that mode.

Richard

--- In l..., "rtstofer" wrote:
>
> --- In l..., "hsutherland2@" wrote:
> >
> > --- In l..., "jim.deas" wrote:
> > >
> > > Can someone give me a hand with the VIC on this chip? I want to attach a GPIO to trigger an interrupt just to get the feel of the chip.
>
> On the smaller chips (eg LPC2148) you must enable interrupts for the chip itself. Regardless of how well you set up the VIC, if the core isn't set to accept interrupts, nothing will happen.
>
> In the startup code, just before the branch to main, there is a line like:
>
> MSR CPSR_c,#MODE_SVC /* enable interrupts */
>
> This enables interrupts in the supervisor mode and leaves the device in supervisor mode.
>
> Previous in the code, the supervisor stack had been set with something like:
>
> msr CPSR_c, #MODE_SVC|I_BIT|F_BIT /* Supervisor Mode */
> mov sp, r0
> sub r0, r0, #SVC_STACK_SIZE
>
> Setting the I & F bits has the effect of disabling interrupts in that mode.
>
> Richard
>

Thanks guys, I will try these out tomorrow :)

--- In l..., "hsutherland2@..."
> disclaimer: ... remote possibility that ...

OK (after the post) I got curious enough to browse through the 2478 manual. Apologies for the misinformation and the wasted bandwidth.

Bah! And I (thought I) was so happy with my shiny new 2148 devboard. Now I'll be gnashing my teeth every time I have to choose between GPIO and interrupt capability.


The 2024 Embedded Online Conference