![]() | ![]() | ![]() |
| | #46 |
|
how about reseting the counter after the ISR like: EDIT: Code: void IRQ_Routine(void)
{
int i;
IOSET0 = 0x30600000; //4 LEDs blink
for(i=0;i<0x0000ffff;i++);
IOCLR0 = 0x30600000;
T0IR = 0x01; //clear interrupt
VICVectAddr = 0x0000; //end of interrupt - dummy write
T0TCR = 0x02;
T0TCR = 0x01; //Added this
}
__________________ 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; 19th January 2009 at 08:27 PM. | |
| |
| | #47 |
| Shouldn't be necessary. It'll wrap around. I don't care how long it takes at this point. And I have strange things happening. The debugger IS running it. What's happening now (I changed nothing (that I know of) to cause this) is when it gets into enable(IRQ) the program restarts every time and hits my debugger breakpoint at the start of main(). This makes it look like the program just isn't running. But when I single step I can see what's actually happening. Acts like the watchdog is running or something. It isn't. Or at least I didn't enable it. Should be disabled by default on this chip. Oh man! This is messin with my mind!
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 19th January 2009 at 09:17 PM. | |
| |
| | #48 |
|
Got it working finally. The LEDs are blippin away right now. Jason, remember when you suggested I change the "VICVectAddr0" in the ISR to "VICVectAddr". Well, I did that, and without consulting the User Manual, thought, "Hey! There's another one of those here at the line "VICVectAddr0 = (unsigned)IRQ_Routine;". So I changed that one too. BIG MISTAKE! There are 17 VICVectAddr registers. The one with no number suffix is the one you use to do a dummy write at the end of your ISR. The others are used to set the 16 IRQ vector addresses. So by removing the 0 suffix I ended up with no vector address for my ISR. When the interrupt hit it jumped to some random address, buzzed through empty memory, wrapped around and restarted the program. What fun!!! ![]() So, the working code is: Code: #include "LPC214x.h"
#define PLOCK 0x400
#define IRQ_MASK 0x00000080
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")));
unsigned enableIRQ(void);
unsigned disableIRQ(void);
unsigned restoreIRQ(unsigned oldCPSR);
int main(void)
{
int i;
unsigned cp;
IODIR0 = 0x30600000;
IOCLR0 = 0x30600000; //LEDs off
init();
T0TCR = 0x02; //reset counter
T0IR = 0xff;
T0MCR = 0x0003; //interrupt and reset on MR0
T0MR0 = 0x00ffffff; //compare-hit count
VICVectCntl0 = 0x00000024; //use it for Timer 0 Interrupt:
VICVectAddr0 = (unsigned)IRQ_Routine; //set interrupt vector in 0
VICIntEnable = 0x00000010; //enable TIMER0 interrupt
T0TCR = 0x01; //enable Timer0
cp = enableIRQ();
while(1){
i=0;
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
VICVectAddr = 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) ;
}
static inline unsigned asm_get_cpsr(void)
{
unsigned long retval;
asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ );
return retval;
}
static inline void asm_set_cpsr(unsigned val)
{
asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) );
}
unsigned enableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr & ~IRQ_MASK);
return _cpsr;
}
unsigned disableIRQ(void)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr(_cpsr | IRQ_MASK);
return _cpsr;
}
unsigned restoreIRQ(unsigned oldCPSR)
{
unsigned _cpsr;
_cpsr = asm_get_cpsr();
asm_set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK));
return _cpsr;
}
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 20th January 2009 at 03:57 PM. | |
| |
| | #49 |
|
Awsome!!! futz i dont want to hassle you but can i get a copy of the code and startup please? So when i get mine i can study it also. Code: VICVectAddr0 = (unsigned)IRQ_Routine; Code: VICVectAddr0 = (unsigned)&IRQ_Routine;
__________________ 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 | |
| |
| | #50 |
|
Since you can use many IRQ routines think about naming it like T0IRQ_Routine
__________________ 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; 19th January 2009 at 10:15 PM. | |
| |
| | #51 | |||
| Quote:
Quote:
Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | ||||
| |
| | #52 |
|
heh im not telling you what "VICVectAddr0" is just stating that i also know lol. Yeah im thinking about using "Eclipse/yagarto/OpenOCD" but might look into Crossworks or even RealView MDK which i think uses uVision or something. But my main plan is the Trio("Eclipse/yagarto/OpenOCD") or Crossworks. Im thinking Crossworks tho. Mainly because it looks like it will be easier to setup and more popular. The thing i dont understand is. Can i cross compile? Like use code made using yaharto with crossworks? Are they compatible? Or will there be many differences? Which are you sticking with?
__________________ 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 | |
| |
| | #53 | |
| Quote:
As much as I dislike using that flaky debugger in Eclipse/yagarto/OpenOCD, I'm sticking with it. It works. You just have to learn its many quirks and bugs and how to work around them. It's flaky as hell, but you can get things done with it. The Crossworks debugger, in comparison, is beautifully polished and so sweet to use. I figure if I'm going to be using GCC either way, I learn a LOT more by using the open-source tools than I do with a polished package like Crossworks. Yes it's painful and takes a lot of time to figure it all out, but at the end I know a lot more than I would if I had used only Crossworks. They hide all this complexity from you unless you need to look at it. So you're going to have the pain sometime. Now, if you use Eclipse/yagarto, or later if you use Crossworks.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= Last edited by futz; 19th January 2009 at 11:06 PM. | ||
| |
| | #54 |
|
ok i think i understand it a bit more. Yeah i would also agree that using open source tools gives one an advantage when learning because you have more options to setup. Hence learning more about the whole package. Dude when ever you want or can maybe you can write a little "how-to" to get me started on this ARM stuff. Maybe place it on your site as a article this way others can gain from this info.
__________________ 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 | |
| |
| | #55 |
|
Thought you would find this interesting: LPC2148 PROTOTYPE DEVELOPMENT BOARD
__________________ 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 | |
| |
| | #56 | |
| Quote:
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | ||
| |
| | #57 |
|
I was referring to the software at the bottom but i just remembered you said yours came with a cd i assume thats on it already then.
__________________ 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 | |
| |
| | #58 |
| Yes it is.
__________________ ========================= Futz's Microcontrollers & Robotics ========================= | |
| |
| | #59 |
|
im going to go see if i can gather info on setting up all 3 tools. I have all 3 installed and just need to understand how to integrate them together. I was reading some on your site but got lost really
__________________ 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 | |
| |
| | #60 |
|
Lets play name that quote! Guys, Olympus would be THAT way! Sorry I missed this, it is so much easier to spot when you are standing over someone discussing it. See page 59 of: http://www.standardics.nxp.com/suppo...46.lpc2148.pdf What we have here is a case of the timer vector register would be that way: VICVectAddr4 for T1 or VICVectAddr5 for T2, VICVectAddr0 is the WDT. Dan Last edited by Ubergeek63; 20th January 2009 at 11:33 AM. | |
| |
|
| 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 |