<?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: LPC1347 Setting up 16bit timer MCR register in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1347-Setting-up-16bit-timer-MCR-register/m-p/725397#M29324</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;Thank you for your interest in NXP Semiconductor products and&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;for the opportunity to serve you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After a brief review of code, I've not found something wrong yet, so I'd highly recommend you to check the values of the set of CT16B0 registers in the visual window when debugging the demo.&lt;/P&gt;&lt;P&gt;It's a good way to figure out the root cause of issue.&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Dec 2017 02:43:28 GMT</pubDate>
    <dc:creator>jeremyzhou</dc:creator>
    <dc:date>2017-12-19T02:43:28Z</dc:date>
    <item>
      <title>LPC1347 Setting up 16bit timer MCR register</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1347-Setting-up-16bit-timer-MCR-register/m-p/725396#M29323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'd like to use 16bit timer to get interrupt with 1s period. I have one question. This is my code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#include "board.h"&lt;/P&gt;&lt;P&gt;#include &amp;lt;cr_section_macros.h&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;#define PORT 1&lt;BR /&gt;#define PIN 1&lt;/P&gt;&lt;P&gt;#define LED_PORT 0&lt;BR /&gt;#define LED_PIN 7&lt;/P&gt;&lt;P&gt;#define IR_MR0INT_MASK _BIT(0)&lt;/P&gt;&lt;P&gt;#define MCR_MR0I_MASK _BIT(0)&lt;BR /&gt;#define MCR_MR0R_MASK _BIT(1)&lt;/P&gt;&lt;P&gt;#define TCR_CEN_MASK _BIT(0)&lt;BR /&gt;#define TCR_CRST_MASK _BIT(1)&lt;/P&gt;&lt;P&gt;#define CT_CLOCK_MASK _BIT(SYSCTL_CLOCK_CT16B0)&lt;BR /&gt;#define NVIC_CT_INT_GROUP 0&lt;BR /&gt;#define NVIC_CT_INT_MASK _BIT(TIMER_16_0_IRQn)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/**&lt;BR /&gt; * @brief Timer interrupt handler&lt;BR /&gt; * @return Nothing&lt;BR /&gt; */&lt;BR /&gt;void TIMER16_0_IRQHandler(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Check if match channel 1 interrupt is pending&lt;BR /&gt;&amp;nbsp; &amp;nbsp; if (LPC_TIMER16_0-&amp;gt;IR &amp;amp; IR_MR0INT_MASK) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // If yes clear interrupt flag and toogle the led state&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;IR = IR_MR0INT_MASK;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LPC_GPIO_PORT-&amp;gt;NOT[LED_PORT] = _BIT(LED_PIN);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * @return Function should not exit&lt;BR /&gt; */&lt;BR /&gt;int main(void) {&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Generic setup&lt;BR /&gt;&amp;nbsp; &amp;nbsp; SystemCoreClockUpdate();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Board_Init();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_GPIO_PORT-&amp;gt;B[LED_PORT][LED_PIN] = 0;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Turn on the timer clock&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_SYSCTL-&amp;gt;SYSAHBCLKCTRL |= CT_CLOCK_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Reset the timer&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;TC = 1;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;TCR |= TCR_CRST_MASK;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; while (LPC_TIMER16_0-&amp;gt;TC != 0) {}&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;TCR &amp;amp;= ~(TCR_CRST_MASK);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Clear the interrupt register&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;IR = IR_MR0INT_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Set the prescaler value&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // System core clock = 72MHz, the wanted T is 0,5ms =&amp;gt; f = 2kHz&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // 72MHz / 2KHz = 36000&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;PR = 36000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Configure the counter to generate an interrupt on match and reset the TC value&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;MCR |= (MCR_MR0I_MASK | MCR_MR0R_MASK);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Generate interrupt each 1s&lt;BR /&gt;&amp;nbsp; &amp;nbsp; // Each TC increment takes exactly 0,5ms =&amp;gt; 2000 * 0,5ms = 1s&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;MR[0] = 2000;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Enable counting&lt;BR /&gt;&amp;nbsp; &amp;nbsp; LPC_TIMER16_0-&amp;gt;TCR |= TCR_CEN_MASK;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; // Configure NVIC registers - clear pending and enable IRQ&lt;BR /&gt;&amp;nbsp; &amp;nbsp; NVIC-&amp;gt;ICPR[NVIC_CT_INT_GROUP] = NVIC_CT_INT_MASK;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; NVIC-&amp;gt;ISER[NVIC_CT_INT_GROUP] = NVIC_CT_INT_MASK;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; while (1) {&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;__WFI();&lt;BR /&gt;&amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; return 0 ;&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This works perfect but when I change line&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp; LPC_TIMER16_0-&amp;gt;MR[0] = 2000;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;to&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&amp;nbsp;LPC_TIMER16_0-&amp;gt;MR[1] = 2000; // or MR[2]&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;and don't change anything else program still works. My question is why? I have configured to have interrupt when MR[0] match TC value... Does anyone know the answer?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Dec 2017 09:02:49 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1347-Setting-up-16bit-timer-MCR-register/m-p/725396#M29323</guid>
      <dc:creator>mateuszkiełbasa</dc:creator>
      <dc:date>2017-12-15T09:02:49Z</dc:date>
    </item>
    <item>
      <title>Re: LPC1347 Setting up 16bit timer MCR register</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1347-Setting-up-16bit-timer-MCR-register/m-p/725397#M29324</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;Thank you for your interest in NXP Semiconductor products and&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV style="white-space: pre-wrap; text-align: left; line-height: 1.75; font-size: 14px;"&gt;&lt;SPAN style="font-family: 'Microsoft YaHei', STXihei; background-color: #ffffff;"&gt;for the opportunity to serve you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After a brief review of code, I've not found something wrong yet, so I'd highly recommend you to check the values of the set of CT16B0 registers in the visual window when debugging the demo.&lt;/P&gt;&lt;P&gt;It's a good way to figure out the root cause of issue.&lt;BR /&gt;Have a great day,&lt;BR /&gt;TIC&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Dec 2017 02:43:28 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC1347-Setting-up-16bit-timer-MCR-register/m-p/725397#M29324</guid>
      <dc:creator>jeremyzhou</dc:creator>
      <dc:date>2017-12-19T02:43:28Z</dc:date>
    </item>
  </channel>
</rss>

