Is it possible to generate different time delay using Timer?

Started by Saravanakumar S June 22, 2006
Hi,
I am using LPC 2106 for my application.

I am generating the time delay using Timer 0 MR1.
Is it possible to generate the different time delay using another channel.

Say Eg:
I want to generate 26 ms time delay in MR0, with out affecting
MR1 channel.

Please, Any body can tell me deatils.Are where I am wrong. I s there any
other way to do that.

Here withthis I enclosed, my sample program.

void main(void)
{
T0PR = 0x000005DB; //Load prescaler
T0TCR = 0x00000002; //Reset counter
and prescaler
T0MCR = 0x00000008; //On match reset the
counter and generate an interrupt
T0MR1 = 0x00002710; //Set the cycle
time for 1 Sec time delay
T0TCR = 0x00000001; //Enable timer
while(1)
{
while(T0IR != 0x02);
{
Task A( );
T0IR = 0x02; //Clear the interrupt
T0MR1 = 0x00002710;
T0TC = 0; // For Testing purpose, we
can configure the same settings in T0MCR also
}
}
}
Regards,
S.Kumar



An Engineer's Guide to the LPC2100 Series

--- In l..., "Saravanakumar S"
wrote:
>
> Hi,
> I am using LPC 2106 for my application.
>
> I am generating the time delay using Timer 0 MR1.
> Is it possible to generate the different time delay using another
channel.

Yes, U can generate upto 4 different time delays in one timer.

TOMR0
TOMR1
TOMR2
TOMR3

Whenever ur timer reaches the first value if u set the match
interrupt it will generate a math interrupt for TOMR0, when it
reches the value in T0MR1 it will generate another like that it goes
upto 4 different time delays.

>
> Say Eg:
> I want to generate 26 ms time delay in MR0, with out
affecting
> MR1 channel.
>
Don't Reset the timer.

> Please, Any body can tell me deatils.Are where I am wrong. I s
there any
> other way to do that.
>
> Here withthis I enclosed, my sample program.
>
> void main(void)
> {
> T0PR = 0x000005DB; //Load
prescaler
> T0TCR = 0x00000002; //Reset
counter
> and prescaler
> T0MCR = 0x00000008; //On match reset
the
> counter and generate an interrupt
> T0MR1 = 0x00002710; //Set the
cycle
> time for 1 Sec time delay
> T0TCR = 0x00000001; //Enable
timer
> while(1)
> {
> while(T0IR != 0x02);
> {
> Task A( );
> T0IR = 0x02; //Clear the
interrupt
> T0MR1 = 0x00002710;
> T0TC = 0; // For Testing
purpose, we
> can configure the same settings in T0MCR also
> }
> }
> }
I am in Haste so i am unable to gothrou ur program.
But it is so simple, Just read the data sheet of timer carefully and
proceed.

Only bits adjustment.

cheers,
Rajendra R

> Regards,
> S.Kumar
>
>
>

Hi Rajendra,
I generated the two different time delay using MR0 & MR1.
Once if it is generated,if we didnt reset the TCR,how can we generate the
interrupt for continuously.

Say Eg:
I loaded the value to generate 26 ms in MR0.
I loaded the value to generate 1sec in MR1.
I enabled the timer, I got 26 ms time delay in MR0.But i didnt get the
1sec time delay in MR1.I didnt the reset the TC.
During this time,i want to generate 26 ms time delay again, what I have to
do?

I don't know how to do? .If I reset the TC means, it will affect the MR1
interrupt

Can u please tell me how can I achieve this one?

--- In l..., "Saravanakumar S"
wrote:
>
> Hi,
> I am using LPC 2106 for my application.
>
> I am generating the time delay using Timer 0 MR1.
> Is it possible to generate the different time delay using another
channel.

Yes, U can generate upto 4 different time delays in one timer.

TOMR0
TOMR1
TOMR2
TOMR3

Whenever ur timer reaches the first value if u set the match
interrupt it will generate a math interrupt for TOMR0, when it
reches the value in T0MR1 it will generate another like that it goes
upto 4 different time delays.

>
> Say Eg:
> I want to generate 26 ms time delay in MR0, with out
affecting
> MR1 channel.
>
Don't Reset the timer.

> Please, Any body can tell me deatils.Are where I am wrong. I s
there any
> other way to do that.
>
> Here withthis I enclosed, my sample program.
>
> void main(void)
> {
> T0PR = 0x000005DB; //Load
prescaler
> T0TCR = 0x00000002; //Reset
counter
> and prescaler
> T0MCR = 0x00000008; //On match reset
the
> counter and generate an interrupt
> T0MR1 = 0x00002710; //Set the
cycle
> time for 1 Sec time delay
> T0TCR = 0x00000001; //Enable
timer
> while(1)
> {
> while(T0IR != 0x02);
> {
> Task A( );
> T0IR = 0x02; //Clear the
interrupt
> T0MR1 = 0x00002710;
> T0TC = 0; // For Testing
purpose, we
> can configure the same settings in T0MCR also
> }
> }
> }
I am in Haste so i am unable to gothrou ur program.
But it is so simple, Just read the data sheet of timer carefully and
proceed.

Only bits adjustment.

cheers,
Rajendra R

> Regards,
> S.Kumar
>
>
>