EmbeddedRelated.com
Forums

LPC2378 timer0

Started by sukh...@yahoo.co.in June 24, 2009
I am running LPC2378 at 72Mhz. now i want to generate 4.8Mhz clock using timer0. how can i do this.
as timer0
T0MR0=0x2;
T0MCR=2;
T0EMR=1|3<<4;
T0TCR=1;
it will generate a clock of 12Mhz.

but i am not able to 4.8 Mhz which require 15 clock cycle. how is it possible?
second thing, i am not able to understand what is purpose of

Clear the corresponding External Match bit/output to 0 (MATn.m pin is
LOW if pinned out).

as this clears the corresponding bit on timer reaches the match register value. but it is not able to be set again after timer starts again.how can i set the output pin high again. because this makes the output pin low permanently.

is 4.8 Mhz clock generation is possible using Clear the corresponding External Match bit/output to 0.

kindly help me.
thanks.

Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com



An Engineer's Guide to the LPC2100 Series

--- In l..., sukhdeepmanku@... wrote:
>
> I am running LPC2378 at 72Mhz. now i want to generate 4.8Mhz clock using timer0. how can i do this.
> as timer0
> T0MR0=0x2;
> T0MCR=2;
> T0EMR=1|3<<4;
> T0TCR=1;
> it will generate a clock of 12Mhz.
>
> but i am not able to 4.8 Mhz which require 15 clock cycle. how is it possible?

With the 2378 it is possible to set a prescaler for the timer of you choice, using the TxPR register.
In my case I needed a 1 ms timer, so I used the following settings to downscale the timer to 1 Mhz.

PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);

T0TCR = 2; /* Stop and reset the timer */
T0CTCR = 0; /* Timer mode */
T0PR = 72; /* Prescaler */
T0MR1 = 250000; /* Match value every 250 ms.. */
T0MCR = (3 << 3); /* Reset timer on match and generate interrupt */

Hope this will help.

>Clear the corresponding External Match bit/output to 0 (MATn.m pin is
>LOW if pinned out).
It is not quite clear to me what you mean by this.. can you formulate your question a bit more specific?
It is possible to toggle certain MATn.m pins (Match pins) if a selected timer reaches the value that is stored in the match register. However as far a I know, this is just a optional feature, it will only work if it is enabled.

first of all thanks for reply.

second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer. can u send me its routine.

one more thing, i am not able to use Clear the corresponding External Match bit/output to 0 (MATn.m pin is

>LOW if pinned out).
can i use this to generate frequency. if yes, then how?

--- On Wed, 24/6/09, neliz_x wrote:

From: neliz_x
Subject: [lpc2000] Re: LPC2378 timer0
To: l...
Date: Wednesday, 24 June, 2009, 12:36 AM

--- In lpc2000@yahoogroups .com, sukhdeepmanku@ ... wrote:

>

> I am running LPC2378 at 72Mhz. now i want to generate 4.8Mhz clock using timer0. how can i do this.

> as timer0

> T0MR0=0x2;

> T0MCR=2;

> T0EMR=1|3<<4;

> T0TCR=1;

> it will generate a clock of 12Mhz.

>

> but i am not able to 4.8 Mhz which require 15 clock cycle. how is it possible?

With the 2378 it is possible to set a prescaler for the timer of you choice, using the TxPR register.

In my case I needed a 1 ms timer, so I used the following settings to downscale the timer to 1 Mhz.

PCLKSEL0 = (PCLKSEL0 & (~(0x3<<2))) | (0x01 << 2);

T0TCR = 2; /* Stop and reset the timer */

T0CTCR = 0; /* Timer mode */

T0PR = 72; /* Prescaler */

T0MR1 = 250000; /* Match value every 250 ms.. */

T0MCR = (3 << 3); /* Reset timer on match and generate interrupt */

Hope this will help.

>Clear the corresponding External Match bit/output to 0 (MATn.m pin is

>LOW if pinned out).

It is not quite clear to me what you mean by this.. can you formulate your question a bit more specific?

It is possible to toggle certain MATn.m pins (Match pins) if a selected timer reaches the value that is stored in the match register. However as far a I know, this is just a optional feature, it will only work if it is enabled.

