<?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>LPC MicrocontrollersのトピックRe: LPC54102J512 SPI - how do I know when transfer is complete?</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54102J512-SPI-how-do-I-know-when-transfer-is-complete/m-p/1575875#M51148</link>
    <description>&lt;P&gt;This turned out to be a bad processor. &amp;nbsp;After a while, the clock signal from the SPI1 module had a 1 volt DC offset. &amp;nbsp;I got a new board and everything works.&lt;/P&gt;</description>
    <pubDate>Fri, 30 Dec 2022 22:04:52 GMT</pubDate>
    <dc:creator>JBM</dc:creator>
    <dc:date>2022-12-30T22:04:52Z</dc:date>
    <item>
      <title>LPC54102J512 SPI - how do I know when transfer is complete?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54102J512-SPI-how-do-I-know-when-transfer-is-complete/m-p/1575668#M51136</link>
      <description>&lt;P&gt;I am developing an application in MCUXpresso for the LPC54102 processor. &amp;nbsp;I am using the SDK and the configuration tools to setup SPI. &amp;nbsp;&lt;/P&gt;&lt;P&gt;The processor has to communicate with display (four wire SPI) connected to SPI1. &amp;nbsp;Additionally, there is a slave select (0), and a D/C# pin on the display. &amp;nbsp;The D/C# is used to denote data or commands. &amp;nbsp;Low for commands and high for data. &amp;nbsp;This pin is checked by the display on the 8th bit of data in each byte transmitted.&lt;/P&gt;&lt;P&gt;The problem I've having is that when I call&amp;nbsp;SPI_MasterTransferBlocking(), I see all the data, but the function returns before the last few bits are transmitted to the display. &amp;nbsp;As I set the D/C# pin (to get ready for data) high after the function returns, the display sees it go high and the last command is interpreted as data instead of a command. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to know that all data has been transmitted? &amp;nbsp;I have tried checking the the END TRANSFER and MSTIDLE bits in the SPI-&amp;gt;STAT register. &amp;nbsp;From the description, it would seem that the MSTIDLE bit is what I want, but it appears to not be set when the&amp;nbsp;SPI_MasterTransferBlocking() function returns.&lt;/P&gt;&lt;P&gt;I have also tried adjusting the SPI delays, but no luck there either.&lt;/P&gt;&lt;P&gt;I can fake it by adding a loop (counting to 100 seems to do it), but that's kind of a hack as far as I'm concerned - it makes me think I'm missing something.&lt;/P&gt;&lt;P&gt;How is this typically done with this processor?&lt;/P&gt;&lt;P&gt;Here's the SPI configuration:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;const spi_master_config_t SPI1_config = {
  .polarity = kSPI_ClockPolarityActiveHigh,
  .phase = kSPI_ClockPhaseFirstEdge,
  .direction = kSPI_MsbFirst,
  .baudRate_Bps = 2000000UL,
  .dataWidth = kSPI_Data8Bits,
  .sselNum = kSPI_Ssel0,
  .sselPol = kSPI_SpolActiveAllLow,
  .enableLoopback = false,
  .enableMaster = true,
  .fifoConfig = {
    .enableTxFifo = false,
    .txFifoSize = 1U,
    .txFifoThreshold = 0U,
    .enableRxFifo = false,
    .rxFifoSize = 0U,
    .rxFifoThreshold = 0U
  },
  .delayConfig = {
    .preDelay = 0U,
    .postDelay = 0U,
    .frameDelay = 0U,
    .transferDelay = 0U
  }
};
spi_master_handle_t SPI1_handle;

static void SPI1_init(void) {
  /* Initialization function */
  SPI_MasterInit(SPI1_PERIPHERAL, &amp;amp;SPI1_config, SPI1_CLOCK_SOURCE);
  /* Interrupt vector SPI1_IRQn priority settings in the NVIC. */
  NVIC_SetPriority(SPI1_IRQN, SPI1_IRQ_PRIORITY);
  SPI_MasterTransferCreateHandle(SPI1_PERIPHERAL, &amp;amp;SPI1_handle, display_hardware_master_transfer_callback, NULL);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I use the callback for non-blocking calls so it is not called here.&lt;/P&gt;&lt;P&gt;Another issue is that the slave select pin does not appear to be toggling at all. &amp;nbsp;It is constantly low.&lt;/P&gt;&lt;P&gt;Here's the generated configuration for that pin:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;    IOCON-&amp;gt;PIO[1][5] = ((IOCON-&amp;gt;PIO[1][5] &amp;amp;
                         /* Mask bits to zero which are setting */
                         (~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK)))

                        /* Selects pin function.
                         * : PORT15 (pin 19) is configured as SPI1_SSEL0. */
                        | IOCON_PIO_FUNC(PIO15_FUNC_ALT2)

                        /* Selects function mode (on-chip pull-up/pull-down resistor control).
                         * : Inactive.
                         * Inactive (no pull-down/pull-up resistor enabled). */
                        | IOCON_PIO_MODE(PIO15_MODE_INACTIVE)

                        /* Select Analog/Digital mode.
                         * : Digital mode. */
                        | IOCON_PIO_DIGIMODE(PIO15_DIGIMODE_DIGITAL));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see any issue with the pin configuration.&lt;/P&gt;&lt;P&gt;I have checked continuity from the processor to the display (custom hardware) and it is connected.&lt;/P&gt;&lt;P&gt;Unfortunately I can't post code.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 19:00:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54102J512-SPI-how-do-I-know-when-transfer-is-complete/m-p/1575668#M51136</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2022-12-30T19:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC54102J512 SPI - how do I know when transfer is complete?</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54102J512-SPI-how-do-I-know-when-transfer-is-complete/m-p/1575875#M51148</link>
      <description>&lt;P&gt;This turned out to be a bad processor. &amp;nbsp;After a while, the clock signal from the SPI1 module had a 1 volt DC offset. &amp;nbsp;I got a new board and everything works.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2022 22:04:52 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC54102J512-SPI-how-do-I-know-when-transfer-is-complete/m-p/1575875#M51148</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2022-12-30T22:04:52Z</dc:date>
    </item>
  </channel>
</rss>

