<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>match register on lpc2378</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/28157/match-register-on-lpc2378</link><description> 
Hi all. 
I want to use all 4 T0MRx in my program. 
whit TxMCR we can set what happen after T0MRx match with T0TC. 
my problem is here : I could wrote code for 1 T0MRx , but I can&amp;#39;t
write code for all of them. 

 
one point : timerx jast have one isr</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/140022?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 13:31:54 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:292a7a93-5379-4b3e-85b0-7904f1b09062</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
&amp;quot;I think my problem is on T0IR , isn&amp;#39;t it ?&amp;quot;&lt;/p&gt;

&lt;p&gt;
That&amp;#39;s not your only problem - I do cover more problems in my
previous answer. And I didn&amp;#39;t spend any time looking at your timer
initialization. Just at your &amp;quot;detect&amp;quot; and &amp;quot;acknowledge&amp;quot; sections of
your ISR.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/130844?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 13:18:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:ed766be3-9394-4f5b-b792-4219cb36327f</guid><dc:creator>shayan nikzad</dc:creator><description>&lt;p&gt;&lt;p&gt;
OK , you are right.&lt;br /&gt;
I think my problem is on T0IR , isn&amp;#39;t it ?&lt;/p&gt;

&lt;p&gt;
thank you.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/127066?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 12:58:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:5ff38c77-7f98-4f43-b2bf-33bd588cbffc</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
When you did spend time reading the user manual - especially the
chapter about the timers - how many of the registers did you spend
time reading about?&lt;/p&gt;

&lt;p&gt;
Did you read anything about the IR register? Maybe any sentence
like &amp;quot;The IR can be read to identify which of eight possible
interrupt sources are pending.&amp;quot;? What was your conclusion, when you
did read that sentence? Did it make you excited, and motivated you to
take a closer look at the IR register? I don&amp;#39;t see your code test any
contents of the IR register.&lt;/p&gt;

&lt;pre&gt;
void timer0_isr(void) __irq{
    if(T0MR0==T0TC)
        i++;
    else if(T0MR1==T0TC)
        j--;

    T0IR=3;
    VICVectAddr=0;
    T0TCR=1;
}
&lt;/pre&gt;

&lt;p&gt;
What make you think that you can compare the fixed value (your
configuration) in T0MR0 and T0MR1 with T0TC? Haven&amp;#39;t you considered
that T0TC is constantly ticking - potentially at a quite high
frequency? What if T0TC happens to tick up one or more ticks before
your ISR has a change to check the value of it? How would then your
== tests manage to compare with T0MR0 or T0MR1?&lt;/p&gt;

&lt;p&gt;
Your code doesn&amp;#39;t contain any code where you compute any times or
frequencies, so I can&amp;#39;t tell. I don&amp;#39;t even know what crystal you
have. But let&amp;#39;s say that T0TC ticks at 10MHz - 1 tick ever 100ns. Do
you expect your ISR to be called, and your two if statements to be
procesed within less than 100ns? Or maybe the timer is ticking even
faster...&lt;/p&gt;

&lt;pre&gt;
T0IR=3;
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
How, just how, can you clear interrupts for both match register 0 and
match register 1, when you don&amp;#39;t even know which of the match
registers that trigged the interrupt?&lt;/p&gt;

&lt;pre&gt;
T0TCR=1
&lt;/pre&gt;

&lt;p&gt;
&lt;br /&gt;
So you ask for a reset of the timer, i.e. for it to restart from
zero. You do this on every interrupt. But if match 0 is after 1.5
million ticks, and match 1 after 3 million ticks - how will the timer
ever be able to reach 3 million ticks when you reset it to zero
already after 1.5 million ticks?&lt;/p&gt;

&lt;p&gt;
Next thing - what makes you think you need to restart the timer
manually? Haven&amp;#39;t you - when you did read the user manual
(specifically the chapter about timers) noted that each match
register (through the match control register) can be configured
to:&lt;br /&gt;
- possibly generate an interrupt on match&lt;br /&gt;
- possibly restart the timer on match&lt;br /&gt;
- possibly stop the timer on match&lt;/p&gt;

&lt;p&gt;
Wouldn&amp;#39;t it be much better to have match register 0 generate an
interrupt on match, and match register 1 generate both an interrupt,
and a reset of the timer? Then the timer would - all by itself -
count to 3 million and directly restart from zero.&lt;/p&gt;

&lt;p&gt;
By the way - are you sure you should have the match register match
for 1500000 and 3000000? Would a match value of 1 mean a timer with
only 1 tick or a timer with two (0 and 1)? What does the user manual
say?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/116483?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 09:17:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:0ebaacab-bf10-4f02-b2f8-2b2682add126</guid><dc:creator>shayan nikzad</dc:creator><description>&lt;p&gt;&lt;p&gt;
is there any special register to find out ?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/116479?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 09:15:20 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:10fe5f14-7006-4e73-b0e5-e81b21a063f6</guid><dc:creator>shayan nikzad</dc:creator><description>&lt;p&gt;&lt;p&gt;
I set register T0MCR when match in happened , stop counting.so in
Timer0_isr , i compared T0TC whit T0MRx that i used them. and wrote
when T0MR0 is match , i++ and when T0MR1 is match , j--.&lt;br /&gt;
but on lcd I just one of them working.&lt;/p&gt;

