Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Tools
Old 17th January 2009, 09:22 PM   #16
Default

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.
AtomSoft is offline  
Old 17th January 2009, 09:41 PM   #17
Default

Quote:
Originally Posted by AtomSoft View Post
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.
Well duh! 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.
futz is offline  
Old 17th January 2009, 09:55 PM   #18
Default

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
=========================
futz is offline  
Old 17th January 2009, 10:11 PM   #19
Default

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) ;
}
if anything i hope this can help:
SparkFun Electronics :: View topic - LPC2294 Uart interrupt problem

Last edited by AtomSoft; 17th January 2009 at 10:19 PM.
AtomSoft is offline  
Old 17th January 2009, 10:20 PM   #20
Default

Quote:
Originally Posted by AtomSoft View Post
can you try this:
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.
futz is offline  
Old 17th January 2009, 10:22 PM   #21
Default

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.
AtomSoft is offline  
Old 17th January 2009, 10:23 PM   #22
Default

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
AtomSoft is offline  
Old 17th January 2009, 10:30 PM   #23
Default

Quote:
Originally Posted by AtomSoft View Post
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
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
=========================
futz is offline  
Old 17th January 2009, 10:32 PM   #24
Default

Quote:
Originally Posted by AtomSoft View Post
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.
You're ok to write zeros to reserved bits. Just not ones.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 17th January 2009, 11:02 PM   #25
Default

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.
AtomSoft is offline  
Old 18th January 2009, 12:07 AM   #26
Default

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) ;
}
AtomSoft is offline  
Old 18th January 2009, 12:21 AM   #27
Default

Quote:
Originally Posted by AtomSoft View Post
I have to step out but modded the code as you know i cant test it so ...
I've been on a thread over at Sparkfun and I think I have the problem almost sorted. Near the bottom Manton comes along and clears up a few things (or maybe opens a whole new can of worms ).
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Old 18th January 2009, 02:15 AM   #28
Default

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?

Last edited by AtomSoft; 18th January 2009 at 02:24 AM.
AtomSoft is offline  
Old 18th January 2009, 02:22 AM   #29
Default

Quote:
Originally Posted by AtomSoft View Post
If you want you can try this lol i know i change too much...
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
=========================
futz is offline  
Old 18th January 2009, 02:41 AM   #30
Default

Quote:
Originally Posted by AtomSoft View Post
I'll see if i order one tomorrow... if i order one will you help me setup?
Hell no! Are you kidding? Ya, sure.

Quote:
I might make:
VS Electronics and Embedded Development JTAG Wiggler Clone

or should i buy the USB Tiny?
Does your computer have a parallel port? None of my newer boxes does. Definitely not my programming/mcu box. Has to be USB.
__________________
=========================
Futz's Microcontrollers & Robotics
=========================
futz is offline  
Reply

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



All times are GMT. The time now is 06:08 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker