<?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>S32KのトピックRe: Problem with setting SPI TCR register</title>
    <link>https://community.nxp.com/t5/S32K/Problem-with-setting-SPI-TCR-register/m-p/1062644#M7162</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/trunghieudon@geotab.com"&gt;trunghieudon@geotab.com&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;The Transmit Command Register (TCR) is not an ordinary register, it is a FIFO.&lt;/P&gt;&lt;P&gt;Please take a look at the description of the register in the RM.&lt;/P&gt;&lt;P&gt;Section 51.3.1.15.2 Function&lt;/P&gt;&lt;P&gt;If you are using several commands, it is better to just store them as constants and write the commands as 32b words without reading a modifying the value in the register.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Aug 2020 09:42:45 GMT</pubDate>
    <dc:creator>danielmartynek</dc:creator>
    <dc:date>2020-08-25T09:42:45Z</dc:date>
    <item>
      <title>Problem with setting SPI TCR register</title>
      <link>https://community.nxp.com/t5/S32K/Problem-with-setting-SPI-TCR-register/m-p/1062643#M7161</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I wrote a driver with a goal to access all Spi instances and implemented macro definitions so that it can be used easily in the future. I&amp;nbsp;used&amp;nbsp;these macros to initialize one of my&amp;nbsp;SPI channel. It worked well for everything but somehow for the TCR register, it only updates the &lt;STRONG&gt;last&amp;nbsp;&lt;/STRONG&gt;register write and it does not update right away. It updates when it escapes the function. Weird! Consider the following example for better explanation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The macros:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#define spi_SetClkPrescale(bInstance, bPrescaler) (pSpiRegisters[bInstance]-&amp;gt;TCR = (pSpiRegisters[bInstance]-&amp;gt;TCR &amp;amp; ~LPSPI_TCR_PRESCALE_MASK) | LPSPI_TCR_PRESCALE(bPrescaler))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#define spi_ConfigurePcs(bInstance, bIndex) (pSpiRegisters[bInstance]-&amp;gt;TCR = (pSpiRegisters[bInstance]-&amp;gt;TCR &amp;amp; ~LPSPI_TCR_PCS_MASK) | LPSPI_TCR_PCS(bIndex))&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;#define spi_SetFrameSize(bInstance,bSize) (pSpiRegisters[bInstance]-&amp;gt;TCR = (pSpiRegisters[bInstance]-&amp;gt;TCR &amp;amp; ~LPSPI_TCR_FRAMESZ_MASK) | LPSPI_TCR_FRAMESZ(bSize))&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Initialize SPI&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;spi_SetFrameSize(1, 7);&lt;BR /&gt; spi_ConfigurePcs(1, 0);&lt;BR /&gt; spi_SetClkPrescale(1, 2);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This will then only updates the Prescaler and not the frame size nor the PCS.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This however works for other registers and it updates everything.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached a simplified module to save work for anyone trying to help me out. In this example, the CCR register updates everything (Line 91-94) while the TCR only updates the final write (Line 88) and discards the previous.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Aug 2020 21:20:09 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Problem-with-setting-SPI-TCR-register/m-p/1062643#M7161</guid>
      <dc:creator>trunghieudon</dc:creator>
      <dc:date>2020-08-24T21:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with setting SPI TCR register</title>
      <link>https://community.nxp.com/t5/S32K/Problem-with-setting-SPI-TCR-register/m-p/1062644#M7162</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A class="jx-jive-macro-user" href="https://community.nxp.com/people/trunghieudon@geotab.com"&gt;trunghieudon@geotab.com&lt;/A&gt;,&lt;/P&gt;&lt;P&gt;The Transmit Command Register (TCR) is not an ordinary register, it is a FIFO.&lt;/P&gt;&lt;P&gt;Please take a look at the description of the register in the RM.&lt;/P&gt;&lt;P&gt;Section 51.3.1.15.2 Function&lt;/P&gt;&lt;P&gt;If you are using several commands, it is better to just store them as constants and write the commands as 32b words without reading a modifying the value in the register.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Aug 2020 09:42:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Problem-with-setting-SPI-TCR-register/m-p/1062644#M7162</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2020-08-25T09:42:45Z</dc:date>
    </item>
  </channel>
</rss>

