<?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: Re: The questions about SPI in MQX Software Solutions</title>
    <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389724#M13017</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately I didn’t test SPI slave till now, but I am almost sure that you are right: If the system works as a slaver and calls the function “fwrite”, the task will be blocked until the master calls the function “fread” and the communication finishes.&lt;/P&gt;&lt;P&gt;Yes, if slave will not call fwrite and master calls the function “fread”, master will generate clock and master will probably real all bytes as 0xFF. Note: if master want read some data from slave, slave must write data prior master start read.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Nov 2014 13:50:31 GMT</pubDate>
    <dc:creator>RadekS</dc:creator>
    <dc:date>2014-11-12T13:50:31Z</dc:date>
    <item>
      <title>The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389718#M13011</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have read the SPI example in the address.&lt;/P&gt;&lt;P&gt;C:\Freescale\Freescale_MQX_4_1_TWRK64F120M\mqx\examples\spi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have 3 questions:&lt;/P&gt;&lt;P&gt;1, What is the meaning of the parameter “cs_mask” in callback&lt;BR /&gt;function “set_CS”? Which parameter is transferred to the parameter “cs_mask” in&lt;BR /&gt;this example?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2, My SPI application has 1 master and 4 slavers (select&lt;BR /&gt;signals:CS0,CS1,CS2,CS3). How to select the slaver?Do I have to select the slaver in the callback&lt;BR /&gt;function? If I want to communicate with the slavers one by one, how should Imodify the source code? &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3,The document &amp;lt; MQX_IO_User_Guide.pdf &amp;gt; Page 63&lt;BR /&gt;describes that&lt;/P&gt;&lt;P&gt;“the chip select signals are de-asserted and the bus is&lt;BR /&gt;released by execution of either IO_IOCTL_FLUSH_OUTPUT or IO_IOCTL_SPI_FLUSH_DEASSERT_CS command or by closing the file handle with _io_close() call.”&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I select the chip in the callback function by myself, are&lt;BR /&gt;the chip select signals still de-asserted by execution of either IO_IOCTL_FLUSH_OUTPUT&lt;BR /&gt;or IO_IOCTL_SPI_FLUSH_DEASSERT_CS command or by closing the file handle with&lt;BR /&gt;_io_close() call?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Nov 2014 08:59:34 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389718#M13011</guid>
      <dc:creator>小勇邹</dc:creator>
      <dc:date>2014-11-10T08:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389719#M13012</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;1)&lt;/P&gt;&lt;P&gt;As it is written in MQX_IO_User_Guide.pdf, cs_mask will tell you how to set chip select pins.&lt;/P&gt;&lt;P&gt;So, if you open SPI1:1 and SPI1:8, cs_mask will give you one followed of numbers - 1,8 or 0 (it depends on type of even which causes calling set_CS()). 0 has special meaning and it means that you have to set all CS pins to inactive state (typically high level).&lt;/P&gt;&lt;P&gt;cs_mask doesn’t need to be directly mask, it could be any number. So, you can open SPI1:22 and when you write to this interface, cs_mask will contain number 22. Note: this is valid only for case when we use software callback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;Yes, you should set all CS pins in “set_CS” function. set_CS() function is always just one. cs_mask will tell you how to set your CS pins. You don’t need modify the source code. You can do for example:&lt;/P&gt;&lt;P&gt;Spifd1 = fopen (spi1:1, NULL);&lt;/P&gt;&lt;P&gt;Spifd2 = fopen (spi1:2, NULL);&lt;/P&gt;&lt;P&gt;Spifd3 = fopen (spi1:4, NULL);&lt;/P&gt;&lt;P&gt;Spifd4 = fopen (spi1:8, NULL);&lt;/P&gt;&lt;P&gt;…&lt;/P&gt;&lt;P&gt;result = fwrite (buffer1, 1, 1, Spifd1);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer2, 1, 1, Spifd2);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer3, 1, 1, Spifd3);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer4, 1, 1, Spifd4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You typically call Spifd1 from different task than Spifd3, SPI driver is prepared for that situation and only one from SpifdX could be bus owner at the same time, others must wait until task executes fflush (SpifdX);.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)&lt;/P&gt;&lt;P&gt;Yes, any call IO_IOCTL_FLUSH_OUTPUT (fflush (SpifdX);) or IO_IOCTL_SPI_FLUSH_DEASSERT_CS command or by closing the file handle with _io_close() (in this case it depends on who is currently owner of SPI bus) will call “set_CS” function.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;RadekS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Nov 2014 17:42:29 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389719#M13012</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-11-10T17:42:29Z</dc:date>
    </item>
    <item>
      <title>Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389720#M13013</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much. I still have some questions according to your answer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As it is written in MQX_IO_User_Guide.pdf, cs_mask will tell&lt;BR /&gt;you how to set chip select pins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if you open SPI1:1 and SPI1:8, cs_mask will give you one&lt;BR /&gt;followed of numbers - 1,8 or 0 (it depends on type of even which causes calling&lt;BR /&gt;set_CS()). 0 has special meaning and it means that you have to set all CS pins&lt;BR /&gt;to inactive state (typically high level).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cs_mask doesn’t need to be directly mask, it could be any&lt;BR /&gt;number. So, you can open SPI1:22 and when you write to this interface, cs_mask&lt;BR /&gt;will contain number 22. Note: this is valid only for case when we use software&lt;BR /&gt;callback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;In the example,spifd = fopen ("spi0:", NULL); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;What is the value of cs_mask in the example?(C:\Freescale\Freescale_MQX_4_1_TWRK64F120M\mqx\examples\spi&lt;/SPAN&gt;&lt;SPAN style="color: #ff0000;"&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;Yes, you should set all CS pins in “set_CS” function. set_CS() function is always just one. cs_mask will tell you how to set your CS pins. You don’t need modify the source code. You can do for example:&lt;/P&gt;&lt;P&gt;Spifd1 = fopen (spi1:1, NULL);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*Does it mean that cs_mask is set as 1*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Spifd2 = fopen (spi1:2, NULL);&lt;/P&gt;&lt;P&gt;Spifd3 = fopen (spi1:4, NULL);&lt;/P&gt;&lt;P&gt;Spifd4 = fopen (spi1:8, NULL);&lt;/P&gt;&lt;P&gt;…&lt;/P&gt;&lt;P&gt;result = fwrite (buffer1, 1, 1, Spifd1);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*Does it means the function will call the callback function "set_CS()"?Does it mean that I shoud set the CS0 as 0(select the chip) and the other signals as 1 in the&amp;nbsp; callback function "se_CS()"?*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;result = fwrite (buffer2, 1, 1, Spifd2);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer3, 1, 1, Spifd3);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer4, 1, 1, Spifd4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You typically call Spifd1 from different task than Spifd3, SPI driver is prepared for that situation and only one from SpifdX could be bus owner at the same time, others must wait until task executes fflush (SpifdX);.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)&lt;/P&gt;&lt;P&gt;Yes, any call IO_IOCTL_FLUSH_OUTPUT (fflush (SpifdX);) or IO_IOCTL_SPI_FLUSH_DEASSERT_CS command or by closing the file handle with _io_close() (in this case it depends on who is currently owner of SPI bus) will call “set_CS” function.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;/*Does it mean that fflush and _io_close() function will&amp;nbsp; set cs_mask as 0 and transfer it to the “set_CS” function and I should set all the signals as 1 in the function(de-asserted all the chips)?*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;4)If the task call&amp;nbsp; fwrite (buffer2, 1, 1, Spifd2),does it mean that the ask should wait until the SPI completes the data transmission? &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;Is there interrupt method for read and write SPI? For example,the task sleeps after calling fwrite and it wates up after the SPI completes the data transmission.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Nov 2014 02:27:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389720#M13013</guid>
      <dc:creator>小勇邹</dc:creator>
      <dc:date>2014-11-11T02:27:31Z</dc:date>
    </item>
    <item>
      <title>Re: Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389721#M13014</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;5),How much data can the SPI master send out in the function "fwrite" one time?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;6),How much data can the SPI master buffer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #ff0000;"&gt;I send out the request data to the slaver and I read the response data 2ms later.And the slaver send out 200 bytes response in the 2ms.Can the SPI master&amp;nbsp; buffer the response data&amp;nbsp; if I do not read them immediately?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Nov 2014 03:37:01 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389721#M13014</guid>
      <dc:creator>小勇邹</dc:creator>
      <dc:date>2014-11-11T03:37:01Z</dc:date>
    </item>
    <item>
      <title>Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389722#M13015</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #3366ff;"&gt;See my blue answers:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;1)&lt;/P&gt;&lt;P&gt;As it is written in MQX_IO_User_Guide.pdf, cs_mask will tell&lt;BR /&gt; you how to set chip select pins.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, if you open SPI1:1 and SPI1:8, cs_mask will give you one&lt;BR /&gt; followed of numbers - 1,8 or 0 (it depends on type of even which causes calling&lt;BR /&gt; set_CS()). 0 has special meaning and it means that you have to set all CS pins&lt;BR /&gt; to inactive state (typically high level).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;cs_mask doesn’t need to be directly mask, it could be any&lt;BR /&gt; number. So, you can open SPI1:22 and when you write to this interface, cs_mask&lt;BR /&gt; will contain number 22. Note: this is valid only for case when we use software&lt;BR /&gt; callback.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;In the example,spifd = fopen ("spi0:", NULL); &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;What is the value of cs_mask in the example?(C:\Freescale\Freescale_MQX_4_1_TWRK64F120M\mqx\examples\spi)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;If you do not specify CS number/mask, CS0 will be automatically used (strtoul() function is used for read CS number)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)&lt;/P&gt;&lt;P&gt;Yes, you should set all CS pins in “set_CS” function. set_CS() function is always just one. cs_mask will tell you how to set your CS pins. You don’t need modify the source code. You can do for example:&lt;/P&gt;&lt;P&gt;Spifd1 = fopen (spi1:1, NULL);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;/*Does it mean that cs_mask is set as 1*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Fopen will not call set_CS function, but you are right. Spifd1 will use number 1 as CS signal. So, if you will write into Spifd1, cs_mask will contain number 1. Therefore set_CS function has to set appropriate pin combination for appropriate chip select. This could be used for example when you connect external 1-of-X demultiplexor for increase number of available chip selects. For example you can use four GPIO pins and 74154 (4514) for generating sixteen CS signals...&amp;nbsp;&amp;nbsp; &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Spifd2 = fopen (spi1:2, NULL);&lt;/P&gt;&lt;P&gt;Spifd3 = fopen (spi1:4, NULL);&lt;/P&gt;&lt;P&gt;Spifd4 = fopen (spi1:8, NULL);&lt;/P&gt;&lt;P&gt;…&lt;/P&gt;&lt;P&gt;result = fwrite (buffer1, 1, 1, Spifd1);&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;/*Does it means the function will call the callback function "set_CS()"?Does it mean that I shoud set the CS0 as 0(select the chip) and the other signals as 1 in the&amp;nbsp; callback function "se_CS()"?*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Yes, exactly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;result = fwrite (buffer2, 1, 1, Spifd2);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer3, 1, 1, Spifd3);&lt;/P&gt;&lt;P&gt;result = fwrite (buffer4, 1, 1, Spifd4);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You typically call Spifd1 from different task than Spifd3, SPI driver is prepared for that situation and only one from SpifdX could be bus owner at the same time, others must wait until task executes fflush (SpifdX);.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)&lt;/P&gt;&lt;P&gt;Yes, any call IO_IOCTL_FLUSH_OUTPUT (fflush (SpifdX);) or IO_IOCTL_SPI_FLUSH_DEASSERT_CS command or by closing the file handle with _io_close() (in this case it depends on who is currently owner of SPI bus) will call “set_CS” function.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;/*Does it mean that fflush and _io_close() function will&amp;nbsp; set cs_mask as 0 and transfer it to the “set_CS” function and I should set all the signals as 1 in the function(de-asserted all the chips)?*/&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Yes, exactly.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;4)If the task call&amp;nbsp; fwrite (buffer2, 1, 1, Spifd2),does it mean that the ask should wait until the SPI completes the data transmission?&lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="list-style-type: upper-alpha;"&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;Yes. If you call fwrite (buffer1, 1, 1, Spifd1); and after that you call fwrite (buffer2, 1, 1, Spifd2);&amp;nbsp; Spifd2 must wait until Spifd1 finish his transfer and task call fflush (Spifd1). After that Spifd2 could send his data. So, correctly it should be:&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;result = fwrite (buffer1, 1, 1, Spifd1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;fflush (Spifd1);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;result = fwrite (buffer2, 1, 1, Spifd2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;fflush (Spifd2);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;result = fwrite (buffer3, 1, 1, Spifd3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;fflush (Spifd3);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;result = fwrite (buffer4, 1, 1, Spifd4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;fflush (Spifd4);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Important is that it will work even when you call fwrite from different tasks.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;Is there interrupt method for read and write SPI? For example,the task sleeps after calling fwrite and it wates up after the SPI completes the data transmission.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Yes, exactly. SPI uses interrupts therefore fwrite () will block current task until data transfer is finished and MCU could work on other tasks in meantime. The same is valid for fread,…&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;So, if you have three tasks and every task sends 200 bytes over the same SPI: &lt;/SPAN&gt;&lt;/P&gt;&lt;OL style="list-style-type: decimal;"&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;task1 call fwrite and it blocks task1 until transfer finish&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;task2 call also fwrite but SPI must wait until first write finish. So, it will blocks task2 until first transfer finish&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;task3 call also fwrite but SPI must wait until first write finish. So, it will blocks task3 until first transfer finish&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;idle task will run until first SPI transfer finish&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN style="color: #0070c0;"&gt;when first SPI transfer finish, it will unblock task1 and when task1 call fflush, it will unblock second write to SPI….&lt;/SPAN&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;5),How much data can the SPI master send out in the function "fwrite" one time?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;This is not limited. It depends on your needs and available memory.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;6),How much data can the SPI master buffer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;For example:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red;"&gt;I send out the request data to the slaver and I read the response data 2ms later.And the slaver send out 200 bytes response in the 2ms.Can the SPI master&amp;nbsp; buffer the response data&amp;nbsp; if I do not read them immediately?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;This is just misunderstanding. In case of SPI only master could generate clock, therefore you don’t need any buffer as in UART case. SPI works as “simple” shift registers. So, when you call fread for 200 bytes SPI module will start generate clock and read data from slave.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0;"&gt;Size of data block isn’t limited. It depends on your needs and available memory – you have to allocate buffer where SPI will store received data.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Nov 2014 11:20:05 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389722#M13015</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-11-11T11:20:05Z</dc:date>
    </item>
    <item>
      <title>Re: Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389723#M13016</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt;"&gt;6), How much data can the SPI master buffer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: red; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt;"&gt;For example:&lt;/SPAN&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: red; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt;"&gt;I send out the request data to the slaver and I read the response&lt;BR /&gt;data 2ms later. And the slaver send out 200 bytes response in the 2ms.Can the&lt;BR /&gt;SPI master&amp;nbsp; buffer the response data&amp;nbsp; if I do not read them&lt;BR /&gt;immediately?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt;"&gt;This is just misunderstanding. In case of SPI only master could&lt;BR /&gt;generate clock, therefore you don’t need any buffer as in UART case. SPI works&lt;BR /&gt;as “simple” shift registers. So, when you call fread for 200 bytes SPI module&lt;BR /&gt;will start generate clock and read data from slave.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #0070c0; font-family: 'Helvetica','sans-serif'; font-size: 10.5pt;"&gt;Size of data block isn’t limited. It depends on your needs and&lt;BR /&gt;available memory – you have to allocate buffer where SPI will store received&lt;BR /&gt;data.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #00b050;"&gt;Yes, it is misunderstanding. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;SPAN style="color: #00b050;"&gt;So does it mean that the slaver only response the data actually when the master start generate clock &lt;/SPAN&gt;&lt;SPAN style="color: #00b050;"&gt;and read data from slave?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #00b050;"&gt;If the system works as a slaver and calls the function “fwrite”, the task will block until the master calls the&lt;BR /&gt;function “fread” and the communication finishes. Is it right?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #00b050;"&gt;If the master calls the function “fread” and the slaver does not response anything, the function “fread” also&lt;BR /&gt;will read some error data and the master will finish the communication. Is it right?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 02:49:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389723#M13016</guid>
      <dc:creator>小勇邹</dc:creator>
      <dc:date>2014-11-12T02:49:30Z</dc:date>
    </item>
    <item>
      <title>Re: Re: The questions about SPI</title>
      <link>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389724#M13017</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Unfortunately I didn’t test SPI slave till now, but I am almost sure that you are right: If the system works as a slaver and calls the function “fwrite”, the task will be blocked until the master calls the function “fread” and the communication finishes.&lt;/P&gt;&lt;P&gt;Yes, if slave will not call fwrite and master calls the function “fread”, master will generate clock and master will probably real all bytes as 0xFF. Note: if master want read some data from slave, slave must write data prior master start read.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Nov 2014 13:50:31 GMT</pubDate>
      <guid>https://community.nxp.com/t5/MQX-Software-Solutions/The-questions-about-SPI/m-p/389724#M13017</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2014-11-12T13:50:31Z</dc:date>
    </item>
  </channel>
</rss>

