<?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 problem with SPI comunication master-slave in LPC Microcontrollers</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1827327#M55641</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I'm trying to debug a SPI comunication master-slave, but it doesn't work. I have modified a SDK examples spi_polling_b2b_transfer_master and&amp;nbsp;spi_polling_b2b_transfer_slave. The master sends the data correctly, but the slave doesn't receive the data. I think there is a problem with the function SPI_SlaveTrasfertNonBlocking, because if I put a breakpoint in the callback when I debug the code, it never enter in. In both the codes I have menaged the chip select like GPIO.&lt;/P&gt;&lt;P&gt;Below you can find the code about SPI master and slave.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;MASTER:

while(1)
{
port_state = GPIO_PortRead(GPIO, APP_SW_PORT);

    	    if ((!(port_state &amp;amp; (1 &amp;lt;&amp;lt; APP_SW_PIN))))
    	      {

    	    /*Start Transfer*/
    	    xfer.txData      = srcBuff;
    	    xfer.dataSize    = 64;
    	    xfer.configFlags = kSPI_FrameAssert;
    	    GPIO_PinWrite(GPIO, 0, 4, 0);
    	    SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &amp;amp;xfer);
    	    GPIO_PinWrite(GPIO, 0, 4, 1);
    	    for(i=0; i&amp;lt;10000000; i++) asm("NOP");
}
}


SLAVE:

void pint_intr_callback(pint_pin_int_t pintr, uint32_t pmatch_status)
{
   flag=1;
}
static void slaveCallback(SPI_Type *base, spi_slave_handle_t *slaveHandle, status_t status, void *userData)
{
    slaveFinished = true;
}


 while (1)
    {
    	PINT_EnableCallbackByIndex(PINT, kPINT_PinInt0);
    	if(flag==1){
            xfer.txData=sendBuff;
    	    xfer.rxData   = receiveBuff;
    	    xfer.dataSize = 64;
    	    SPI_SlaveTransferNonBlocking(EXAMPLE_SPI_SLAVE, &amp;amp;handle, &amp;amp;xfer);

    	    while (slaveFinished != true)
    	    {
    	    }
    	}

    }
&lt;/LI-CODE&gt;&lt;P&gt;best regards.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Mar 2024 15:48:15 GMT</pubDate>
    <dc:creator>elix</dc:creator>
    <dc:date>2024-03-13T15:48:15Z</dc:date>
    <item>
      <title>problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1827327#M55641</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hi, I'm trying to debug a SPI comunication master-slave, but it doesn't work. I have modified a SDK examples spi_polling_b2b_transfer_master and&amp;nbsp;spi_polling_b2b_transfer_slave. The master sends the data correctly, but the slave doesn't receive the data. I think there is a problem with the function SPI_SlaveTrasfertNonBlocking, because if I put a breakpoint in the callback when I debug the code, it never enter in. In both the codes I have menaged the chip select like GPIO.&lt;/P&gt;&lt;P&gt;Below you can find the code about SPI master and slave.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;MASTER:

while(1)
{
port_state = GPIO_PortRead(GPIO, APP_SW_PORT);

    	    if ((!(port_state &amp;amp; (1 &amp;lt;&amp;lt; APP_SW_PIN))))
    	      {

    	    /*Start Transfer*/
    	    xfer.txData      = srcBuff;
    	    xfer.dataSize    = 64;
    	    xfer.configFlags = kSPI_FrameAssert;
    	    GPIO_PinWrite(GPIO, 0, 4, 0);
    	    SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &amp;amp;xfer);
    	    GPIO_PinWrite(GPIO, 0, 4, 1);
    	    for(i=0; i&amp;lt;10000000; i++) asm("NOP");
}
}


SLAVE:

void pint_intr_callback(pint_pin_int_t pintr, uint32_t pmatch_status)
{
   flag=1;
}
static void slaveCallback(SPI_Type *base, spi_slave_handle_t *slaveHandle, status_t status, void *userData)
{
    slaveFinished = true;
}


 while (1)
    {
    	PINT_EnableCallbackByIndex(PINT, kPINT_PinInt0);
    	if(flag==1){
            xfer.txData=sendBuff;
    	    xfer.rxData   = receiveBuff;
    	    xfer.dataSize = 64;
    	    SPI_SlaveTransferNonBlocking(EXAMPLE_SPI_SLAVE, &amp;amp;handle, &amp;amp;xfer);

    	    while (slaveFinished != true)
    	    {
    	    }
    	}

    }
&lt;/LI-CODE&gt;&lt;P&gt;best regards.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2024 15:48:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1827327#M55641</guid>
      <dc:creator>elix</dc:creator>
      <dc:date>2024-03-13T15:48:15Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1829413#M55671</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230910"&gt;@elix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please tell us which chip do you use.&lt;/P&gt;
&lt;P&gt;What about your board? DEMO board from nxp or your own board?&lt;/P&gt;
&lt;P&gt;And how about demo working without any change?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 12:55:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1829413#M55671</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-03-15T12:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1829528#M55673</link>
      <description>&lt;P&gt;Hi, I'm using the evaluation kit LPC55s06 like a Master and our board like a slave.&lt;BR /&gt;yes, I have tried the demo working without any changes, the master sends the data correctly (a vector from 0 to 64) but the slave doesn't reply the same.&lt;BR /&gt;Unlike the demo working, in my code I menage the chip select like a GPIO, the data is sent from the master when I push the button SW1 and the slave would start to receive the data when the chip select goes down, but it doesn't work.&lt;BR /&gt;Best reguard&lt;/P&gt;</description>
      <pubDate>Fri, 15 Mar 2024 15:47:11 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1829528#M55673</guid>
      <dc:creator>elix</dc:creator>
      <dc:date>2024-03-15T15:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1833694#M55716</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230910"&gt;@elix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Recommend you first using SDK demo without any change.&lt;/P&gt;
