<?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のトピックlpSPI0 Configuration using polling method - S32K144-Q100</title>
    <link>https://community.nxp.com/t5/S32K/lpSPI0-Configuration-using-polling-method-S32K144-Q100/m-p/1627927#M21863</link>
    <description>&lt;P&gt;Here is the copy of the init code plz.&lt;/P&gt;&lt;P&gt;void LPSPI0_init_master(void) {&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_LPSPI0_INDEX] = 0; /* Disable clocks to modify PCS ( default) */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_LPSPI0_INDEX] = 0xC6000000; /* Enable PCS=SPLL_DIV2 (40 MHz func'l clock) */&lt;BR /&gt;LPSPI0-&amp;gt;CR = 0x00000000; /* Disable module for configuration */&lt;BR /&gt;LPSPI0-&amp;gt;IER = 0x00000000; /* Interrupts not used */&lt;BR /&gt;LPSPI0-&amp;gt;DER = 0x00000000; /* DMA not used */&lt;BR /&gt;LPSPI0-&amp;gt;CFGR0 = 0x00000000; /* Defaults: */&lt;BR /&gt;/* RDM0=0: rec'd data to FIFO as normal */&lt;BR /&gt;/* CIRFIFO=0; Circular FIFO is disabled */&lt;BR /&gt;/* HRSEL, HRPOL, HREN=0: Host request disabled */&lt;BR /&gt;LPSPI0-&amp;gt;CFGR1 = 0x00000001; /* Configurations: master mode*/&lt;BR /&gt;/* PCSCFG=0: PCS[3:2] are enabled */&lt;BR /&gt;/* OUTCFG=0: Output data retains last value when CS negated */&lt;BR /&gt;/* PINCFG=0: SIN is input, SOUT is output */&lt;BR /&gt;/* MATCFG=0: Match disabled */&lt;BR /&gt;/* PCSPOL=0: PCS is active low */&lt;BR /&gt;/* NOSTALL=0: Stall if Tx FIFO empty or Rx FIFO full */&lt;BR /&gt;/* AUTOPCS=0: does not apply for master mode */&lt;BR /&gt;/* SAMPLE=0: input data sampled on SCK edge */&lt;BR /&gt;/* MASTER=1: Master mode */&lt;BR /&gt;LPSPI0-&amp;gt;TCR = 0x5100001F; /* Transmit cmd: PCS1, 32bits, prescale func'l clk by 4. */&lt;BR /&gt;/* CPOL=0: SCK inactive state is low */&lt;BR /&gt;/* CPHA=1: Change data on SCK lead'g, capture on trail'g edge*/&lt;BR /&gt;/* PRESCALE=2: Functional clock divided by 2**2 = 4 */&lt;BR /&gt;/* PCS=3: Transfer using PCS3 */&lt;BR /&gt;/* LSBF=0: Data is transferred MSB first */&lt;BR /&gt;/* BYSW=0: Byte swap disabled */&lt;BR /&gt;/* CONT, CONTC=0: Continuous transfer disabled */&lt;BR /&gt;/* RXMSK=0: Normal transfer: rx data stored in rx FIFO */&lt;BR /&gt;/* TXMSK=0: Normal transfer: data loaded from tx FIFO */&lt;BR /&gt;/* WIDTH=0: Single bit transfer */&lt;BR /&gt;/* FRAMESZ=15: # bits in frame = 31+1=32 */&lt;BR /&gt;LPSPI0-&amp;gt;CCR = 0x04090808; /* Clk dividers based on prescaled func'l clk of 100 nsec */&lt;BR /&gt;/* SCKPCS=4: SCK to PCS delay = 4+1 = 5 (500 nsec) */&lt;BR /&gt;/* PCSSCK=4: PCS to SCK delay = 9+1 = 10 (1 usec) */&lt;BR /&gt;/* DBT=8: Delay between Transfers = 8+2 = 10 (1 usec) */&lt;BR /&gt;/* SCKDIV=8: SCK divider =8+2 = 10 (1 usec: 1 MHz baud rate) */&lt;BR /&gt;LPSPI0-&amp;gt;FCR = 0x00000003; /* RXWATER=0: Rx flags set when Rx FIFO &amp;gt;0 */&lt;BR /&gt;/* TXWATER=3: Tx flags set when Tx FIFO &amp;lt;= 3 */&lt;/P&gt;&lt;P&gt;LPSPI0-&amp;gt;CR = 0x00000009; /* Enable module for operation */&lt;BR /&gt;/* DBGEN=1: module enabled in debug mode */&lt;BR /&gt;/* DOZEN=0: module enabled in Doze mode */&lt;BR /&gt;/* RST=0: Master logic not reset */&lt;BR /&gt;/* MEN=1: Module is enabled */&lt;/P&gt;&lt;P&gt;I would like to transmit this code using polling method. Please help me out on the following.&lt;/P&gt;&lt;P&gt;1. What condition to check before transmit data (updating FIFO Tx buffer)&lt;/P&gt;&lt;P&gt;2. What is the condition to check when Data Transmission is completed&lt;/P&gt;&lt;P&gt;BTW Will this code work please?&lt;/P&gt;&lt;P&gt;void LPSPI0_transmit_32bits(uint32_t send) {&lt;BR /&gt;while((LPSPI0-&amp;gt;SR &amp;amp; LPSPI_SR_TDF_MASK)&amp;gt;&amp;gt;LPSPI_SR_TDF_SHIFT == 1);&lt;BR /&gt;/* Wait for Tx FIFO available */&lt;BR /&gt;LPSPI0-&amp;gt;TDR = send; /* Transmit data */&lt;BR /&gt;LPSPI0-&amp;gt;SR |= LPSPI_SR_TDF_MASK; /* Set TDF flag */&lt;BR /&gt;PTD-&amp;gt;PTOR |= 1&amp;lt;&amp;lt;0; /* Toggle output on port D0 (blue LED) */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that S32K config tool does not support polling method. How to configure the polling method and handle this please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Apr 2023 21:24:47 GMT</pubDate>
    <dc:creator>SivakumarMariappan</dc:creator>
    <dc:date>2023-04-04T21:24:47Z</dc:date>
    <item>
      <title>lpSPI0 Configuration using polling method - S32K144-Q100</title>
      <link>https://community.nxp.com/t5/S32K/lpSPI0-Configuration-using-polling-method-S32K144-Q100/m-p/1627927#M21863</link>
      <description>&lt;P&gt;Here is the copy of the init code plz.&lt;/P&gt;&lt;P&gt;void LPSPI0_init_master(void) {&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_LPSPI0_INDEX] = 0; /* Disable clocks to modify PCS ( default) */&lt;BR /&gt;PCC-&amp;gt;PCCn[PCC_LPSPI0_INDEX] = 0xC6000000; /* Enable PCS=SPLL_DIV2 (40 MHz func'l clock) */&lt;BR /&gt;LPSPI0-&amp;gt;CR = 0x00000000; /* Disable module for configuration */&lt;BR /&gt;LPSPI0-&amp;gt;IER = 0x00000000; /* Interrupts not used */&lt;BR /&gt;LPSPI0-&amp;gt;DER = 0x00000000; /* DMA not used */&lt;BR /&gt;LPSPI0-&amp;gt;CFGR0 = 0x00000000; /* Defaults: */&lt;BR /&gt;/* RDM0=0: rec'd data to FIFO as normal */&lt;BR /&gt;/* CIRFIFO=0; Circular FIFO is disabled */&lt;BR /&gt;/* HRSEL, HRPOL, HREN=0: Host request disabled */&lt;BR /&gt;LPSPI0-&amp;gt;CFGR1 = 0x00000001; /* Configurations: master mode*/&lt;BR /&gt;/* PCSCFG=0: PCS[3:2] are enabled */&lt;BR /&gt;/* OUTCFG=0: Output data retains last value when CS negated */&lt;BR /&gt;/* PINCFG=0: SIN is input, SOUT is output */&lt;BR /&gt;/* MATCFG=0: Match disabled */&lt;BR /&gt;/* PCSPOL=0: PCS is active low */&lt;BR /&gt;/* NOSTALL=0: Stall if Tx FIFO empty or Rx FIFO full */&lt;BR /&gt;/* AUTOPCS=0: does not apply for master mode */&lt;BR /&gt;/* SAMPLE=0: input data sampled on SCK edge */&lt;BR /&gt;/* MASTER=1: Master mode */&lt;BR /&gt;LPSPI0-&amp;gt;TCR = 0x5100001F; /* Transmit cmd: PCS1, 32bits, prescale func'l clk by 4. */&lt;BR /&gt;/* CPOL=0: SCK inactive state is low */&lt;BR /&gt;/* CPHA=1: Change data on SCK lead'g, capture on trail'g edge*/&lt;BR /&gt;/* PRESCALE=2: Functional clock divided by 2**2 = 4 */&lt;BR /&gt;/* PCS=3: Transfer using PCS3 */&lt;BR /&gt;/* LSBF=0: Data is transferred MSB first */&lt;BR /&gt;/* BYSW=0: Byte swap disabled */&lt;BR /&gt;/* CONT, CONTC=0: Continuous transfer disabled */&lt;BR /&gt;/* RXMSK=0: Normal transfer: rx data stored in rx FIFO */&lt;BR /&gt;/* TXMSK=0: Normal transfer: data loaded from tx FIFO */&lt;BR /&gt;/* WIDTH=0: Single bit transfer */&lt;BR /&gt;/* FRAMESZ=15: # bits in frame = 31+1=32 */&lt;BR /&gt;LPSPI0-&amp;gt;CCR = 0x04090808; /* Clk dividers based on prescaled func'l clk of 100 nsec */&lt;BR /&gt;/* SCKPCS=4: SCK to PCS delay = 4+1 = 5 (500 nsec) */&lt;BR /&gt;/* PCSSCK=4: PCS to SCK delay = 9+1 = 10 (1 usec) */&lt;BR /&gt;/* DBT=8: Delay between Transfers = 8+2 = 10 (1 usec) */&lt;BR /&gt;/* SCKDIV=8: SCK divider =8+2 = 10 (1 usec: 1 MHz baud rate) */&lt;BR /&gt;LPSPI0-&amp;gt;FCR = 0x00000003; /* RXWATER=0: Rx flags set when Rx FIFO &amp;gt;0 */&lt;BR /&gt;/* TXWATER=3: Tx flags set when Tx FIFO &amp;lt;= 3 */&lt;/P&gt;&lt;P&gt;LPSPI0-&amp;gt;CR = 0x00000009; /* Enable module for operation */&lt;BR /&gt;/* DBGEN=1: module enabled in debug mode */&lt;BR /&gt;/* DOZEN=0: module enabled in Doze mode */&lt;BR /&gt;/* RST=0: Master logic not reset */&lt;BR /&gt;/* MEN=1: Module is enabled */&lt;/P&gt;&lt;P&gt;I would like to transmit this code using polling method. Please help me out on the following.&lt;/P&gt;&lt;P&gt;1. What condition to check before transmit data (updating FIFO Tx buffer)&lt;/P&gt;&lt;P&gt;2. What is the condition to check when Data Transmission is completed&lt;/P&gt;&lt;P&gt;BTW Will this code work please?&lt;/P&gt;&lt;P&gt;void LPSPI0_transmit_32bits(uint32_t send) {&lt;BR /&gt;while((LPSPI0-&amp;gt;SR &amp;amp; LPSPI_SR_TDF_MASK)&amp;gt;&amp;gt;LPSPI_SR_TDF_SHIFT == 1);&lt;BR /&gt;/* Wait for Tx FIFO available */&lt;BR /&gt;LPSPI0-&amp;gt;TDR = send; /* Transmit data */&lt;BR /&gt;LPSPI0-&amp;gt;SR |= LPSPI_SR_TDF_MASK; /* Set TDF flag */&lt;BR /&gt;PTD-&amp;gt;PTOR |= 1&amp;lt;&amp;lt;0; /* Toggle output on port D0 (blue LED) */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please note that S32K config tool does not support polling method. How to configure the polling method and handle this please?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Apr 2023 21:24:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/lpSPI0-Configuration-using-polling-method-S32K144-Q100/m-p/1627927#M21863</guid>
      <dc:creator>SivakumarMariappan</dc:creator>
      <dc:date>2023-04-04T21:24:47Z</dc:date>
    </item>
    <item>
      <title>Re: lpSPI0 Configuration using polling method - S32K144-Q100</title>
      <link>https://community.nxp.com/t5/S32K/lpSPI0-Configuration-using-polling-method-S32K144-Q100/m-p/1628156#M21876</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/212077"&gt;@SivakumarMariappan&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1.&lt;/P&gt;
&lt;P&gt;Read LPSPI_SR[TDF]&lt;/P&gt;
&lt;P&gt;2.&lt;/P&gt;
&lt;P&gt;Read LPSPI_SR[TCF]&lt;/P&gt;
&lt;P&gt;3.&lt;/P&gt;
&lt;P&gt;Not &lt;STRONG&gt;while(TDF == 1)&lt;/STRONG&gt; but &lt;STRONG&gt;while(TDF == 0)&lt;/STRONG&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;while((LPSPI1-&amp;gt;SR &amp;amp; LPSPI_SR_TDF_MASK)&amp;gt;&amp;gt;LPSPI_SR_TDF_SHIFT==0);&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The TDF flag cannot be set this way:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;LPSPI0-&amp;gt;SR |= LPSPI_SR_TDF_MASK; /* Set TDF flag */&lt;/LI-CODE&gt;
&lt;P&gt;It is set automatically when the number of words in the TX FIFO is &amp;lt; TXWATER&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There is &lt;STRONG&gt;S32K144_Project_LPSPI&lt;/STRONG&gt; in S32DS IDE rev.2.2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Wed, 05 Apr 2023 09:36:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/lpSPI0-Configuration-using-polling-method-S32K144-Q100/m-p/1628156#M21876</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2023-04-05T09:36:01Z</dc:date>
    </item>
  </channel>
</rss>

