EmbeddedRelated.com
Forums

Min. Requirements for VIC in Crossworks w/2478

Started by Kevin Townsend June 20, 2009
> Well, there is something special that needs to happen in the timer interrupt in addition to the usual reschedule after an interrupt that can change thread state - the OS has to increment its tick timer and timeout waits and sleeps. Somewhere in your timer initialization, something should set up a call to something like 'ctl_increment_tick_from_isr()', perhaps by loading this function into a static so that it can be later called from the timer interrupt handler.
>
> Are you doing this OK?

Martin:

Thanks for the reply. I don't suppose you have any examples, since I'm not really clear on exactly what I should be modifying? I'm not actually using any of the tasking functionality (which would obviously require a 'tick' interrupt) or the timer methods built into the CTL (I prefer to use standard GCC code as much as possible). For the moment, I am simply writing something where the only code present is the Timer initialisation and ISR just to make sure it is all working well before adding in FreeRTOS. But I plan to use the same code to handle USB and Serial interrupts as well, which is why I wasn't using the CTL Timer code.

Even without this, though, you think I need to configure or increment the interrupt 'tick' counter?

Kevin

An Engineer's Guide to the LPC2100 Series

Tim:

Thanks for the code. I made a few changes, such as only starting the timer after running the CTL methods, but still no luck. It goes into the ISR at the appropriate moment (after a 1s delay), but once it's in there is just keeps endlessly going back with no delay at all. I went back and looked at some 2148 code I had working, and pretty much the same ISR and timer configuration works properly and will flash an LED on and off every second. I'm really stumped on this, though, since (to my flawed eyes) the Timer initialisation looks OK, as well as the ISR. Perhaps there is something I'm not aware of with the new vectored interrupt handler in the 2378/2478?

Kevin.

// Configure Timer1
SCB_PCONP |= SCB_PCONP_PCTIM1; // Add power to Timer 1
T1_TCR = T_TCR_CR; // Reset timer
T1_PR = 0; // Set prescalar to 0
T1_IR = T_IR_MR1; // Reset all interrupt flags
T1_MR1 = 60000000 / 4; // Set timer match register (0.25 sec)
T1_MCR = T_MCR_MR1R | T_MCR_MR1I; // Raise an interrupt and reset on match/MR1
ctl_set_isr( // Set interrupt using CTL (vector, priority, trigger, isr, oldisr)
VIC_Channel_Timer1,
2,
CTL_ISR_TRIGGER_FIXED,
timer1_isr,
0);
ctl_unmask_isr(VIC_Channel_Timer1); // Unmas interrupt using CTL
T1_TCR = T_TCR_CE; // Enable Timer1 interrupt

// Enable interrupts using Crossworks CTL
ctl_global_interrupts_enable();

....

// Handle TIMER1 interrupt
void timer1_isr(void)
{
int setBreakpoint = 0;

T1_IR = T_IR_MR1; // Clear timer interrupt
VIC_Address = 0; // Signal end of interrupt
}

----Original Message----
From: l...
[mailto:l...] On Behalf Of Kevin
Townsend Sent: 22 June 2009 10:42 To:
l... Subject: [lpc2000] Re: Min.
Requirements for VIC in Crossworks w/2478

> Tim:
>
> Thanks for the code. I made a few changes, such as only
> starting the timer after running the CTL methods, but
> still no luck. It goes into the ISR at the appropriate
> moment (after a 1s delay), but once it's in there is just
> keeps endlessly going back with no delay at all. I went
> back and looked at some 2148 code I had working, and
> pretty much the same ISR and timer configuration works
> properly and will flash an LED on and off every second.
> I'm really stumped on this, though, since (to my flawed
> eyes) the Timer initialisation looks OK, as well as the
> ISR. Perhaps there is something I'm not aware of with
> the new vectored interrupt handler in the 2378/2478?
>

