<?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 Set / Clear IO bit in LPCOpen (very-very beginner) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585081#M21161</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Bela on Wed Nov 05 08:02:50 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Gentlemen,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new to Cortex M3, also to LPCXpresso, and to LPCOpen and even to C language. But I do have a motivation to learn it all :-)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use LPCXpresso 7.3.0 on Ubuntu 14.04. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An LPCXpresso 1768 board is connected. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can open an existing example-project, in my case it is a blinky example, it compiles and can be downloaded to the board. Since it just blinks, there's nothing to do with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It took me a while, while I could recognize that CMSIS, mbed and LPCOpen are different things and shouldn't be mixed up :-) I decided to try to use LPCOpen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My next step is to write my own code for something similar. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There's an LED on P0.22, I want to control it's brightness up and down slowly, employing PWM principle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To do this, I could use Timer0 and one (or two) of the match registers. They could procuce an internal PWM and I could control the P0.22 in software, because this pin cannot be controlled directly by the built-in PWM hardware. The PWM rate would be changed by SysTick IT, one step in every 10 msec by incrementing / decrementing the value in Timer0/match0 register. Match0 could provide the duty cycle, Match1 the PWM period and it also resets Timer0. That's my idea.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are the problems coming in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.:&amp;nbsp;&amp;nbsp; There's only one IT vector for Timer0. How can my code detect if this IT is due to one of the match registers? Both should have it's IT enabled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.:&amp;nbsp;&amp;nbsp; I couldn't find out how could I write a value into Timer0/Match0 and Match1 register? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPCXpresso gives proposals to some registers, for example like this: LPC_SYSCTL-&amp;gt;PCONP Here PCONP comes up automatically as I enter LPC_SYSCTL-&amp;gt; . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; But if I try LPC_TIMER0-&amp;gt; here just MR is valid. In the user manual I see 4 match registers for each of the timers, not only one. I don't understand, how could I access one out of the 4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3.:&amp;nbsp; How could I set and/or clear the P0.22 bit? When I try LPC_GPIO_T-&amp;gt; no proposal comes, and whatever I try to finish this instruction, it doesn't compile, saying:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;../src/Proba03.c:101:12: error: expected identifier or '(' before '-&amp;gt;' token&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; LPC_GPIO_T-&amp;gt;CLR0 = (1&amp;lt;&amp;lt;22);&amp;nbsp;&amp;nbsp;&amp;nbsp; // LED1 output low (On)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Similarly, I couldn't acces the IO control bits, because LPC_IOCON_T-&amp;gt;&amp;nbsp; doesn't compile and doesn't give proposals.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;4.:&amp;nbsp; Is there a verbosely written documentation of LPCOpen? I do have this HTML docu: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fsystem%2Ffiles%2Flpcopen_2_10_docs_17xx_40xx.zip" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/system/files/lpcopen_2_10_docs_17xx_40xx.zip&lt;/A&gt;&lt;SPAN&gt; but it is not written for beginners.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is so inconvenient sitting in the darkness, could someone help me, please?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 20:25:57 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T20:25:57Z</dc:date>
    <item>
      <title>Set / Clear IO bit in LPCOpen (very-very beginner)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585081#M21161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Bela on Wed Nov 05 08:02:50 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Gentlemen,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm new to Cortex M3, also to LPCXpresso, and to LPCOpen and even to C language. But I do have a motivation to learn it all :-)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I use LPCXpresso 7.3.0 on Ubuntu 14.04. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;An LPCXpresso 1768 board is connected. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I can open an existing example-project, in my case it is a blinky example, it compiles and can be downloaded to the board. Since it just blinks, there's nothing to do with.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It took me a while, while I could recognize that CMSIS, mbed and LPCOpen are different things and shouldn't be mixed up :-) I decided to try to use LPCOpen.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My next step is to write my own code for something similar. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;There's an LED on P0.22, I want to control it's brightness up and down slowly, employing PWM principle.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;To do this, I could use Timer0 and one (or two) of the match registers. They could procuce an internal PWM and I could control the P0.22 in software, because this pin cannot be controlled directly by the built-in PWM hardware. The PWM rate would be changed by SysTick IT, one step in every 10 msec by incrementing / decrementing the value in Timer0/match0 register. Match0 could provide the duty cycle, Match1 the PWM period and it also resets Timer0. That's my idea.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here are the problems coming in.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.:&amp;nbsp;&amp;nbsp; There's only one IT vector for Timer0. How can my code detect if this IT is due to one of the match registers? Both should have it's IT enabled.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2.:&amp;nbsp;&amp;nbsp; I couldn't find out how could I write a value into Timer0/Match0 and Match1 register? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LPCXpresso gives proposals to some registers, for example like this: LPC_SYSCTL-&amp;gt;PCONP Here PCONP comes up automatically as I enter LPC_SYSCTL-&amp;gt; . &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; But if I try LPC_TIMER0-&amp;gt; here just MR is valid. In the user manual I see 4 match registers for each of the timers, not only one. I don't understand, how could I access one out of the 4.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3.:&amp;nbsp; How could I set and/or clear the P0.22 bit? When I try LPC_GPIO_T-&amp;gt; no proposal comes, and whatever I try to finish this instruction, it doesn't compile, saying:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;../src/Proba03.c:101:12: error: expected identifier or '(' before '-&amp;gt;' token&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; LPC_GPIO_T-&amp;gt;CLR0 = (1&amp;lt;&amp;lt;22);&amp;nbsp;&amp;nbsp;&amp;nbsp; // LED1 output low (On)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Similarly, I couldn't acces the IO control bits, because LPC_IOCON_T-&amp;gt;&amp;nbsp; doesn't compile and doesn't give proposals.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;4.:&amp;nbsp; Is there a verbosely written documentation of LPCOpen? I do have this HTML docu: &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Fwww.lpcware.com%2Fsystem%2Ffiles%2Flpcopen_2_10_docs_17xx_40xx.zip" rel="nofollow" target="_blank"&gt;http://www.lpcware.com/system/files/lpcopen_2_10_docs_17xx_40xx.zip&lt;/A&gt;&lt;SPAN&gt; but it is not written for beginners.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;It is so inconvenient sitting in the darkness, could someone help me, please?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:25:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585081#M21161</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: Set / Clear IO bit in LPCOpen (very-very beginner)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585082#M21162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Bela on Thu Nov 06 10:42:48 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Maybe I have to include more header files? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How to do that and how can I find out what headers are available and which one I need?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:25:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585082#M21162</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Set / Clear IO bit in LPCOpen (very-very beginner)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585083#M21163</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by starblue on Fri Nov 07 01:42:26 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Bela&lt;/STRONG&gt;&lt;BR /&gt;1.:&amp;nbsp;&amp;nbsp; There's only one IT vector for Timer0. How can my code detect if this IT is due to one of the match registers?&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Look at the bits in T0IR.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Bela&lt;/STRONG&gt;&lt;BR /&gt;2.:&amp;nbsp;&amp;nbsp; I couldn't find out how could I write a value into Timer0/Match0 and Match1 register? [...] But if I try LPC_TIMER0-&amp;gt; here just MR is valid. In the user manual I see 4 match registers for each of the timers, not only one. I don't understand, how could I access one out of the 4.&lt;/SPAN&gt;&lt;HR /&gt;&lt;SPAN&gt;Typically this would be an array, i.e. use LPC_TIMER0-&amp;gt;MR[0] (I havent't checked, though).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;HR /&gt;&lt;SPAN style="color: #0000ff;"&gt;&lt;STRONG&gt;Quote: Bela&lt;/STRONG&gt;&lt;BR /&gt;3.:&amp;nbsp; How could I set and/or clear the P0.22 bit?&lt;/SPAN&gt;&lt;HR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In general, read the .h file defining these things, and figure out how it relates to the register description in the user manual.&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:25:58 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585083#M21163</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Set / Clear IO bit in LPCOpen (very-very beginner)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585084#M21164</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Ano on Wed Nov 19 04:45:35 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;In LPC Open there should be some functions for this cases.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Setting a Pin: Chip_GPIO_SetPinSate(LPC_GPIO; Portnumber; Portpin, state);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;or state being true or false. There is also a fuction to toggle the pin.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Before you can use this command, you need to set the GPIO to output: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It is called Chip_GPIO_SetDirection or something like that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;For the Matchtimer use: Chip_Timer_SetMatch(X,X,X); There you can enter&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;your desired matchvalue. Write it like that: "Chip_GetSystemClock / Y" with Y &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;being the frequency you want to aquire.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(to understand the match values needed, read this: &lt;/SPAN&gt;&lt;A href="http://http://www.lpcware.com/content/forum/understanding-timer-interval-values-match-register#comment-1131540"&gt;Thread&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 20:25:59 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/Set-Clear-IO-bit-in-LPCOpen-very-very-beginner/m-p/585084#M21164</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T20:25:59Z</dc:date>
    </item>
  </channel>
</rss>

