<?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: LPC1768 problem with timer0 in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574446#M21855</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu May 03 04:13:00 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Where is your Interrupt routine (ISR) and what is not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A simple sample has been posted here: &lt;/SPAN&gt;&lt;A href="http://"&gt;http://knowledgebase.nxp.com/showthread.php?t=2059&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 01:07:38 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:07:38Z</dc:date>
    <item>
      <title>LPC1768 problem with timer0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574445#M21854</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by damiandoles on Thu May 03 03:11:34 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi, this is my first thread in this forum and at the beginning i want to apologize for my English &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt; OK, I've just written small program with timer0 and interrupt. I want to toggle one of the LED on board, but...It doesn't work and I really don't know what's wrong with this code. Each LED is lit...Could you help with it ?&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;
/*
===============================================================================
 Name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : main.c
 Author&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : 
 Version&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :
 Copyright&amp;nbsp;&amp;nbsp; : Copyright (C) 
 Description : main definition
===============================================================================
*/

#ifdef __USE_CMSIS
#include "LPC17xx.h"
#endif

#include &amp;lt;cr_section_macros.h&amp;gt;
#include &amp;lt;NXP/crp.h&amp;gt;

// Variable to store CRP value in. Will be placed automatically
// by the linker when "Enable Code Read Protect" selected.
// See crp.h header for more information
__CRP const unsigned int CRP_WORD = CRP_NO_CRP ;

// TODO: insert other include files here

// TODO: insert other definitions and declarations here
int main(void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO2-&amp;gt;FIODIR |= 1 &amp;lt;&amp;lt; 29;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SC-&amp;gt;PCONP |= 1 &amp;lt;&amp;lt; 1;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SC-&amp;gt;PCLKSEL0 |= 1 &amp;lt;&amp;lt; 3;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 0x00000002;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;MCR |= 0x00000003;
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;MR0 |= 6000000;
&amp;nbsp;&amp;nbsp;&amp;nbsp; NVIC_EnableIRQ(TIMER0_IRQn);
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;TCR |= 0x00000001;
&amp;nbsp;&amp;nbsp;&amp;nbsp; while(1){}
&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0 ;
}

void TIMER0_IRQHandler (void)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; if((LPC_TIM0-&amp;gt;IR &amp;amp; 0x01) == 0x01)
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_TIM0-&amp;gt;IR |= 1 &amp;lt;&amp;lt; 0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_GPIO2-&amp;gt;FIOPIN ^= 1 &amp;lt;&amp;lt; 29;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:07:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574445#M21854</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 problem with timer0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574446#M21855</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu May 03 04:13:00 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Where is your Interrupt routine (ISR) and what is not working?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;A simple sample has been posted here: &lt;/SPAN&gt;&lt;A href="http://"&gt;http://knowledgebase.nxp.com/showthread.php?t=2059&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:07:38 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574446#M21855</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1768 problem with timer0</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574447#M21856</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ex-Zero on Thu May 03 10:52:17 MST 2012&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Back in office and back to work:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error #1:[INDENT]What's obviously wrong here is your timer setup in TCR.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT][INDENT]Reset(1&amp;lt;&amp;lt;1) and Enable(1&amp;lt;&amp;lt;0) at the same time is confusing your timer :confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Since TCR Reset value is 0, you don't need to reset this register. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Just enable it (after enabling Interrupt) with:&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;
 LPC_TIM0-&amp;gt;TCR[B][COLOR=Red] =[/COLOR][/B] 1; //enable timer
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;[/INDENT]Error #2:[INDENT]I'm not sure what you are toggling here. My 1769 has no P2[29] :eek:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Changing it to P1[29] shows a wonderful signal &lt;SPAN class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;&lt;LI-EMOJI id="lia_slightly-smiling-face" title=":slightly_smiling_face:"&gt;&lt;/LI-EMOJI&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Toggling as desired with (CCLK/2)/6E6 = 50MHz/6E6 = 8.33Hz &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;[/INDENT]&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:07:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/LPC1768-problem-with-timer0/m-p/574447#M21856</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:07:39Z</dc:date>
    </item>
  </channel>
</rss>