Mine is running on 2478, so I don't think so.
You don't need to access the VIC at all when using CTL for interrupts,
so you don't need the VIC_Address=0 line.
Have you tried doing T1_IR=0xFF to reset all the int flags together? Cos
it sounds like an interrupt flag is remaining set.

--
Tim Mitchell

Kevin,

> > Well, there is something special that needs to happen in the timer
> interrupt in addition to the usual reschedule after an interrupt that can
> change thread state - the OS has to increment its tick timer and timeout
> waits and sleeps. Somewhere in your timer initialization, something
should
> set up a call to something like 'ctl_increment_tick_from_isr()', perhaps
by
> loading this function into a static so that it can be later called from
the
> timer interrupt handler.
> >
> > Are you doing this OK?
>
> Martin:
>
> Thanks for the reply. I don't suppose you have any examples, since I'm
not
> really clear on exactly what I should be modifying? I'm not actually
using
> any of the tasking functionality (which would obviously require a 'tick'
> interrupt) or the timer methods built into the CTL (I prefer to use
> standard GCC code as much as possible). For the moment, I am simply
> writing something where the only code present is the Timer initialisation
> and ISR just to make sure it is all working well before adding in
FreeRTOS.
> But I plan to use the same code to handle USB and Serial interrupts as
> well, which is why I wasn't using the CTL Timer code.

Please, help yourself... :-( Look at the examples we ship.

In V1 and V2:

Install the LPC2000 CPU support package and the EA LPC2468 package (2478
isn't so different).

Click Tools > Show Installed Packages.
Click EA 2468 OEM package.
Click LPC2468 OEM Samples Solution

Take a look at the timer_interrupt project.

--
Paul Curtis, Rowley Associates Ltd http://www.rowley.co.uk
CrossWorks V2 is out for LPC1700, LPC3100, LPC3200, SAM9, and more!

Hi Kevin,

You can remove the

VIC_Address = 0;

from the interrupt handler - the irq_handler will do this. The source code to ctl_set_isr and irq_handler is in the system files folder of the project.

Regards
Michael

>
> Tim:
>
> Thanks for the code. I made a few changes, such as only starting the timer after running the CTL methods, but still no luck. It goes into the ISR at the appropriate moment (after a 1s delay), but once it's in there is just keeps endlessly going back with no delay at all. I went back and looked at some 2148 code I had working, and pretty much the same ISR and timer configuration works properly and will flash an LED on and off every second. I'm really stumped on this, though, since (to my flawed eyes) the Timer initialisation looks OK, as well as the ISR. Perhaps there is something I'm not aware of with the new vectored interrupt handler in the 2378/2478?
>
> Kevin.
>
> // Configure Timer1
> SCB_PCONP |= SCB_PCONP_PCTIM1; // Add power to Timer 1
> T1_TCR = T_TCR_CR; // Reset timer
> T1_PR = 0; // Set prescalar to 0
> T1_IR = T_IR_MR1; // Reset all interrupt flags
> T1_MR1 = 60000000 / 4; // Set timer match register (0.25 sec)
> T1_MCR = T_MCR_MR1R | T_MCR_MR1I; // Raise an interrupt and reset on match/MR1
> ctl_set_isr( // Set interrupt using CTL (vector, priority, trigger, isr, oldisr)
> VIC_Channel_Timer1,
> 2,
> CTL_ISR_TRIGGER_FIXED,
> timer1_isr,
> 0);
> ctl_unmask_isr(VIC_Channel_Timer1); // Unmas interrupt using CTL
> T1_TCR = T_TCR_CE; // Enable Timer1 interrupt
>
> // Enable interrupts using Crossworks CTL
> ctl_global_interrupts_enable();
>
> ....
>
> // Handle TIMER1 interrupt
> void timer1_isr(void)
> {
> int setBreakpoint = 0;
>
> T1_IR = T_IR_MR1; // Clear timer interrupt
> VIC_Address = 0; // Signal end of interrupt
> }
>