![]() | ![]() | ![]() |
| | #16 |
|
hey futz when you pause and check where the code is at can you check if the "T0IR" register instead of checking to see if it went to the location. Like check if the flag is even set at all. If its not then it doesnt have to do with the location on calling your function it would have to do with setting the timer right and interrupt.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #17 | |
| Quote:
Good thinking! I should have thought of that (but I didn't ). Just checked and the MR0 interrupt flag is set. So now I need to find out why that's not tripping the interrupt.EDIT: I put in a T0IR = 0xff; line to clear the flag right at init. Now the flag is clear and stays clear. I can see the timer counter changing and left it long enough to match MR0 many times. Flag still clear. Hmm... Oops, ran it some more and now the flag is set.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 17th January 2009 at 09:47 PM. | ||
| |
| | #18 |
|
I'm getting some unexpected results when debugging. Looks to me like both Timer0 and Timer1 are running on startup. The interrupt flag is set by the time my code inits things. I have to very carefully step thru things and see exactly what's going on and maybe mod the code to fix it. I don't know enough to say yet.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #19 |
|
can you try this: Code: #include "LPC214x.h"
#define PLOCK 0x400
void init(void);
void IRQ_Routine(void) __attribute__ ((interrupt ("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
int main(void)
{
int i;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00ffffff; //compare-hit count
T0TCR |= 0x01; //enable Timer0
T0TCR |= 0x02; //reset counter
VICVectAddr0 = (unsigned long)&IRQ_Routine; //set interrupt vector in 0
//or
//VICVectAddr0 = (unsigned long)IRQ_Routine; //set interrupt vector in 0
VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt
VICIntSelect = 0x00000000; //Configure for IRQ
VICIntEnable = 0x00000010; //enable TIMER0 interrupt
while(1);
}
void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
}
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)
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
SparkFun Electronics :: View topic - LPC2294 Uart interrupt problem
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 17th January 2009 at 10:19 PM. | |
| |
| | #20 |
| All you're changing is the VICIntSelect line, right? It shouldn't be necessary, as they're all set to IRQ on reset, but never hurts to be sure. ![]() I'll add it to my code rather than go through the misery of switching to yours and back. EDIT: Ran it. No change. The timer works right. The timer interrupt flag gets set. No interrupt occurs. Just so we're on the same page, here's my current code: Code: #include "LPC214x.h"
#define PLOCK 0x400
void init(void);
void IRQ_Routine (void) __attribute__ ((interrupt("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
int main(void)
{
int i;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0TCR = 0x02; //reset counter
T0IR = 0xff;
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x0000ffff; //compare-hit count
VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
VICIntSelect = 0;
VICVectAddr0 = (unsigned)IRQ_Routine; //set interrupt vector in 0
VICIntEnable = 0x00000010; //enable TIMER0 interrupt
T0TCR = 0x01; //enable Timer0
while(1){
i=0;
for(i=0;i<1000;i++);
i=1;
}
}
void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
}
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)
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 17th January 2009 at 10:23 PM. | |
| |
| | #21 |
|
yeah better safe then sorry ... also look at the "T0TCR |= 0x01;" i used |= to set it since it has reserved bits which are used internally i suppose . Using the OR will set only the bits you want and leave the rest unchanged.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #22 |
|
i cant wait to order this board from sparkfun. I have some weeks to wait still. but when i get it, i hope i get lost in it lol
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #23 |
| Ya, "lost in it". That's exactly how it is. They aren't as simple as PICs. Basic bit twiddling stuff is similar, but some things are pretty tough to figure out.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #24 |
| You're ok to write zeros to reserved bits. Just not ones.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #25 |
|
i just reread it futz and ur correct 1's are the evil for reserved ![]() im tired lol Ill try to read up on it some more. Good luck while i read the sheet.
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #26 |
|
I have to step out but modded the code as you know i cant test it so ... I was reading from the VIC start in the datasheet and this is how i would do it. Code: #include "LPC214x.h"
#define PLOCK 0x400
void init(void);
void IRQ_Routine(void) __attribute__ ((interrupt ("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
int main(void)
{
int i;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00ffffff; //compare-hit count
T0TCR |= 0x01; //enable Timer0
T0TCR |= 0x02; //reset counter
VICSoftInt = 0x00000010;
VICSoftIntClear = 0x00000010;
VICIntEnable = 0x00000010;
VICIntEnClear = 0x00000010;
VICIntSelect = 0xFFFFFFEF;
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned long)&IRQ_Routine;
while(1);
}
void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
}
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)
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics | |
| |
| | #27 | |
| Quote:
).
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | ||
| |
| | #28 |
|
If you want you can try this lol i know i change too much... Code: #include "LPC214x.h"
#define PLOCK 0x400
void init(void);
void IRQ_Routine(void) __attribute__ ((interrupt ("IRQ")));
void FIQ_Routine (void) __attribute__ ((interrupt("FIQ")));
void SWI_Routine (void) __attribute__ ((interrupt("SWI")));
void UNDEF_Routine (void) __attribute__ ((interrupt("UNDEF")));
int main(void)
{
int i;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00ffffff; //compare-hit count
T0TCR |= 0x01; //enable Timer0
T0TCR |= 0x02; //reset counter
VICSoftInt = 0x00000010;
VICIntEnable = 0x00000010;
VICIntSelect = 0x00000010;
VICVectCntl0 = 0x00000024;
VICVectAddr0 = (unsigned long)&IRQ_Routine;
VICDefVectAddr = (unsigned long)&IRQ_Routine;
while(1);
}
void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr0 = 0; //end of interrupt - dummy write
}
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)
}
void FIQ_Routine(void){
while (1) ;
}
void SWI_Routine(void){
while (1) ;
}
void UNDEF_Routine(void) {
while (1) ;
}
CHECK this out: ARM Information Center in PDF its: http://infocenter.arm.com/help/topic...1e/DDI0181.pdf Ive seen your post on sparkfun also lol when i was searching google to find some info.I cant wait to get me one of these it looks like lots of things you can set and do . I love the interrupts. Its awesome.... even if we cant get them to work yet ! lol. Ill see if i order one tomorrow... if i order one will you help me setup? I might make: VS Electronics and Embedded Development JTAG Wiggler Clone or should i buy the USB Tiny?
__________________ AtomSofts eBay Store AtomSoftTech: C18 TIPS & TRICKS v9 PDF Nokia 6100 Driver/Software My Name: Jason Lopez http://atomsofttech.info/ | My YouTube Videos! My Favorite Store: dipmicro Electronics Last edited by AtomSoft; 18th January 2009 at 02:24 AM. | |
| |
| | #29 |
| Won't work. Not gonna try it. You need to jump thru some stupid code hoops to enable interrupts. No amount of messing with my original code will change that. I have the additional code needed already, but haven't got it working yet. I quit for the night anyway.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #30 | ||
| Quote:
Ya, sure. ![]() Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |||
| |
|
| Tags |
| interrupts, lpc2148, match, timer, work |
| Thread Tools | |
| Display Modes | |
| |
Similar | ||||
| Title | Starter | Forum | Replies | Latest |
| LPC2148 async serial baud rate confusion | futz | Micro Controllers | 23 | 30th December 2008 03:48 PM |
| Best way for homemade E-Match | SMUGangsta | Chit-Chat | 8 | 2nd November 2008 09:43 PM |
| Two circuits ground do not match | xtcx | Electronic Projects Design/Ideas/Reviews | 3 | 24th December 2007 09:03 AM |
| I don't know why my Periodic ON-OFF Timer don't work. They are two CD4541. | taotoon | Electronic Projects Design/Ideas/Reviews | 7 | 29th October 2007 03:10 AM |
| Need Help in Timer Interrupts, CCS C and PIC16F628A | mysemcon2000 | Micro Controllers | 0 | 4th November 2006 02:12 PM |