<?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: Using SPI0 to control two slave devices with differnent SPIconfig</title>
    <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1639267#M22343</link>
    <description>&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;I didn't check the return value yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I set the value&amp;nbsp;&lt;STRONG&gt;u16_len = 260U&lt;/STRONG&gt;,and&amp;nbsp;&lt;STRONG&gt;u32_twmeout = 10U.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For testing, I close PMIC SPI and only EEPROM SPI active.&lt;/P&gt;&lt;P&gt;Also, I trace that the SPI messages fully transmitted is taken about 2ms.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Leon_Hsieh_0-1682384520947.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/220644iB09E1E1ECBF0646B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Leon_Hsieh_0-1682384520947.png" alt="Leon_Hsieh_0-1682384520947.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 25 Apr 2023 01:28:14 GMT</pubDate>
    <dc:creator>Leon_Hsieh</dc:creator>
    <dc:date>2023-04-25T01:28:14Z</dc:date>
    <item>
      <title>Using SPI0 to control two slave devices with differnent SPIconfig</title>
      <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1638639#M22326</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I have some issues about using the SPI module.&lt;/P&gt;&lt;P&gt;I want to use the S32k148 SPI0 to control two slave PMIC(FS65) and EEPROM(M95M01)&lt;/P&gt;&lt;P&gt;Because of the different baudrate and framsize, need to re-initialize the SPI0 configurations in the runtime. Before SPI data transmited, deinit the SPI first and then re-init SPI with the corresponded configuration.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;status_t StartBlockingTransfer_SPI0(lpspi_which_pcs_t cs, uint8_t* u8_tx_buff, uint8_t* u8_rx_buff, uint16_t u16_len, uint32_t u32_timeout)
{
	static uint8_t cs_temp;
	if(cs_temp != cs){
		cs_temp = cs;
		SPI_MasterDeinit(&amp;amp;spi0Instance);
		SPI_MasterInit(&amp;amp;spi0Instance, &amp;amp;spi0MasterConfig[cs]);
	}else{

	}
	//LPSPI_DRV_SetPcs(0U, cs, LPSPI_ACTIVE_LOW);
	return SPI_MasterTransferBlocking(&amp;amp;spi0Instance, u8_tx_buff, u8_rx_buff, u16_len, (uint16_t)u32_timeout);
}&lt;/LI-CODE&gt;&lt;P&gt;Below are the SPI0 configurations for the 2 slave devices.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;spi_master_t spi0MasterConfig[2] =
{
	[0] ={//PMIC
		.baudRate      = 500000,
		.ssPolarity    = SPI_ACTIVE_LOW,
		.frameSize     = 16U,
		.clockPhase    = READ_ON_EVEN_EDGE,
		.clockPolarity = SPI_ACTIVE_HIGH ,
		.bitOrder      = SPI_TRANSFER_MSB_FIRST,
		.transferType  = LPSPI_USING_INTERRUPTS,
		.rxDMAChannel  = 255U,
		.txDMAChannel  = 255U,
		.callback      = NULL,
		.callbackParam = NULL,
		.ssPin         = 0,
		.extension     = NULL
	},
	[1] = {//EEPROM
		.baudRate	   = 1000000, //1MHz
		.ssPolarity    = SPI_ACTIVE_LOW,
		.frameSize	   = 8U,
		.clockPhase    = READ_ON_ODD_EDGE,
		.clockPolarity = SPI_ACTIVE_HIGH ,
		.bitOrder	   = SPI_TRANSFER_MSB_FIRST,
		.transferType  = LPSPI_USING_INTERRUPTS,
		.rxDMAChannel  = 255U,
		.txDMAChannel  = 255U,
		.callback	   = NULL,
		.callbackParam = NULL,
		.ssPin		   = 1,
		.extension	   = NULL,
	}
};&lt;/LI-CODE&gt;&lt;P&gt;Now I want to change the different configurations after the EEPROM page-write(256 bytes) transmitted completely, how could I make it?&lt;/P&gt;&lt;P&gt;About 16 bytes transmitted and then&amp;nbsp; SPI0 deinit.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Leon06_1-1682318220800.png" style="width: 473px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/220479i8C96837CF83BC42A/image-dimensions/473x213?v=v2" width="473" height="213" role="button" title="Leon06_1-1682318220800.png" alt="Leon06_1-1682318220800.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Leon&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;</description>
      <pubDate>Mon, 24 Apr 2023 06:37:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1638639#M22326</guid>
      <dc:creator>Leon06</dc:creator>
      <dc:date>2023-04-24T06:37:53Z</dc:date>
    </item>
    <item>
      <title>Re: Using SPI0 to control two slave devices with differnent SPIconfig</title>
      <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1638722#M22331</link>
      <description>&lt;P&gt;Hi Leon,&lt;/P&gt;