&lt;p&gt;
please help me.&lt;/p&gt;

&lt;p&gt;
thanks all.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/116480?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 09:08:55 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:bdff2055-8c81-4a97-a521-9e4327327604</guid><dc:creator>shayan nikzad</dc:creator><description>&lt;p&gt;&lt;p&gt;
it&amp;#39;s my code :&lt;/p&gt;

&lt;pre&gt;
#include &amp;lt;lpc23xx.h&amp;gt;

#define     LCD_PORT_0
#define     LCD_RS 25
#define         LCD_E 24
#define         LCD_DB4 23
#define         LCD_DB5 22
#define         LCD_DB6 21
#define         LCD_DB7 20
#include &amp;lt;lcd.h&amp;gt;






int i=0;
int j=10000;

void timer0_isr(void) __irq{


if(T0MR0==T0TC)
i++;
else if(T0MR1==T0TC)
j--;


T0IR=3;
VICVectAddr=0;
T0TCR=1;
}



int main(){
SCS=1;
lcd_init();
lcd_clear();

//timer0 setting
T0TCR=2;                           // reset counter , disable counter
T0CTCR=0;             // set T/C for Timer
T0PR=0;              // no prescale
T0MR0=1500000;
T0MR1=3000000;
T0MCR=63;
T0TCR=1;                   //enable counter

//interrupt setting
VICIntSelect=0;          // set timer0 interrupt on IRQ mood
VICIntEnable=1 &amp;lt;&amp;lt; 4;               // enable interrupt for timer0
VICVectAddr4=(unsigned long) timer0_isr;         //set label for jump when T0MR0 is match with T0TC


//LEDs setting
PINSEL6=0;
FIO3DIR0=255;

//main loop

while(1){

lcd_gotoxy(1,1);
lcd_puts(i);
lcd_putsf(&amp;quot;      &amp;quot;);
lcd_gotoxy(2,1);
lcd_puts(j);
lcd_putsf(&amp;quot;    &amp;quot;);


}}


&lt;/pre&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/105202?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 09:01:15 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:3a47e1a8-7c7b-4e45-9455-1be06fbd4e7d</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
The timer 0 can only have one single ISR for a simple reason. One
ISR can handle all four match registers, since the ISR can check
which of the match registers that resulted in the interrupt.&lt;/p&gt;

&lt;p&gt;
Have you located the part of the user manual documentation that
tells you how to figure out which match register(s) that have
matched?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/105203?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 08:55:27 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:23dc697f-e85e-46bf-ab4c-87f42f710cff</guid><dc:creator>HansBernhard Broeker</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;i could wrote a code , but it didn&amp;#39;t work.&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
And it really didn&amp;#39;t occur to you that&lt;/p&gt;

&lt;p&gt;
a) you&amp;#39;ll not just have to &lt;b&gt;write&lt;/b&gt; code, but also &lt;b&gt;show&lt;/b&gt;
it to people, if they&amp;#39;re to have any chance at helping you, nor
that&lt;/p&gt;

&lt;p&gt;
b) &amp;quot;it didn&amp;#39;t work&amp;quot; is an utterly useless way of describing any
error&lt;/p&gt;

&lt;p&gt;
?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/79528?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 08:18:36 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a62af495-a0b2-437b-80a3-2828a75c5e88</guid><dc:creator>shayan nikzad</dc:creator><description>&lt;p&gt;&lt;p&gt;
actually , i could wrote a code , but it didn&amp;#39;t work.&lt;/p&gt;

&lt;p&gt;
I have already read UM and i have not problem with that , and i
wrote code for just one match register , now i want code for all of 4
match register on Timer0 for example.&lt;/p&gt;

&lt;p&gt;
thanks for your answer.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: match register on lpc2378</title><link>https://community.arm.com/thread/66866?ContentTypeID=1</link><pubDate>Sun, 28 Aug 2011 08:13:06 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:14cb7e4d-eb2a-49df-bd55-ad4637fde459</guid><dc:creator>Andy Neil</dc:creator><description>&lt;p&gt;&lt;p&gt;
&lt;i&gt;&amp;quot;but I can&amp;#39;t write code for all of them&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Why not? What&amp;#39;s the problem?&lt;/p&gt;

&lt;p&gt;
&lt;i&gt;&amp;quot;timerx jast have one isr , how i can use all of 4 T0MRx
interrupt?&amp;quot;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;
Study the chip&amp;#39;s &lt;b&gt;documentation&lt;/b&gt; to see what features are
available to identify which timer caused the interrupt...?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>