<?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: SPI on MKV58F1M0VLQ24 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-on-MKV58F1M0VLQ24/m-p/1187697#M58902</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before writing data to PUSHR you need to clear the MCR[HALT] field to start the transmission, also please check if the module is enabled, otherwise writing to PUSHR has no effect.&lt;/P&gt;
&lt;P&gt;The code stays in "while ((base-&amp;gt;SR &amp;amp; SPI_SR_TCF_MASK) == 0)" while the transfer is still in progress.&lt;/P&gt;
&lt;P&gt;I suggest you refer to the SDK examples, there you can functions that will help you with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if this is helpful, if you have more questions do not hesitate to ask me.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Omar&lt;/P&gt;</description>
    <pubDate>Mon, 23 Nov 2020 20:47:27 GMT</pubDate>
    <dc:creator>Omar_Anguiano</dc:creator>
    <dc:date>2020-11-23T20:47:27Z</dc:date>
    <item>
      <title>SPI on MKV58F1M0VLQ24</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-on-MKV58F1M0VLQ24/m-p/1185317#M58871</link>
      <description>&lt;P&gt;On MK10FN1M0VLQ12 I did this way&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;uint32_t SPI_TransferByte(uint32_t spi_num, uint8_t tx_data, uint8_t *rx_data)
{
	uint32_t timeout;

	SPIx[spi_num]-&amp;gt;PUSHR = SPI_PUSHR_CTAS(0) | SPI_PUSHR_TXDATA((uint32_t)tx_data);

	timeout = 0;
	while (!( SPIx[spi_num]-&amp;gt;SR &amp;amp; SPI_SR_TCF_MASK))
	{
		if (timeout++ &amp;gt; SPI_TIMEOUT)
		{
			 SPIx[spi_num]-&amp;gt;SR = SPI_SR_TCF_MASK;
			return SPI_TIMEOUT_ERROR;
		}
	}

	timeout = 0;
	while (!(SPIx[spi_num]-&amp;gt;SR &amp;amp; SPI_SR_RFDF_MASK))
	{
		if (timeout++ &amp;gt; SPI_TIMEOUT)
		{
			 SPIx[spi_num]-&amp;gt;SR = SPI_SR_RFDF_MASK;
			return SPI_TIMEOUT_ERROR;
		}
	}

	*rx_data = (uint8_t)SPIx[spi_num]-&amp;gt;POPR;

    SPIx[spi_num]-&amp;gt;SR = SPI_SR_TCF_MASK | SPI_SR_RFDF_MASK;

	return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it work very good.&lt;/P&gt;&lt;P&gt;So I did the same on MKV58F1M0VLQ24&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;uint8_t SPI_TransferByte(SPI_Type *base, uint8_t tx_data)
{
	uint32_t timeout = 0;

 base-&amp;gt;PUSHR = SPI_PUSHR_CTAS(0) | SPI_PUSHR_TXDATA((uint32_t)tx_data);

    while ((base-&amp;gt;SR &amp;amp; SPI_SR_TCF_MASK) == 0)
    {
    	if (timeout++ &amp;gt; 100000)
    	{
    		base-&amp;gt;SR |= SPI_SR_TCF_MASK;
    	  	break;
    	}
    }
    base-&amp;gt;SR |= SPI_SR_TCF_MASK;
    timeout = 0;

    while ((base-&amp;gt;SR &amp;amp; SPI_SR_RFDF_MASK)==0)
    {
        if (timeout++ &amp;gt; 100000)
        {
        	base-&amp;gt;SR |= SPI_SR_RFDF_MASK;
            break;
        }
    }
    base-&amp;gt;SR |= SPI_SR_RFDF_MASK;

   return (uint8_t)(base-&amp;gt;POPR);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And I stay in&lt;/P&gt;&lt;P&gt;while ((base-&amp;gt;SR &amp;amp; SPI_SR_TCF_MASK) == 0)&lt;/P&gt;&lt;P&gt;the flag always low.&lt;/P&gt;&lt;P&gt;What&amp;nbsp; I did wrong?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2020 15:58:45 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-on-MKV58F1M0VLQ24/m-p/1185317#M58871</guid>
      <dc:creator>john71</dc:creator>
      <dc:date>2020-11-18T15:58:45Z</dc:date>
    </item>
    <item>
      <title>Re: SPI on MKV58F1M0VLQ24</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-on-MKV58F1M0VLQ24/m-p/1187697#M58902</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Before writing data to PUSHR you need to clear the MCR[HALT] field to start the transmission, also please check if the module is enabled, otherwise writing to PUSHR has no effect.&lt;/P&gt;
&lt;P&gt;The code stays in "while ((base-&amp;gt;SR &amp;amp; SPI_SR_TCF_MASK) == 0)" while the transfer is still in progress.&lt;/P&gt;
&lt;P&gt;I suggest you refer to the SDK examples, there you can functions that will help you with this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Let me know if this is helpful, if you have more questions do not hesitate to ask me.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Omar&lt;/P&gt;</description>
      <pubDate>Mon, 23 Nov 2020 20:47:27 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-on-MKV58F1M0VLQ24/m-p/1187697#M58902</guid>
      <dc:creator>Omar_Anguiano</dc:creator>
      <dc:date>2020-11-23T20:47:27Z</dc:date>
    </item>
  </channel>
</rss>