Love Cricket? Check out live scores, photos, video highlights and more. Click here http://cricket.yahoo.com



sukhdeep singh wrote:
> second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer.
> can u send me its routine.
>
> one more thing, i am not able to use Clear the corresponding External
> Match bit/output to 0 (MATn.m pin is
>
> >LOW if pinned out).
> can i use this to generate frequency. if yes, then how?

So, what was wrong with the neliz_x's ideas? How did you try them? What
did happen?

--

Timo

it's neliz_x's example working fine. there is no problem. but want to generate frequency using Clear the corresponding External

> Match bit/output to 0 (MATn.m pin is

> >LOW if pinned out).

i am failed to generate, output value is not set on timer overflow. how can i set output value after comparsion match occur to generate frequency.

kindly help me.
Thanks to all of u for ur replies.

--- On Wed, 24/6/09, t...@gmail.com wrote:

From: t...@gmail.com
Subject: [lpc2000] Re: LPC2378 timer0
To: l...
Date: Wednesday, 24 June, 2009, 2:52 AM

sukhdeep singh wrote:

> second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer..

> can u send me its routine.

>

> one more thing, i am not able to use Clear the corresponding External

> Match bit/output to 0 (MATn.m pin is

>

> >LOW if pinned out).

> can i use this to generate frequency. if yes, then how?

So, what was wrong with the neliz_x's ideas? How did you try them? What

did happen?

--

Timo

ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com



sukhdeep singh wrote:
> it's neliz_x's example working fine. there is no problem. but want to
> generate frequency using Clear the corresponding External
>
> > Match bit/output to 0 (MATn.m pin is
>
> > >LOW if pinned out).
>
> i am failed to generate, output value is not set on timer overflow. how
> can i set output value after comparsion match occur to generate frequency.

Why do you want to use exactly that function? It does just what is said:
clear the pin. It won't go up again without you explicitly setting it.
Why don't you try neliz_x's hint about using the toggle function?

--

Timo
Hi:

I would recommend using the PWM module instead of Timer 0.

The reason for this is that at 4.8MHz, you only have ~208ns between edges. This corresponds to approximately 16 CPU clock cycles, which probably is not enough to execute an interrupt and reload the Timer Match register for the next cycle.

With the PWM, all functions are done by hardware, and, once setup, there is no need to do anything in software to keep the generated signal running.

Regards,

Alex.

--- In l..., sukhdeep singh wrote:
>
> it's neliz_x's example working fine. there is no problem. but want to generate frequency using Clear the corresponding External
>
> > Match bit/output to 0 (MATn.m pin is
>
> > >LOW if pinned out).
>
> i am failed to generate, output value is not set on timer overflow. how can i set output value after comparsion match occur to generate frequency.
>
> kindly help me.
> Thanks to all of u for ur replies.
>
> --- On Wed, 24/6/09, tike64@... wrote:
>
> From: tike64@...
> Subject: [lpc2000] Re: LPC2378 timer0
> To: l...
> Date: Wednesday, 24 June, 2009, 2:52 AM
>
>
>
>
>
> sukhdeep singh wrote:
>
> > second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer..
>
> > can u send me its routine.
>
> > > one more thing, i am not able to use Clear the corresponding External
>
> > Match bit/output to 0 (MATn.m pin is
>
> > > >LOW if pinned out).
>
> > can i use this to generate frequency. if yes, then how?
>
> So, what was wrong with the neliz_x's ideas? How did you try them? What
>
> did happen?
>
> --
>
> Timo
>
>
>
>
>
>
>
>
>
>
>
>
>
> ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com
>
>
>

thanks,

what is the roll of lear the corresponding External

>

> > Match bit/output to 0 (MATn.m pin is

>

> > >LOW if pinned out).

where will we use it in programming.
Thanks

--- On Wed, 24/6/09, Alex Ribero wrote:

From: Alex Ribero
Subject: [lpc2000] Re: LPC2378 timer0
To: l...
Date: Wednesday, 24 June, 2009, 6:00 AM





Hi:

I would recommend using the PWM module instead of Timer 0.

The reason for this is that at 4.8MHz, you only have ~208ns between edges. This corresponds to approximately 16 CPU clock cycles, which probably is not enough to execute an interrupt and reload the Timer Match register for the next cycle.

