<?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 Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master) in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206184#M43439</link>
    <description>&lt;P&gt;Hi Alice&lt;/P&gt;&lt;P&gt;TXDAT is a 32bit register,&amp;nbsp;&lt;/P&gt;&lt;P&gt;what could be the difference btw:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TXDAT = 0xFF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TXDAT = (uint16_t)(0xFF) = 0x00FF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am not so clear why casting does its job there? I might be missing something...&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
    <pubDate>Mon, 04 Jan 2021 15:08:37 GMT</pubDate>
    <dc:creator>Babycat</dc:creator>
    <dc:date>2021-01-04T15:08:37Z</dc:date>
    <item>
      <title>LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1205170#M43399</link>
      <description>&lt;P&gt;Hello Everyone&lt;/P&gt;&lt;P&gt;I am playing around with SPI on LPCXpresso802 board. Everything seems OK but there is an unclear code that I try to understand but I could not configure out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is in example:&amp;nbsp;&lt;EM&gt;&lt;STRONG&gt;lpcxpresso802_spi_interrupt_master.&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;As the Data transfer Length is setup with 8 bits width, so RXDAT and TXDAT will be handle each single byte. but why does it need casting type (uint16_t) as below?&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have connected to external SPI chip (AS3933), if no casting type, then read command sometime did not get right value.&lt;/P&gt;&lt;P&gt;Here is the origial interrupt code&lt;/P&gt;&lt;P&gt;void SPI_MASTER_IRQHandler(void)&lt;BR /&gt;{&lt;BR /&gt;/* Check if data is ready in RX register. */&lt;BR /&gt;if ((SPI_GetStatusFlags(EXAMPLE_SPI_MASTER) &amp;amp; kSPI_RxReadyFlag))&lt;BR /&gt;{&lt;BR /&gt;rxBuffer[BUFFER_SIZE - rxIndex] = SPI_ReadData(EXAMPLE_SPI_MASTER);&lt;BR /&gt;rxIndex--;&lt;BR /&gt;}&lt;BR /&gt;/* Write data to TX regsiter if TX register is ready. */&lt;BR /&gt;if ((SPI_GetStatusFlags(EXAMPLE_SPI_MASTER) &amp;amp; kSPI_TxReadyFlag) &amp;amp;&amp;amp; (txIndex != 0U))&lt;BR /&gt;{&lt;BR /&gt;/* If this is the last byte to send. */&lt;BR /&gt;if (1U == txIndex)&lt;BR /&gt;{&lt;BR /&gt;/* Add end of transfer configuration. */&lt;BR /&gt;SPI_WriteConfigFlags(EXAMPLE_SPI_MASTER, kSPI_EndOfTransfer);&lt;BR /&gt;SPI_WriteData(EXAMPLE_SPI_MASTER, txBuffer[BUFFER_SIZE - txIndex]);&lt;BR /&gt;}&lt;BR /&gt;else&lt;BR /&gt;{&lt;BR /&gt;SPI_WriteData(EXAMPLE_SPI_MASTER, &lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;(uint16_t)&lt;/STRONG&gt;&lt;/FONT&gt;(txBuffer[BUFFER_SIZE - txIndex]));&lt;BR /&gt;}&lt;BR /&gt;txIndex--;&lt;BR /&gt;}&lt;BR /&gt;/* If no data to be transferred, disable the interrupt. */&lt;BR /&gt;if ((txIndex == 0U) &amp;amp;&amp;amp; (rxIndex == 0U))&lt;BR /&gt;{&lt;BR /&gt;slaveFinished = true;&lt;BR /&gt;SPI_DisableInterrupts(EXAMPLE_SPI_MASTER, kSPI_RxReadyInterruptEnable);&lt;BR /&gt;}&lt;BR /&gt;__DSB();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Dec 2020 06:48:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1205170#M43399</guid>
      <dc:creator>Babycat</dc:creator>
      <dc:date>2020-12-30T06:48:06Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1205853#M43428</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="UserName lia-user-name lia-user-rank-Contributor-I lia-component-message-view-widget-author-username"&gt;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" style="color: #333f48;" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/181850" target="_self"&gt;&lt;SPAN class=""&gt;Babycat&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;Because the DATA in SPI transmitter data register is 16 bits, so no matter the &lt;/P&gt;
&lt;P&gt;data transfer length is, we need (uint16_t) as you said.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="3456.jpg" style="width: 999px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/133805i9D5892E717FDCAC2/image-size/large?v=v2&amp;amp;px=999" role="button" title="3456.jpg" alt="3456.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 07:01:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1205853#M43428</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-01-04T07:01:48Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206003#M43432</link>
      <description>&lt;P&gt;Hi Yang&lt;/P&gt;&lt;P&gt;Thanks for your reply,&amp;nbsp;&lt;/P&gt;&lt;P&gt;then the question is, why dont we cast it in the if clause?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;if (1U == txIndex)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;/* Add end of transfer configuration. */&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPI_WriteConfigFlags(EXAMPLE_SPI_MASTER, kSPI_EndOfTransfer);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPI_WriteData(EXAMPLE_SPI_MASTER, &lt;FONT color="#FF0000"&gt;txBuffer[BUFFER_SIZE - txIndex])&lt;/FONT&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SPI_WriteData(EXAMPLE_SPI_MASTER,&amp;nbsp;&lt;/SPAN&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;(uint16_t)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN&gt;(txBuffer[BUFFER_SIZE - txIndex]));&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 08:54:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206003#M43432</guid>
      <dc:creator>Babycat</dc:creator>
      <dc:date>2021-01-04T08:54:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206020#M43434</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think it will be ok if we also cast it here&amp;nbsp; &lt;SPAN&gt;&lt;FONT color="#FF6600"&gt;&lt;STRONG&gt;(uint16_t)(&lt;/STRONG&gt;&lt;/FONT&gt; &lt;FONT color="#FF0000"&gt;txBuffer[BUFFER_SIZE - txIndex]).&amp;nbsp; &lt;/FONT&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;This is the last byte to send, so there should no error even though not cast it.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Alice&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 09:06:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206020#M43434</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-01-04T09:06:30Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206184#M43439</link>
      <description>&lt;P&gt;Hi Alice&lt;/P&gt;&lt;P&gt;TXDAT is a 32bit register,&amp;nbsp;&lt;/P&gt;&lt;P&gt;what could be the difference btw:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TXDAT = 0xFF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;TXDAT = (uint16_t)(0xFF) = 0x00FF&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I am not so clear why casting does its job there? I might be missing something...&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 04 Jan 2021 15:08:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206184#M43439</guid>
      <dc:creator>Babycat</dc:creator>
      <dc:date>2021-01-04T15:08:37Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206352#M43446</link>
      <description>&lt;P&gt;Hello &lt;SPAN class="UserName lia-user-name lia-user-rank-Contributor-I lia-component-message-view-widget-author-username"&gt;&lt;A id="link_12" class="lia-link-navigation lia-page-link lia-user-name-link" style="color: #333f48;" href="https://community.nxp.com/t5/user/viewprofilepage/user-id/181850" target="_self"&gt;&lt;SPAN class=""&gt;Babycat&lt;/SPAN&gt;&lt;/A&gt;&lt;/SPAN&gt;,&lt;/P&gt;
&lt;P&gt;- TXDAT is 32 bits register, while the 31:16 are reserved, only 15:0 is&amp;nbsp; DATA part.&lt;/P&gt;
&lt;P&gt;-"what could be the difference btw:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TXDAT = 0xFF&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;TXDAT = (uint16_t)(0xFF) = 0x00FF&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;"&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;To some machine, when there is no casting, maybe add random data in 15:8, for example 0x10FF, not 0X00FF.&lt;/P&gt;
&lt;P&gt;So for r&lt;SPAN class="VIiyi"&gt;&lt;SPAN class="JLqJ4b ChMk0b" data-language-for-alternatives="en" data-language-to-translate-into="zh-CN" data-phrase-index="0"&gt;&lt;SPAN&gt;igorous&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;，all the data put to DATA need casting to 16 bits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 01:47:39 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206352#M43446</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2021-01-05T01:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: LPC802 SPI Code (lpcxpresso802_spi_interrupt_master)</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206497#M43450</link>
      <description>&lt;P&gt;&amp;nbsp;Hi Alice&lt;/P&gt;&lt;P&gt;Oh, I understood. I did not know about that, I thought C complier will auto add that extra 00 as its job supposed to.&lt;/P&gt;&lt;P&gt;by the way, in case TXDAT =&amp;nbsp;&lt;SPAN&gt;0x10FF. If I configured Len = 8 bits, MSB first.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Which byte will be sent out, 10 or FF?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Jan 2021 05:52:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC802-SPI-Code-lpcxpresso802-spi-interrupt-master/m-p/1206497#M43450</guid>
      <dc:creator>Babycat</dc:creator>
      <dc:date>2021-01-05T05:52:27Z</dc:date>
    </item>
  </channel>
</rss>

