<?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>LPCXpresso IDE中的主题 Re: Using Timer</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582059#M25229</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Mike45 on Fri Nov 05 15:14:45 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: volter&lt;/STRONG&gt;&lt;BR /&gt;Can you give me a short explanation of what is: DDRB,TCCR1B,PORTB and how it work in lpc1343?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DDRB is for setting input or outpin of the pin, like GPIOnDIR on the 1343(pg 119 of the user manual).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TCCR1B is a configuration register, it includes things such as a prescaler for the clock, how the timer operates ( different modes like CTC- whether you want a configurable match compare or normal mode).&amp;nbsp; The 1343 has these modes and a prescaler for the clock( pg. 262).&amp;nbsp; I've also got a lot to learn about the timer, but you can get started with the basic timer example that everyone has access to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PORTB is for setting the bit on a pin, it is done through GPIOnDATA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for DDRB and PORTB, gpio.h that is included in the examples has two handy functions that sets the direction and level of the pin like so:&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;/*****************************************************************************
** Function name:GPIOSetValue
**
** Descriptions:Set/clear a bitvalue in a specific bit position
**in GPIO portX(X is the port number.)
**
** parameters:port num, bit position, bit value
** Returned value:None
**
*****************************************************************************/
static __INLINE void GPIOSetValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
{
LPC_GPIO[portNum]-&amp;gt;MASKED_ACCESS[(1&amp;lt;&amp;lt;bitPosi)] = (bitVal&amp;lt;&amp;lt;bitPosi);
}

/*****************************************************************************
** Function name:GPIOSetDir
**
** Descriptions:Set the direction in GPIO port
**
** parameters:port num, bit position, direction (1 out, 0 input)
** Returned value:None
**
*****************************************************************************/
static __INLINE void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )
{
if(dir)
LPC_GPIO[portNum]-&amp;gt;DIR |= 1&amp;lt;&amp;lt;bitPosi;
else
LPC_GPIO[portNum]-&amp;gt;DIR &amp;amp;= ~(1&amp;lt;&amp;lt;bitPosi);
}&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:14:37 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:14:37Z</dc:date>
    <item>
      <title>Using Timer</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582056#M25226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by volter on Fri Nov 05 09:02:51 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Can some on give an example of how to use Timers in LPCXpresso PLC1343 ?:confused:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I know how to do them in microcontrollers type 80C52&amp;nbsp; but this microcontroller more powerful.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:14:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582056#M25226</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:14:34Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timer</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582057#M25227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Mike45 on Fri Nov 05 10:14:23 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;i learned timers on avrs using this tutorial - &lt;/SPAN&gt;&lt;A href="http://"&gt;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=50106&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;most of everything i learned from that tutorial can be applied to the 1343.&amp;nbsp; for timing calculations, this equation has served me well :&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;"Target Timer Count = (1 / Target Frequency) / (1 / Timer Clock Frequency) - 1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hope it might help you,&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:14:35 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582057#M25227</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timer</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582058#M25228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by volter on Fri Nov 05 13:35:52 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Mike45&lt;/STRONG&gt;&lt;BR /&gt;i learned timers on avrs using this tutorial - &lt;A href="http://"&gt;http://www.avrfreaks.net/index.php?name=PNphpBB2&amp;amp;file=viewtopic&amp;amp;t=50106&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;most of everything i learned from that tutorial can be applied to the 1343.&amp;nbsp; for timing calculations, this equation has served me well :&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;"Target Timer Count = (1 / Target Frequency) / (1 / Timer Clock Frequency) - 1"&lt;BR /&gt;&lt;BR /&gt;hope it might help you,&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can you give me a short explanation of what is: DDRB,TCCR1B,PORTB and how it work in lpc1343?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:14:36 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582058#M25228</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timer</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582059#M25229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Mike45 on Fri Nov 05 15:14:45 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: volter&lt;/STRONG&gt;&lt;BR /&gt;Can you give me a short explanation of what is: DDRB,TCCR1B,PORTB and how it work in lpc1343?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;DDRB is for setting input or outpin of the pin, like GPIOnDIR on the 1343(pg 119 of the user manual).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TCCR1B is a configuration register, it includes things such as a prescaler for the clock, how the timer operates ( different modes like CTC- whether you want a configurable match compare or normal mode).&amp;nbsp; The 1343 has these modes and a prescaler for the clock( pg. 262).&amp;nbsp; I've also got a lot to learn about the timer, but you can get started with the basic timer example that everyone has access to.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PORTB is for setting the bit on a pin, it is done through GPIOnDATA.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;for DDRB and PORTB, gpio.h that is included in the examples has two handy functions that sets the direction and level of the pin like so:&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;/*****************************************************************************
** Function name:GPIOSetValue
**
** Descriptions:Set/clear a bitvalue in a specific bit position
**in GPIO portX(X is the port number.)
**
** parameters:port num, bit position, bit value
** Returned value:None
**
*****************************************************************************/
static __INLINE void GPIOSetValue( uint32_t portNum, uint32_t bitPosi, uint32_t bitVal )
{
LPC_GPIO[portNum]-&amp;gt;MASKED_ACCESS[(1&amp;lt;&amp;lt;bitPosi)] = (bitVal&amp;lt;&amp;lt;bitPosi);
}

/*****************************************************************************
** Function name:GPIOSetDir
**
** Descriptions:Set the direction in GPIO port
**
** parameters:port num, bit position, direction (1 out, 0 input)
** Returned value:None
**
*****************************************************************************/
static __INLINE void GPIOSetDir( uint32_t portNum, uint32_t bitPosi, uint32_t dir )
{
if(dir)
LPC_GPIO[portNum]-&amp;gt;DIR |= 1&amp;lt;&amp;lt;bitPosi;
else
LPC_GPIO[portNum]-&amp;gt;DIR &amp;amp;= ~(1&amp;lt;&amp;lt;bitPosi);
}&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:14:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582059#M25229</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Using Timer</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582060#M25230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by fpg on Fri Mar 18 11:18:53 MST 2011&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm also in trouble with using timer in my LPC1769. I use timer0, I manage to start it, but I cannot make it stop, I've tried with a couple of methods (I only need one delayed interrupt):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;- I set MR0S bit in Match Control Register during configuring timer with CMSIS function TIM_ConfigMatch.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I tried the CMSIS function TIM_Cmd(LPC_TIM0, DISABLE), which resets enable bit in TCR register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I tried to disable interrupt on match by resetting MR0I bit in Match Control Register.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(- During debugging I noticed, that Counter Enable register does not remain one after enabling. At least, it seems so during from the debugger. Why is that... ? )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- It is written in lpc17xx datasheet, that during TCR[1] is set, TC and PC is 0. I tried that and they are 0, but the interrupt yet happens.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;- I even tried disabling power supply, by resetting the appropriate bit in PCONP register in debug mode. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I really do not understand why interrupt is happening over and over again...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:14:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Using-Timer/m-p/582060#M25230</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:14:37Z</dc:date>
    </item>
  </channel>
</rss>

