<?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 Peripheral register access, RESERVED registers in LPCXpresso IDE</title>
    <link>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581692#M25059</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by curtvm on Sun Nov 07 08:12:03 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC11xx manual&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.2 Memory map-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;All peripheral register addresses are 32-bit word aligned regardless of their size. An implication of this is that word and half-word registers must be accessed all at once. For example, it is not possible to read or write the upper byte of a word register separately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am unclear as to what this means. It seems to me the 'implication' is that since these registers are word aligned, they CAN be accessed as a word. The Cortex M0 requires word alignment for word access, halfword alignment for halfword access, and of course no alignment for byte access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These registers cannot be accessed on a byte level?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other part of this, is RESERVED bits in registers. Some have specific values that need to be written (like PDRUNCFG), some have non-zero reset values (like IOCON_PIOx_x), but no mention of whether writing 0 will cause problems, and the rest seem to be 0 on reset (not a problem).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So in some cases avoiding the reserved bits in registers by using byte access could be beneficial (maybe not that many). In the case of something like PDRUNCFG, it would usually make no difference since setting/clearing individual bits (Read-Modify-Write) would be the normal way to access these anyway (unless you set all bits as needed in one write).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, can these registers be accessed on a byte level, and what is the story on writing 0's to reserved bits that are not 0 at reset (that show no required set value in datasheet description)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;update-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears reading/writing to peripheral registers does work with byte access. I only tested a few, but reading/writing bytes on some of these works ok (at least no hard faults, and results were as expected). I don't know if this holds true for AHB, though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jun 2016 01:15:01 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-16T01:15:01Z</dc:date>
    <item>
      <title>Peripheral register access, RESERVED registers</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581692#M25059</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by curtvm on Sun Nov 07 08:12:03 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LPC11xx manual&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.2 Memory map-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;All peripheral register addresses are 32-bit word aligned regardless of their size. An implication of this is that word and half-word registers must be accessed all at once. For example, it is not possible to read or write the upper byte of a word register separately.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;--------------&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am unclear as to what this means. It seems to me the 'implication' is that since these registers are word aligned, they CAN be accessed as a word. The Cortex M0 requires word alignment for word access, halfword alignment for halfword access, and of course no alignment for byte access.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;These registers cannot be accessed on a byte level?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The other part of this, is RESERVED bits in registers. Some have specific values that need to be written (like PDRUNCFG), some have non-zero reset values (like IOCON_PIOx_x), but no mention of whether writing 0 will cause problems, and the rest seem to be 0 on reset (not a problem).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So in some cases avoiding the reserved bits in registers by using byte access could be beneficial (maybe not that many). In the case of something like PDRUNCFG, it would usually make no difference since setting/clearing individual bits (Read-Modify-Write) would be the normal way to access these anyway (unless you set all bits as needed in one write).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, can these registers be accessed on a byte level, and what is the story on writing 0's to reserved bits that are not 0 at reset (that show no required set value in datasheet description)?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;update-&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;It appears reading/writing to peripheral registers does work with byte access. I only tested a few, but reading/writing bytes on some of these works ok (at least no hard faults, and results were as expected). I don't know if this holds true for AHB, though.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:15:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581692#M25059</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Peripheral register access, RESERVED registers</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581693#M25060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by CodeRedSupport on Mon Nov 08 14:52:28 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend using a read/modify/write strategy to ensure that you basically only change the bits you actually want to change. The following example code (taken from &lt;/SPAN&gt;&lt;A href="http://" rel="nofollow noopener noreferrer" target="_blank"&gt;http://support.code-red-tech.com/CodeRedWiki/Support4CMSIS&lt;/A&gt;&lt;SPAN&gt;) shows this being done....&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;&amp;nbsp;&amp;nbsp;&amp;nbsp; #include "LPC17xx.h"

&amp;nbsp;&amp;nbsp;&amp;nbsp; // PCADC / PCAD
&amp;nbsp;&amp;nbsp;&amp;nbsp; #define ADC_POWERON (1 &amp;lt;&amp;lt; 12)

&amp;nbsp;&amp;nbsp;&amp;nbsp; #define PCLK_ADC 24
&amp;nbsp;&amp;nbsp;&amp;nbsp; #define PCLK_ADC_MASK (3 &amp;lt;&amp;lt; 24)

&amp;nbsp;&amp;nbsp;&amp;nbsp; // AD0.0 - P0.23, PINSEL1 [15:14] = 01
&amp;nbsp;&amp;nbsp;&amp;nbsp; #define SELECT_ADC0 (0x1&amp;lt;&amp;lt;14)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :
&amp;nbsp;&amp;nbsp;&amp;nbsp; // Turn on power to ADC block
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SC-&amp;gt;PCONP |=&amp;nbsp; ADC_POWERON;

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Turn on ADC peripheral clock
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SC-&amp;gt;PCLKSEL0 &amp;amp;= ~(PCLK_ADC_MASK);
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_SC-&amp;gt;PCLKSEL0 |=&amp;nbsp; (3 &amp;lt;&amp;lt; PCLK_ADC);

&amp;nbsp;&amp;nbsp;&amp;nbsp; // Set P0.23 to AD0.0 in PINSEL1
&amp;nbsp;&amp;nbsp;&amp;nbsp; LPC_PINCON-&amp;gt;PINSEL1 |= SELECT_ADC0;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; :&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;CodeRedSupport&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:15:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581693#M25060</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Peripheral register access, RESERVED registers</title>
      <link>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581694#M25061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by curtvm on Mon Nov 08 15:48:39 MST 2010&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;That would be the smart thing to do, it seems.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although it does look like there may be cases where that may cause problems if one is not careful. As in something like U0IER where bits 31:10 are described as 'Reserved, user software should not write ones to reserved bits. The value read from a reserved bit is not defined.'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If the read of those bits is not defined, I suppose the possibility exists that the read could produce 1's, which then will be written. So in this case, I guess those bits need to be cleared also (Read-Modify-Modify-Write).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;So, I guess in summary, these registers can be accessed at a byte level if needed (to avoid reserved bits for example, although it may not be worth the trouble). Reserved bits need to be written as instructed, if instructed in the register description. Reserved bits without any specific instructions, I guess the rule is nobody really knows, so just read-modify-write to avoid any surprises or potential strange problems.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jun 2016 01:15:02 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPCXpresso-IDE/Peripheral-register-access-RESERVED-registers/m-p/581694#M25061</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-16T01:15:02Z</dc:date>
    </item>
  </channel>
</rss>

