<?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 Register writes - 32 bits at a time only? in i.MX Processors</title>
    <link>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420923#M63457</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a bare metal project and was configuring the PWM peripheral when I ran across a strange bug.&amp;nbsp; I'm using the imx6 bare metal SDK register definitions, which are produced by the IOMUX tool.&amp;nbsp; Every time I wrote HW_PWM_PWMSAR(instance).B.SAMPLE, it wouldn't take effect.&amp;nbsp; I would read it back and it was still the old value.&amp;nbsp; (This is how it's done in the PWM example in the SDK, so beware)&amp;nbsp; Looking through the assembly, the compiler was generating a strh which only writes the lower 16 bits of the register - exactly what it should do given the register is defined as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef union _hw_pwm_pwmsar&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reg32_t U;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct _hw_pwm_pwmsar_bitfields&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned SAMPLE : 16; //!&amp;lt; [15:0] Sample Value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned RESERVED0 : 16; //!&amp;lt; [31:16] These are reserved bits and writing a value will not affect the functionality of PWM and are always read as zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } B;&lt;/P&gt;&lt;P&gt;} hw_pwm_pwmsar_t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I switched to using HW_PWM_PWMSAR(instance).U which winds up doing a str into the address, writing all 32 bits and now it works just fine.&amp;nbsp; So if you write 16 bits of the register, it doesn't work.&amp;nbsp; If you write all 32 bits, it does.&amp;nbsp; This makes me very wary of using the structure bitfields, which are used all over the place in the IOMUX register definitions.&amp;nbsp; Is this an error in the PWM hardware specifically or do all registers need to be written 32 bits at a time? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 17 Jul 2015 18:21:41 GMT</pubDate>
    <dc:creator>elijahbrown</dc:creator>
    <dc:date>2015-07-17T18:21:41Z</dc:date>
    <item>
      <title>Register writes - 32 bits at a time only?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420923#M63457</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm doing a bare metal project and was configuring the PWM peripheral when I ran across a strange bug.&amp;nbsp; I'm using the imx6 bare metal SDK register definitions, which are produced by the IOMUX tool.&amp;nbsp; Every time I wrote HW_PWM_PWMSAR(instance).B.SAMPLE, it wouldn't take effect.&amp;nbsp; I would read it back and it was still the old value.&amp;nbsp; (This is how it's done in the PWM example in the SDK, so beware)&amp;nbsp; Looking through the assembly, the compiler was generating a strh which only writes the lower 16 bits of the register - exactly what it should do given the register is defined as:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;typedef union _hw_pwm_pwmsar&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; reg32_t U;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; struct _hw_pwm_pwmsar_bitfields&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned SAMPLE : 16; //!&amp;lt; [15:0] Sample Value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; unsigned RESERVED0 : 16; //!&amp;lt; [31:16] These are reserved bits and writing a value will not affect the functionality of PWM and are always read as zero.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; } B;&lt;/P&gt;&lt;P&gt;} hw_pwm_pwmsar_t;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I switched to using HW_PWM_PWMSAR(instance).U which winds up doing a str into the address, writing all 32 bits and now it works just fine.&amp;nbsp; So if you write 16 bits of the register, it doesn't work.&amp;nbsp; If you write all 32 bits, it does.&amp;nbsp; This makes me very wary of using the structure bitfields, which are used all over the place in the IOMUX register definitions.&amp;nbsp; Is this an error in the PWM hardware specifically or do all registers need to be written 32 bits at a time? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 18:21:41 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420923#M63457</guid>
      <dc:creator>elijahbrown</dc:creator>
      <dc:date>2015-07-17T18:21:41Z</dc:date>
    </item>
    <item>
      <title>Re: Register writes - 32 bits at a time only?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420924#M63458</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;HI Elijah&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you are right PWM registers should be accessed as 32 bit&lt;/P&gt;&lt;P&gt;registers only:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="1.jpg"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/54577i379D184814E377E2/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.jpg" alt="1.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;P&gt;igor&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;P&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 19 Jul 2015 00:27:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420924#M63458</guid>
      <dc:creator>igorpadykov</dc:creator>
      <dc:date>2015-07-19T00:27:29Z</dc:date>
    </item>
    <item>
      <title>Re: Register writes - 32 bits at a time only?</title>
      <link>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420925#M63459</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok.&amp;nbsp; The bare metal SDK should be fixed then, there are tons of 32 bit registers being accessed this way.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 20 Jul 2015 22:11:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/i-MX-Processors/Register-writes-32-bits-at-a-time-only/m-p/420925#M63459</guid>
      <dc:creator>elijahbrown</dc:creator>
      <dc:date>2015-07-20T22:11:33Z</dc:date>
    </item>
  </channel>
</rss>

