<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Timer configuration problem LPC 1769 in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517079#M2004</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cfbsoftware on Thu Oct 10 05:07:22 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Your PCLK speed for Timer0 is CCLK divided by 1, 2, 4 or 8 depending on the value in the PCLK_TIMER0 bits in the PCLKSEL0 register (see Table 40 and 42). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The value of CCLK depends on the PLL settings you have used in your clock configuration. You can find all of the relevant formulae in Chapter 4: LPC17xx Clocking and power control. As an example, the default Oberon initialisation code we use for development boards with a 12Mhz crystal as the clock source is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;NSEL := 0;
&amp;nbsp; CCLKSEL := 3;
&amp;nbsp; MSEL := 11;
&amp;nbsp; Fcco := (2 * 12000000 * (MSEL + 1)) DIV (NSEL + 1);
&amp;nbsp; CCLK := Fcco DIV (CCLKSEL + 1);
&amp;nbsp; PCLK := CCLK DIV 4;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That results in CCLK = 72Mhz and PCLK = 18Mhz&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 17:26:18 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T17:26:18Z</dc:date>
    <item>
      <title>Timer configuration problem LPC 1769</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517076#M2001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Fabienvg on Wed Oct 09 08:41:48 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm really new to microcontrollers and I have problems with setting up a timer (timer 0 in my case)&amp;nbsp; and interrupt. For Example the prescaler, I think I didn't set it right. I want to set the prescaler to 1 ms. Is 1000-1 then right? I cannot imagine it works on only 1 Mhz. I think I made multiple mistakes in the basic configuration. Could anyone modify this to right code or help me out?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks a lot&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;User manual LPC 1769: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.nxp.com%2Fdocuments%2Fuser_manual%2FUM10360.pdf" rel="nofollow noopener noreferrer" target="_blank"&gt;http://www.nxp.com/documents/user_manual/UM10360.pdf&lt;/A&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Basic configuration Timer starts at page 490.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;
#defineTMR16B0TC&amp;nbsp; 0x40004008
#define PCLKSEL0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0x400FC1A8
#define TMR16B0IR 0x40004000
#define TMR16B0TCR 0x40004004
#define TMR16B0PR 0x4000400C
#define TMR16B0MR0 0x40004018
#define TMR16B0MCR&amp;nbsp; 0x40004014
#define TMR16B0CTCR 0x40004070
#define PCONP 0x400FC0C4
#define ISER0 0xE000E100

int* pCLKSEL0= (int*) PCLKSEL0;
int* tMR16B0TCR = (int*) TMR16B0TCR;
int* tMR16B0PR = (int*) TMR16B0PR;
int* tMR16B0MR0 = (int*) TMR16B0MR0;
int* tMR16B0MCR = (int*) TMR16B0MCR;
int* tMR16B0CTCR = (int*) TMR16B0CTCR;
int* tMR16B0IR = (int*) TMR16B0IR;
int* iSER0 = (int*) ISER1;
int* tMR16B0TC = (int*) TMR16B0TC;
int* pCONP = (int*) PCONP;

void (*timer_tmr_callback)();

void init()
{
*pCONP = 0x2;
*pCLKSEL0&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0xC;
*tMR16B0TC&amp;nbsp;&amp;nbsp; = 0x0;
*tMR16B0PR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 1000 - 1;
*tMR16B0CTCR&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0;

}

void timer_async_usec( unsigned int msec, void (*callback)())
{
timer_tmr_callback = callback;
*tMR16B0MR0&amp;nbsp;&amp;nbsp;&amp;nbsp; = msec;
*tMR16B0MCR&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x07;
*iSER0&amp;nbsp;&amp;nbsp;&amp;nbsp; = (1 &amp;lt;&amp;lt; 1);
*tMR16B0TCR&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x2;
*tMR16B0TCR&amp;nbsp;&amp;nbsp;&amp;nbsp; = 0x1;
}

void (TIMER0_IRQHandler(void))
{
*tMR16B0IR = 0x1F;
timer_tmr_callback();
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:26:16 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517076#M2001</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:26:16Z</dc:date>
    </item>
    <item>
      <title>Re: Timer configuration problem LPC 1769</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517077#M2002</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cfbsoftware on Wed Oct 09 14:31:46 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;If you want a delay of 1 msec then you should set the prescale register to (PCLK / 1000) - 1 where PCLK is your peripheral clock speed. Watch out for rounding / truncation issues if PCLK is not a multiple of 1000.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:26:17 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517077#M2002</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Timer configuration problem LPC 1769</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517078#M2003</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Fabienvg on Thu Oct 10 00:41:47 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you. Could you tell me what the PCLK speed is? I could not find it in the use manual. Do you mind taking a look?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:26:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517078#M2003</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:26:18Z</dc:date>
    </item>
    <item>
      <title>Re: Timer configuration problem LPC 1769</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517079#M2004</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by cfbsoftware on Thu Oct 10 05:07:22 MST 2013&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Your PCLK speed for Timer0 is CCLK divided by 1, 2, 4 or 8 depending on the value in the PCLK_TIMER0 bits in the PCLKSEL0 register (see Table 40 and 42). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The value of CCLK depends on the PLL settings you have used in your clock configuration. You can find all of the relevant formulae in Chapter 4: LPC17xx Clocking and power control. As an example, the default Oberon initialisation code we use for development boards with a 12Mhz crystal as the clock source is:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca"&gt; &lt;PRE&gt;NSEL := 0;
&amp;nbsp; CCLKSEL := 3;
&amp;nbsp; MSEL := 11;
&amp;nbsp; Fcco := (2 * 12000000 * (MSEL + 1)) DIV (NSEL + 1);
&amp;nbsp; CCLK := Fcco DIV (CCLKSEL + 1);
&amp;nbsp; PCLK := CCLK DIV 4;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;That results in CCLK = 72Mhz and PCLK = 18Mhz&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 17:26:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Timer-configuration-problem-LPC-1769/m-p/517079#M2004</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T17:26:18Z</dc:date>
    </item>
  </channel>
</rss>

