Crossworks setting up interrupt problem (SOLVED)
Discussion in "ARM Development" started by KidE Feb 11, 2009.
Wed Feb 11 2009, 11:13 pm
Hi brothers in ARM(s)
I have some issues setting up interrupts under crossworks. I was plouging though the manuals but cant seem to find what i'm looking for.
After a while i got some code working good but i dont know if i did it correctly so that get into trouble later.
I'm pretty new in this so forgive me for this
The following code works fine after adding the ctl_global_interrupts_enable();
In the manuals i read i must use the following lines to setup a interrupt.
ctl_set_isr(7, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(7);
what is the value of this if its working ok without it?
in the ISR i need to:
Do i need to T0IR = 0x01; & VICVectAddr = 0; when i use ctl_global_interrupts_(un)_re_enable_from_isr();
I hope somebody can help me out.
Cheers,
Ernst
I have some issues setting up interrupts under crossworks. I was plouging though the manuals but cant seem to find what i'm looking for.
After a while i got some code working good but i dont know if i did it correctly so that get into trouble later.
I'm pretty new in this so forgive me for this
The following code works fine after adding the ctl_global_interrupts_enable();
#include "LPC214x.h" #include <ctl_api.h> #define PLOCK 0x400 void init(void); void delay_ms(int); void isr (void) __attribute__ ((interrupt("IRQ"))); volatile int servo; int main(void) { init(); PINSEL1 = 0x10000000; //p0.30 = AD0.3 IODIR0 = 0x00200000; //p0.21 = output AD0CR = 0x00210e08; //start burst A/D on AD0.3 T0TCR = 0x02; //reset counter T0IR = 0xff; T0MCR = 0x0003; //interrupt and reset on MR0 T0MR0 = 0x00124f80; //compare-hit count VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt: VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0 VICIntEnable = 0x00000010; //enable TIMER0 interrupt T0TCR = 0x01; //enable Timer0 ctl_global_interrupts_enable(); while(1){ servo = (((ADDR3 > > 6) & 0x000003ff) * 0x6e) + 0x39ff; } } void isr(void) { if(IOPIN0 & 0x00200000){ IOCLR0 = 0x00200000; T0MR0 = 0x00124f80 - servo; } else{ IOSET0 = 0x00200000; T0MR0 = servo; } T0IR = 0x01; //clear interrupt VICVectAddr = 0; //end of interrupt - dummy write }
In the manuals i read i must use the following lines to setup a interrupt.
ctl_set_isr(7, 0, CTL_ISR_TRIGGER_FIXED, isr, 0);
ctl_unmask_isr(7);
what is the value of this if its working ok without it?
in the ISR i need to:
void isr(void) { ctl_global_interrupts_re_enable_from_isr(); if(IOPIN0 & 0x00200000){ IOCLR0 = 0x00200000; T0MR0 = 0x00124f80 - servo; } else{ IOSET0 = 0x00200000; T0MR0 = servo; } ctl_global_interrupts_un_re_enable_from_isr(); // T0IR = 0x01; //clear interrupt // VICVectAddr = 0; //end of interrupt - dummy write }
Do i need to T0IR = 0x01; & VICVectAddr = 0; when i use ctl_global_interrupts_(un)_re_enable_from_isr();
I hope somebody can help me out.
Cheers,
Ernst
[ Edited Tue Feb 24 2009, 12:31 am ]
Thu Feb 12 2009, 02:29 am
ctl_set_isr(7, 0, CTL_ISR_TRIGGER_FIXED, isr, 0); ctl_unmask_isr(7);
the above line of code do the same thing as what you did in the following part of your code.
VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt: VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0 VICIntEnable = 0x00000010; //enable TIMER0 interrupt
and there is always a global masking bit to enable/disable interrupts globally. unless you enable the global interrupt all interrupts will remain disabled.
yes in ISR you need to clear the interrupt flags, to notify processor that interrupt has been serviced and processor can continue its task.
Fri Feb 13 2009, 12:29 am
If i look in the examples from Rowley's this is how it
should look i think.
Only downside..... its not working :mad
Reading the manual part of ctl_api this should be working.
In the startup file i've also enabled: VECTORED_IRQ_INTERRUPTS
What could this be?
#include <ctl_api.h> #define PLOCK 0x400 void init(void); void delay_ms(int); volatile int servo; int main(void) { init(); PINSEL1 = 0x10000000; //p0.30 = AD0.3 IODIR0 = 0x00200000; //p0.21 = output AD0CR = 0x00210e08; //start burst A/D on AD0.3 T0TCR = 0x02; //reset counter T0IR = 0xff; T0MCR = 0x0003; //interrupt and reset on MR0 T0MR0 = 0x00124f80; //compare-hit count // VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt: // VICVectAddr0 = (unsigned)isr; //set interrupt vector in 0 // VICIntEnable = 0x00000010; //enable TIMER0 interrupt T0TCR = 0x01; //enable Timer0 ctl_global_interrupts_enable(); while(1){ } } void isr(void) { // let burn some LED's T0IR = 0x01; //clear interrupt VICVectAddr = 0; //end of interrupt - dummy write } void init_isr(void) { ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0); ctl_unmask_isr( 1); }
Gr,
Ernst
Fri Feb 13 2009, 12:29 am
.Ok almost solved
The code is working now and interrupts are fired
Using crossworks in the ISR the following should be replaced by something else. Only what?
The code is working now and interrupts are fired
#include <ctl_api.h> #define PLOCK 0x400 void init(void); void delay_ms(int); volatile int servo; int main(void) { init(); init_isr(); PINSEL1 = 0x10000000; //p0.30 = AD0.3 IODIR0 = 0x00200000; //p0.21 = output AD0CR = 0x00210e08; //start burst A/D on AD0.3 T0TCR = 0x02; //reset counter T0IR = 0xff; T0MCR = 0x0003; //interrupt and reset on MR0 T0MR0 = 0x00124f80; //compare-hit count T0TCR = 0x01; //enable Timer0 ctl_global_interrupts_enable(); while(1){ } } void isr(void) { // let burn some LED's T0IR = 0x01; //clear interrupt VICVectAddr = 0; //end of interrupt - dummy write } void init_isr(void) { ctl_set_isr(1, 0, CTL_ISR_TRIGGER_FIXED, isr, 0); ctl_unmask_isr( 1); }
Using crossworks in the ISR the following should be replaced by something else. Only what?
T0IR = 0x01; //clear interrupt VICVectAddr = 0; //end of interrupt - dummy write
[ Edited Fri Feb 13 2009, 02:19 pm ]
Tue Feb 24 2009, 12:30 am
Ok somebody from lpc2000 group helped me good and my problem (at least teh IRQ thing) is solved now.
#include "LPC214x.h" #include <ctl_api.h> #define PLOCK 0x400 void init(void); void delay_ms(int); void isr_servo_out(void); volatile int servo; void init_isr(void) { ctl_global_interrupts_enable(); // interrupts enabled ctl_set_isr(4, 0, CTL_ISR_TRIGGER_FIXED, isr_servo_out, 0); //interrupt set ctl_unmask_isr( 4); //interrupt unmasked } void isr_servo_out(void) { IOSET0 = 0x00200000; // and there was light T0IR = 0x01; //clear interrupt } int main(void) { init(); init_isr(); PINSEL1 = 0x00002000; //p0.22 = capture 0.1 (timer0) IODIR0 = 0x00200C00; //p0.10, p0.11, p0.21 = GPIO output IOSET0 = 0x00000C00; // LED1+2 off T0TCR = 0x02; //reset counter T0IR = 0xff; T0CCR = 0x00000005; //capture on rising edge T0TCR = 0x00000001; //enable timer while(1){ } } void init(void) { PLLCFG=0x24; //set multiplier/divider values PLLFEED=0xaa; PLLFEED=0x55; PLLCON=0x01; //enable PLL PLLFEED=0xaa; PLLFEED=0x55; while(!(PLLSTAT & PLOCK)); //wait for the PLL to lock to set frequency PLLCON=0x3; //connect the PLL as the clock source PLLFEED=0xaa; PLLFEED=0x55; MAMCR=0x02; //enable MAM MAMTIM=0x04; //set number of clocks for flash memory fetch VPBDIV=0x01; //set peripheral clock(pclk) to system clock(cclk) }
Powered by e107 Forum System