With the PWM, all functions are done by hardware, and, once setup, there is no need to do anything in software to keep the generated signal running..

Regards,

Alex.

--- In lpc2000@yahoogroups .com, sukhdeep singh wrote:

>

> it's neliz_x's example working fine. there is no problem. but want to generate frequency using Clear the corresponding External

>

> > Match bit/output to 0 (MATn.m pin is

>

> > >LOW if pinned out).

>

> i am failed to generate, output value is not set on timer overflow. how can i set output value after comparsion match occur to generate frequency..

>

> kindly help me.

> Thanks to all of u for ur replies.

>

> --- On Wed, 24/6/09, tike64@... wrote:

>

> From: tike64@...

> Subject: [lpc2000] Re: LPC2378 timer0

> To: lpc2000@yahoogroups .com

> Date: Wednesday, 24 June, 2009, 2:52 AM

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

> sukhdeep singh wrote:

>

> > second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer..

>

> > can u send me its routine.

>

> >

>

> > one more thing, i am not able to use Clear the corresponding External

>

> > Match bit/output to 0 (MATn.m pin is

>

> >

>

> > >LOW if pinned out).

>

> > can i use this to generate frequency. if yes, then how?

>

>

>

> So, what was wrong with the neliz_x's ideas? How did you try them? What

>

> did happen?

>

>

>

> --

>

>

>

> Timo

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

> ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket. yahoo.com

>

>

>















ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com



Hi:

This simply indicates that the bit EM0 will go LOW when the match occurs.

For example

T0EMR |= (1 << 4);

will program the Timer 0 to Clear the EM0 bit (on that same register T0EMR) when a match event occurs (TC=MR0).

If you choose to connect the Match Pin out (to a GPIO using the PINCONNECT registers), then the GPIO will go low.

Note that if you want to have an actual clock signal, you would need to use the Toggle function or set manually back the bit to 1.

Regards,

Alex

--- In l..., sukhdeep singh wrote:
>
> thanks,
>
> what is the roll of lear the corresponding External
>
> >
>
> > > Match bit/output to 0 (MATn.m pin is
>
> >
>
> > > >LOW if pinned out).
>
> where will we use it in programming.
> Thanks
>
> --- On Wed, 24/6/09, Alex Ribero wrote:
>
> From: Alex Ribero
> Subject: [lpc2000] Re: LPC2378 timer0
> To: l...
> Date: Wednesday, 24 June, 2009, 6:00 AM
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Hi:
>
>
>
> I would recommend using the PWM module instead of Timer 0.
>
>
>
> The reason for this is that at 4.8MHz, you only have ~208ns between edges. This corresponds to approximately 16 CPU clock cycles, which probably is not enough to execute an interrupt and reload the Timer Match register for the next cycle.
>
>
>
> With the PWM, all functions are done by hardware, and, once setup, there is no need to do anything in software to keep the generated signal running..
>
>
>
> Regards,
>
>
>
> Alex.
>
>
>
> --- In lpc2000@yahoogroups .com, sukhdeep singh wrote:
>
> >
>
> > it's neliz_x's example working fine. there is no problem. but want to generate frequency using Clear the corresponding External
>
> >
>
> > > Match bit/output to 0 (MATn.m pin is
>
> >
>
> > > >LOW if pinned out).
>
> >
>
> > i am failed to generate, output value is not set on timer overflow. how can i set output value after comparsion match occur to generate frequency..
>
> >
>
> > kindly help me.
>
> > Thanks to all of u for ur replies.
>
> >
>
> > --- On Wed, 24/6/09, tike64@ wrote:
>
> >
>
> > From: tike64@
>
> > Subject: [lpc2000] Re: LPC2378 timer0
>
> > To: lpc2000@yahoogroups .com
>
> > Date: Wednesday, 24 June, 2009, 2:52 AM
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > sukhdeep singh wrote:
>
> >
>
> > > second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer..
>
> >
>
> > > can u send me its routine.
>
> >
>
> > >
>
> >
>
> > > one more thing, i am not able to use Clear the corresponding External
>
> >
>
> > > Match bit/output to 0 (MATn.m pin is
>
> >
>
> > >
>
> >
>
> > > >LOW if pinned out).
>
> >
>
> > > can i use this to generate frequency. if yes, then how?
>
> >
>
> >
>
> >
>
> > So, what was wrong with the neliz_x's ideas? How did you try them? What
>
> >
>
> > did happen?
>
> >
>
> >
>
> >
>
> > --
>
> >
>
> >
>
> >
>
> > Timo
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> >
>
> > ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket. yahoo.com
>
> >
>
> >
>
> >
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com
>
>
>

