<?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 within XEP100 found the program stop in while(SPI0SR_SPIF==0) in S12 / MagniV Microcontrollers</title>
    <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692939#M14451</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;You are welcome. I am glad that it works now correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the CPHA = 1 is most typical solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This difference is visible also on SPI waveforms in RM:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="CPHA0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/16219i04D97B642813573A/image-size/large?v=v2&amp;amp;px=999" role="button" title="CPHA0.png" alt="CPHA0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="CPHA1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/16133iDC150834687957CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="CPHA1.png" alt="CPHA1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Aug 2017 11:57:42 GMT</pubDate>
    <dc:creator>RadekS</dc:creator>
    <dc:date>2017-08-07T11:57:42Z</dc:date>
    <item>
      <title>SPI within XEP100 found the program stop in while(SPI0SR_SPIF==0)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692935#M14447</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;STRONG&gt;When I use SPI within XEP100 to write to &amp;nbsp;and read data&amp;nbsp;&amp;nbsp;&amp;nbsp;from an RAM chip(FM25640),I found the program stop in while(!SPI0SR_SPIF)&amp;nbsp;,I dont know how to solve this problem,anyone who have a good idea give me some suggestion,thank you!&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here are init ,write and read programs.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;void SPI0_Init(void)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt; SPI_SO_DD=0;// MISO设置成输入&lt;BR /&gt; &lt;BR /&gt; CS_D=1;&lt;BR /&gt; CS_DD=1;//SS设置为输出&lt;BR /&gt; &lt;BR /&gt; SPI_SI=1;&lt;BR /&gt; SPI_SI_DD=1;//MOSI设置为输出&lt;BR /&gt; &lt;BR /&gt; SPI_SCK=0;&lt;BR /&gt; SPI_SCK_DD=1;//SCK设置为输出&lt;BR /&gt; &lt;BR /&gt; MODRR = 0x00;//使用SPI0口 &lt;BR /&gt; SPI0CR1=0X52;//使能SPI模块为主模式，使能SPI0，禁止SPI中断CHOL CPHA = 00 &lt;BR /&gt; SPI0CR2=0X10;//SS引脚作为通用IO，用户程序控制其信号。 通讯字节为8位&lt;BR /&gt; //SPI0BR=0X42; //设置通讯波特率，分频因子40&lt;BR /&gt; SPI0BR=0x77; //设置通讯波特率，分频因子2048&lt;BR /&gt;}&lt;BR /&gt;/***********************写一个字节********************/&lt;BR /&gt;unsigned char Write_Byte(unsigned char data) &lt;BR /&gt;{&lt;BR /&gt; unsigned char temp;&lt;BR /&gt; while(!SPI0SR_SPTEF); &lt;BR /&gt; SPI0DR=data;&lt;BR /&gt; while(!SPI0SR_SPIF);&lt;BR /&gt; return SPI0DR;&lt;BR /&gt;}&lt;BR /&gt;/***********************写数据********************/&lt;BR /&gt;void write_Data(unsigned int start_address,unsigned int length,unsigned char *dat) &lt;BR /&gt;{&lt;BR /&gt; unsigned int i;&lt;BR /&gt; CS_D=ON;&lt;BR /&gt; Write_Byte(WREN);&lt;BR /&gt; Write_Byte(WRITE);&lt;BR /&gt; Write_Byte(start_address &amp;gt;&amp;gt; 8);&lt;BR /&gt; Write_Byte(start_address);&lt;BR /&gt; for (i=0;i&amp;lt;length;i++)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt; Write_Byte(*dat);&lt;BR /&gt; dat++;&lt;BR /&gt; }&lt;BR /&gt; CS_D=OFF;&lt;BR /&gt;}&lt;BR /&gt;/**********************读一个字节************************/&lt;BR /&gt;unsigned char Read_Byte(void)&lt;BR /&gt;{&lt;BR /&gt; unsigned char rByte=0;&lt;BR /&gt; unsigned char temp;&lt;BR /&gt; while(!SPI0SR_SPIF); &lt;BR /&gt; rByte=SPI0DR;&lt;BR /&gt; return rByte; &lt;BR /&gt;}&lt;BR /&gt;/***********************读数据********************/&lt;BR /&gt;void Read_Data(unsigned int start_address,unsigned int length,unsigned char *dat) &lt;BR /&gt;{&lt;BR /&gt; unsigned int i;&lt;BR /&gt; CS_D=ON;&lt;BR /&gt; Write_Byte(READ);&lt;BR /&gt; Write_Byte(start_address &amp;gt;&amp;gt; 8);&lt;BR /&gt; Write_Byte(start_address);&lt;BR /&gt; for(i=0;i&amp;lt;length;i++)&lt;/P&gt;&lt;P&gt;{&lt;BR /&gt; *dat = Read_Byte() ;&lt;BR /&gt; dat++;&lt;/P&gt;&lt;P&gt;}&lt;BR /&gt; CS_D=OFF;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Aug 2017 06:41:43 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692935#M14447</guid>
      <dc:creator>921996194</dc:creator>
      <dc:date>2017-08-03T06:41:43Z</dc:date>
    </item>
    <item>
      <title>Re: SPI within XEP100 found the program stop in while(SPI0SR_SPIF==0)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692936#M14448</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Please refer to the attached example code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Daniel&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Aug 2017 09:13:33 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692936#M14448</guid>
      <dc:creator>danielmartynek</dc:creator>
      <dc:date>2017-08-04T09:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: SPI within XEP100 found the program stop in while(SPI0SR_SPIF==0)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692937#M14449</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &amp;nbsp;&amp;amp;#21016; &amp;amp;#38134;&lt;/P&gt;&lt;P&gt;I am slightly confused from your CS(SS) bit configuration. The SPI0CR1 and SPI0CR2 configuration specifies, that SS pin is driven by SPI module. While CS_D=ON; commands looks like manual driven SS pin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anyway, you selected CPOL=0 and CPHA=0. In that case, bytes (or words if XFRW=1) must by divided by SS pin line toggling (SS line is always deasserted and reasserted between successive transfers for at least minimum idle time)&lt;/P&gt;&lt;P&gt;So, if you use manual driven SS, you must toggle SS pin twice between bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Possible solutions:if&lt;/P&gt;&lt;P&gt;1. If you use manual driven SS, add code for SS pin toggle between byte transfers.&lt;/P&gt;&lt;P&gt;2. Use SS pin signal generated by SPI module&lt;/P&gt;&lt;P&gt;3. Use CPOL=1, CPHA=1 configuration (SPI Mode 3 per FM25640 datasheet)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Important note:&lt;/P&gt;&lt;P&gt;Please be aware, that while(!SPI0SR_SPIF); command cannot be debugged in stepping mode. The SPIF flag is cleared by read SPISR register with SPIF == 1 and then read SPIDRL register. That reading is applied also by debugger when you step over code – debugger clears SPIF flag by register reading when CPU halt.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&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, 07 Aug 2017 08:49:32 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692937#M14449</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-08-07T08:49:32Z</dc:date>
    </item>
    <item>
      <title>Re: SPI within XEP100 found the program stop in while(SPI0SR_SPIF==0)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692938#M14450</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;Hi&amp;nbsp;&lt;SPAN&gt;Radek,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN&gt;Thank you for your suggestions. I tried the third soulution(&lt;SPAN style="background-color: #ffffff;"&gt;Use CPOL=1, CPHA=1 configuration&lt;/SPAN&gt;), and it worked.I used the CS as an I/O port, not the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;SPI module.Although I dont know how it worked .Thanks a lot .&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Have a great day,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; background-color: #ffffff;"&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Ben&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 09:24:12 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692938#M14450</guid>
      <dc:creator>921996194</dc:creator>
      <dc:date>2017-08-07T09:24:12Z</dc:date>
    </item>
    <item>
      <title>Re: SPI within XEP100 found the program stop in while(SPI0SR_SPIF==0)</title>
      <link>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692939#M14451</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ben,&lt;/P&gt;&lt;P&gt;You are welcome. I am glad that it works now correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, the CPHA = 1 is most typical solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This difference is visible also on SPI waveforms in RM:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="CPHA0.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/16219i04D97B642813573A/image-size/large?v=v2&amp;amp;px=999" role="button" title="CPHA0.png" alt="CPHA0.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="CPHA1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/16133iDC150834687957CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="CPHA1.png" alt="CPHA1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope it helps you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have a great day,&lt;BR /&gt;Radek&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Aug 2017 11:57:42 GMT</pubDate>
      <guid>https://community.nxp.com/t5/S12-MagniV-Microcontrollers/SPI-within-XEP100-found-the-program-stop-in-while-SPI0SR-SPIF-0/m-p/692939#M14451</guid>
      <dc:creator>RadekS</dc:creator>
      <dc:date>2017-08-07T11:57:42Z</dc:date>
    </item>
  </channel>
</rss>