&lt;P data-unlink="true"&gt;What's the value of &lt;STRONG&gt;u16_len&lt;/STRONG&gt; and &lt;STRONG&gt;u32_timeout&lt;/STRONG&gt;? &lt;SPAN&gt;If time expires&amp;nbsp;&lt;/SPAN&gt;SPI_MasterTransferBlocking()&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;will return error and the transmission will be aborted. Did you check the return value?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;BR /&gt;-------------------------------------------------------------------------------&lt;BR /&gt;Note:&lt;BR /&gt;- If this post answers your question, please click the "Mark Correct" button. Thank you!&lt;/P&gt;
&lt;P&gt;- We are following threads for 7 weeks after the last post, later replies are ignored&lt;BR /&gt;Please open a new thread and refer to the closed one, if you have a related question at a later point in time.&lt;BR /&gt;-------------------------------------------------------------------------------&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 00:36:47 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1638722#M22331</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2023-05-04T00:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Using SPI0 to control two slave devices with differnent SPIconfig</title>
      <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1639267#M22343</link>
      <description>&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;I didn't check the return value yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I set the value&amp;nbsp;&lt;STRONG&gt;u16_len = 260U&lt;/STRONG&gt;,and&amp;nbsp;&lt;STRONG&gt;u32_twmeout = 10U.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;For testing, I close PMIC SPI and only EEPROM SPI active.&lt;/P&gt;&lt;P&gt;Also, I trace that the SPI messages fully transmitted is taken about 2ms.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Leon_Hsieh_0-1682384520947.png" style="width: 400px;"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/220644iB09E1E1ECBF0646B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Leon_Hsieh_0-1682384520947.png" alt="Leon_Hsieh_0-1682384520947.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 01:28:14 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1639267#M22343</guid>
      <dc:creator>Leon_Hsieh</dc:creator>
      <dc:date>2023-04-25T01:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using SPI0 to control two slave devices with differnent SPIconfig</title>
      <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1639600#M22358</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Leon,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Which version of S32DS+S32K SDK are you using?&amp;nbsp;It is recommended to use the latest S32DSv3.4+S32K1 SDK RTM4.0.3&lt;BR /&gt;What is the return value?&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Robin&lt;/P&gt;</description>
      <pubDate>Tue, 25 Apr 2023 08:38:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1639600#M22358</guid>
      <dc:creator>Robin_Shen</dc:creator>
      <dc:date>2023-04-25T08:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using SPI0 to control two slave devices with differnent SPIconfig</title>
      <link>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1642845#M22520</link>
      <description>&lt;P&gt;Hi Robin,&lt;/P&gt;&lt;P&gt;Thanks for your help.&lt;/P&gt;&lt;P&gt;Now , I add a SPI status checked before doing SPI de-initialized and initialized.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This way, it ensures that if the SPI module is busy, nothing will be done before the SPI configuration is changed.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;status_t StartBlockingTransfer_SPI0(lpspi_which_pcs_t cs, uint8_t* u8_tx_buff, uint8_t* u8_rx_buff, uint16_t u16_len, uint32_t u32_timeout)
{
	//If busy, not do spi initialize, Leon 20230427
	LPSPI_Type *base = g_lpspiBase[0];
    if (LPSPI_GetStatusFlag(base, LPSPI_MODULE_BUSY))
    {
        return STATUS_BUSY;
    }

	static uint8_t cs_temp;
	if(cs_temp != cs){
		cs_temp = cs;
		SPI_MasterDeinit(&amp;amp;spi0Instance);
		SPI_MasterInit(&amp;amp;spi0Instance, &amp;amp;spi0MasterConfig[cs]);
	}else{

	}
	return SPI_MasterTransferBlocking(&amp;amp;spi0Instance, u8_tx_buff, u8_rx_buff, u16_len, (uint16_t)u32_timeout);
}&lt;/LI-CODE&gt;&lt;P&gt;Leon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 May 2023 02:58:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S32K/Using-SPI0-to-control-two-slave-devices-with-differnent/m-p/1642845#M22520</guid>
      <dc:creator>Leon06</dc:creator>
      <dc:date>2023-05-02T02:58:08Z</dc:date>
    </item>
  </channel>
</rss>