&lt;P&gt;I have tested the demo on my side with EVK boards, working well.&lt;/P&gt;
&lt;P&gt;Refer to readme.txt to connect hardware.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BR&lt;/P&gt;
&lt;P&gt;Alice&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Mar 2024 11:00:53 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1833694#M55716</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-03-22T11:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1834385#M55733</link>
      <description>&lt;P&gt;Hi, tanks for the answer, this day I have tried SDK demo without any changes and it works. I have found that the problem isn't in the function&amp;nbsp;&lt;SPAN&gt;SPI_SlaveTrasfertNonBlocking, but when I started to menage the slave's chip select like GPIO the code doesnt' work.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Best reguards&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 08:11:03 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1834385#M55733</guid>
      <dc:creator>elix</dc:creator>
      <dc:date>2024-03-25T08:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1834392#M55734</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/27788"&gt;@Alice_Yang&lt;/a&gt;, thanks for the answer. This days I have tried the SKD demo whitout any changes and now it works. I have found that the problem isnt' in the function&amp;nbsp;&lt;SPAN&gt;SPI_SlaveTrasfertNonBlocking, but when I started to&amp;nbsp;menage the slave's chip select like a GPIO the code doesn't work.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;BR&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 08:17:18 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1834392#M55734</guid>
      <dc:creator>elix</dc:creator>
      <dc:date>2024-03-25T08:17:18Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1836431#M55773</link>
      <description>&lt;P&gt;Hi, as already said the demo SDK without any changes works. This days I have modified the demo, the chip select is handled as GPIO for both master and slave. The Master sends the data to the slave when I push the botton correctly , but if I start to menage the slave's chip select as GPIO the code doesn't work. I have configured the pin in the Slave side as&amp;nbsp;a digital input, and I have initialized the GPIO port and pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;   gpio_pin_config_t led_config = {
    		 kGPIO_DigitalInput,

        };

    GPIO_PortInit(GPIO, 0);
    GPIO_PinInit(GPIO, 0, 23, &amp;amp;led_config);

BOARD_InitPins():
    const uint32_t port0_pin23_config = (/* Pin is configured as GPIO */
    		                             IOCON_PIO_FUNC0 |
                                         /* No addition pin function */
					     IOCON_PIO_MODE_INACT|
		 /* Standard mode, output slew rate control is enabled */
					   IOCON_PIO_SLEW_STANDARD |
				/* Input function is not inverted */
				     	    IOCON_PIO_INV_DI |
					/* Enables digital function */
					IOCON_PIO_DIGITAL_EN |
				      /* Open drain is disabled */
					 IOCON_PIO_OPENDRAIN_DI);
		  /* PORT0 PIN28 (coords: 44) is configured as PIO0_28 */
 IOCON_PinMuxSet(IOCON, 0U, 23U, port0_pin23_config);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that the state of the slave's chip select pin doesn't change and is always equals to 1, also when the master starts to send the data to the slave.&lt;BR /&gt;Why doesn't the code work, if I start to menage the slave's chip select as GPIO?&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below you can find the code about SPI master and slave.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;MASTER:
           for (i = 0; i &amp;lt; BUFFER_SIZE; i++)
            {
              srcBuff[i] = i;
            }

    while (1)
    {
    	port_state = GPIO_PortRead(GPIO, APP_SW_PORT);

    	    if ((!(port_state &amp;amp; (1 &amp;lt;&amp;lt; APP_SW_PIN))))
    	      {

    	    /*Start Transfer*/
    	    xfer.txData      = srcBuff;
    	    xfer.dataSize    = 64;
    	    xfer.configFlags = kSPI_FrameAssert;
    	    GPIO_PinWrite(GPIO, 0, 4, 0);
    	    SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &amp;amp;xfer);
    	    GPIO_PinWrite(GPIO, 0, 4, 1);
    	    for(i=0; i&amp;lt;10000000; i++) asm("NOP");

    }
}
}



SLAVE:
  for (i = 0; i &amp;lt; 64; i++)
         {
             sendBuff[i] = i;
         }

    while (1)
    {
   state= GPIO_PinRead(GPIO, 0, 23);
   if (state==0){
	   flag=1;
   }

      /* receive data from master */
      xfer.txData   = sendBuff;
      xfer.rxData   = receiveBuff;
      xfer.dataSize = sizeof(sendBuff);
      SPI_SlaveTransferNonBlocking(EXAMPLE_SPI_SLAVE, &amp;amp;handle, &amp;amp;xfer);

      while (slaveFinished != true)
      {
      }

     }
}&lt;/LI-CODE&gt;&lt;P&gt;in attach there is the screen shot of the logical analyzer.&lt;/P&gt;&lt;P&gt;BR&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>Wed, 27 Mar 2024 14:32:22 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1836431#M55773</guid>
      <dc:creator>elix</dc:creator>
      <dc:date>2024-03-27T14:32:22Z</dc:date>
    </item>
    <item>
      <title>Re: problem with SPI comunication master-slave</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1838510#M55796</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/230910"&gt;@elix&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So why do you configure&amp;nbsp;&lt;SPAN&gt;chip select pin as gpio?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If used as gpio, try to directly send data, not use the function&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-c"&gt;&lt;CODE&gt; SPI_MasterTransferBlocking(EXAMPLE_SPI_MASTER, &amp;amp;xfer);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 09:46:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/problem-with-SPI-comunication-master-slave/m-p/1838510#M55796</guid>
      <dc:creator>Alice_Yang</dc:creator>
      <dc:date>2024-04-01T09:46:54Z</dc:date>
    </item>
  </channel>
</rss>