first of all thanks,
can we not make the make high after match?

--- On Wed, 24/6/09, Alex Ribero wrote:

From: Alex Ribero
Subject: [lpc2000] Re: LPC2378 timer0
To: l...
Date: Wednesday, 24 June, 2009, 9:19 AM





Hi:

This simply indicates that the bit EM0 will go LOW when the match occurs..

For example

T0EMR |= (1 << 4);

will program the Timer 0 to Clear the EM0 bit (on that same register T0EMR) when a match event occurs (TC=MR0).

If you choose to connect the Match Pin out (to a GPIO using the PINCONNECT registers), then the GPIO will go low.

Note that if you want to have an actual clock signal, you would need to use the Toggle function or set manually back the bit to 1.

Regards,

Alex

--- In lpc2000@yahoogroups .com, sukhdeep singh wrote:

>

> thanks,

>

> what is the roll of lear the corresponding External

>

> >

>

> > > Match bit/output to 0 (MATn.m pin is

>

> >

>

> > > >LOW if pinned out).

>

> where will we use it in programming.

> Thanks

>

> --- On Wed, 24/6/09, Alex Ribero wrote:

>

> From: Alex Ribero

> Subject: [lpc2000] Re: LPC2378 timer0

> To: lpc2000@yahoogroups .com

> Date: Wednesday, 24 June, 2009, 6:00 AM

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

> Hi:

>

>

>

> I would recommend using the PWM module instead of Timer 0.

>

>

>

> The reason for this is that at 4.8MHz, you only have ~208ns between edges. This corresponds to approximately 16 CPU clock cycles, which probably is not enough to execute an interrupt and reload the Timer Match register for the next cycle.

>

>

>

> With the PWM, all functions are done by hardware, and, once setup, there is no need to do anything in software to keep the generated signal running..

>

>

>

> Regards,

>

>

>

> Alex.

>

>

>

> --- In lpc2000@yahoogroups .com, sukhdeep singh wrote:

>

> >

>

> > it's neliz_x's example working fine. there is no problem. but want to generate frequency using Clear the corresponding External

>

> >

>

> > > Match bit/output to 0 (MATn.m pin is

>

> >

>

> > > >LOW if pinned out).

>

> >

>

> > i am failed to generate, output value is not set on timer overflow. how can i set output value after comparsion match occur to generate frequency..

>

> >

>

> > kindly help me.

>

> > Thanks to all of u for ur replies.

>

> >

>

> > --- On Wed, 24/6/09, tike64@ wrote:

>

> >

>

> > From: tike64@

>

> > Subject: [lpc2000] Re: LPC2378 timer0

>

> > To: lpc2000@yahoogroups .com

>

> > Date: Wednesday, 24 June, 2009, 2:52 AM

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> > sukhdeep singh wrote:

>

> >

>

> > > second thing, i am not able to generate 4.8Mhz clock using 72Mhz timer..

>

> >

>

> > > can u send me its routine.

>

> >

>

> > >

>

> >

>

> > > one more thing, i am not able to use Clear the corresponding External

>

> >

>

> > > Match bit/output to 0 (MATn.m pin is

>

> >

>

> > >

>

> >

>

> > > >LOW if pinned out).

>

> >

>

> > > can i use this to generate frequency. if yes, then how?

>

> >

>

> >

>

> >

>

> > So, what was wrong with the neliz_x's ideas? How did you try them? What

>

> >

>

> > did happen?

>

> >

>

> >

>

> >

>

> > --

>

> >

>

> >

>

> >

>

> > Timo

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> >

>

> > ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket. yahoo.com

>

> >

>

> >

>

> >

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

>

> ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket. yahoo.com

>

>

>















ICC World Twenty20 England '09 exclusively on YAHOO! CRICKET http://cricket.yahoo.com