Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

two timer simultenously lpc2148

Status
Not open for further replies.

embpic

Advanced Member level 3
Advanced Member level 3
Joined
May 29, 2013
Messages
742
Helped
80
Reputation
160
Reaction score
77
Trophy points
1,308
Location
india
Visit site
Activity points
5,213
Hello master's
i am using lpc2148 and keil 4. i had done this two timer simultenously and works well but now i tried by configuring newly and copy pasted last also but this program not working.
in debug mode it works well but on dev. board it does not work.
here i have posted files.

- - - Updated - - -

if i do all this in single file then it works on dev. board then what should be the problem with seprate files.
 

Attachments

  • files.zip
    978 bytes · Views: 43

The problem is in the red lines, you overwrite the VICIntEnable register

Code:
void init_timer()
{	
	T0CTCR = 0x00;	
	T0TC   = 0x00000000;	
	T0MR0  = 0x00003b2f;	
	T0MCR  = 0x0003;
	T0TCR  = 0x01;
	VICIntSelect  = 0x00000000;
	[COLOR="#FF0000"]VICIntEnable  = 0x00000010;	[/COLOR]
	VICVectAddr0  = (unsigned long)isr_t0;
	VICVectCntl0  = (0x00000020)|4;
}

__irq void isr_t0(void)
{
	T0IR = 0x01;	
	IO1PIN ^= (1<<16);
	VICVectAddr = 0x00;		//acknowledging VIC controller...
}

void init_timer1()
{
	T1CTCR = 0x00;		
	T1TC   = 0x00000000;	
	T1MR0  = 0x00003b2f;	
	T1MCR  = 0x0003;
	T1TCR  = 0x01;
	VICIntSelect  = 0x00000000;
	[COLOR="#FF0000"]VICIntEnable  = 0x00000020;	[/COLOR]
	VICVectAddr1  = (unsigned long)isr_t1;
	VICVectCntl1  = (0x00000020)|5;	
}

__irq void isr_t1(void)
{
	T1IR = 0x01;			//clearing interrupt register...
	IO1PIN ^= (1<<19);
	VICVectAddr = 0x00;		//acknowledging VIC controller...
}
 

yes sir but i think this was not problem. problem was
Code:
	PINSEL0 = 0x00;
	PINSEL0 = 0x00;
	PINSEL0 = 0x00;

which should be as
Code:
      PINSEL0 = 0x00;
	PINSEL1 = 0x00;
	PINSEL2 = 0x00;

- - - Updated - - -

and it works.
 

VICIntEnable = 0x00000010; enables the timer0 interrupt and VICIntEnable = 0x00000020; enables JUST the timer1 interrupt and overwrites the timer0 interrupt bit.

Apparently this was not a problem for you because you didn't try to use the interrupts but it will become a problem as soon as you try to use them.
 

sir i am not getting bcoz i m using interrupt.
do i need ORing with this Reg. you shown.
is it like
Code:
VICIntEnable  |= 0x00000020;
??
 

Yes, you need to OR the values, VICIntEnable controls which of the 32 interrupt requests and software interrupts contribute to FIQ or IRQ so if you want to use more than one interrupts you either need to OR the bits or write the register one time with the value of the combined bits

For example for the two timer interrupts, either

Code:
VICIntEnable  = 0x00000010;  // assuming this doesn't overwrite a previous interrupt setting
VICIntEnable  |= 0x00000020;

/or

VICIntEnable  = 0x00000030;
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top