<?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 FATFS KEA128 in Kinetis Microcontrollers</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508087#M31952</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Jingjing,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I add this 5 files to my project in coe warrior &lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58458i84DABA8200C4B741/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; there is no error wheni build it. I write this code in the main part&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;#include "CLK.h"&lt;/P&gt;&lt;P&gt;#include "SPI.h"&lt;/P&gt;&lt;P&gt;#include "typedefs.h"&lt;/P&gt;&lt;P&gt;#include "SD.h"&lt;/P&gt;&lt;P&gt;#include "ff.h"&lt;/P&gt;&lt;P&gt;#include "diskio.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static UINT8 errorSD;&lt;/P&gt;&lt;P&gt;static UINT8 errorwrite;&lt;/P&gt;&lt;P&gt;static UINT8 errorread;&lt;/P&gt;&lt;P&gt;static UINT8 errorFAT;&lt;/P&gt;&lt;P&gt;static UINT8 datos[512];&lt;/P&gt;&lt;P&gt;static UINT8 datosr[512];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static FRESULT fr1;&lt;/P&gt;&lt;P&gt;static FRESULT fr2;&lt;/P&gt;&lt;P&gt;static FRESULT fr3;&lt;/P&gt;&lt;P&gt;static FIL fil;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; int counter = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char FILE_NAME[9]="text5.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp; FATFS FatFs;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; int i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;256;i++)datos[i]=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=256;i&amp;lt;512;i++)datos[i]=511-i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;512;i++)datos[i]=45;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Clk_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; initSPI();&lt;/P&gt;&lt;P&gt;&amp;nbsp; errorSD=SD_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(errorSD==0){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr1 = f_mount(SD, &amp;amp;FatFs);&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr2 = f_open(&amp;amp;fil, "log_data.txt", FA_WRITE | FA_OPEN_ALWAYS);&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr3 = f_close(&amp;amp;fil);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter++;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create fr1, fr2 and fr3 to sea the error in each step of f_mount, f_open and f_close and i got this result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58480iEBA3AB87ED4FECD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_9.png" alt="pastedImage_9.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I don't understand is how to link the SPI initialitation of the card and this 3 funtions. Where can I say to this functions to use the spi that I already configure?&lt;/P&gt;&lt;P&gt;I attache the project.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Emilio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 07 Mar 2016 16:22:08 GMT</pubDate>
    <dc:creator>emilioaronmoyer</dc:creator>
    <dc:date>2016-03-07T16:22:08Z</dc:date>
    <item>
      <title>SPI FATFS KEA128</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508085#M31950</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write to .txt file on a SD card using SPI and FATFS. Right now I can only write raw data to the SD. I found some examples (libraries) on but I cannot connect the two program. Does anyone one have libraries for FATFS for the Kinets KEA128 or similar board?&lt;/P&gt;&lt;P&gt;or does anyone have and idea what do i need to do to write a .txt file? &lt;/P&gt;&lt;P&gt;I have no idea how to link both programs.&lt;/P&gt;&lt;P&gt;I'm using and adafruit adapter for the sd.&lt;/P&gt;&lt;P&gt;I attached my project y the library of fatfs&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337464"&gt;Copy-of-SPI_SD.rar&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Original Attachment has been moved to: &lt;A _jive_internal="true" href="https://community.nxp.com/docs/DOC-337464"&gt;ff11a.rar&lt;/A&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 04 Mar 2016 23:56:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508085#M31950</guid>
      <dc:creator>emilioaronmoyer</dc:creator>
      <dc:date>2016-03-04T23:56:30Z</dc:date>
    </item>
    <item>
      <title>Re: SPI FATFS KEA128</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508086#M31951</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Emillo Aron Moyers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I find you already ask this question in your another post:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.nxp.com/message/617077#comment-617077" title="https://community.freescale.com/message/617077#comment-617077"&gt;https://community.freescale.com/message/617077#comment-617077&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; And our colleague already reply you, about the FATFS lib, you can refer to the &lt;A href="http://cache.nxp.com/files/32bit/software_tools/SOFTWARE-DEVELOPMENT-KIT.html?fpsp=1&amp;amp;WT_TYPE=Software%20Development%20Kits&amp;amp;WT_VENDOR=FREESCALE&amp;amp;WT_FILE_FORMAT=html&amp;amp;WT_ASSET=Downloads&amp;amp;fileExt=.html"&gt;KSDK1.3.0.&lt;/A&gt;​&lt;/P&gt;&lt;P&gt;&amp;nbsp; After you download the KSDK1.3.0, and you can find the FATFs in the path:C:\Freescale\KSDK_1.3.0\middleware\filesystem\fatfs&lt;/P&gt;&lt;P&gt;&amp;nbsp; There still have another post about the Fatfs, but is is for K series, you also can refer to it:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.nxp.com/docs/DOC-105852"&gt;FatFs + SDHC data logger with KSDK in Kinetis Design Studio&lt;/A&gt;&lt;/P&gt;&lt;P&gt;When you add the Fatfs file, you just need to use f_open function&amp;nbsp; to create a .txt file, then use the f_write function to write the new code to the text file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;If you still have question, please contact me!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jingjing&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 Mar 2016 05:51:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508086#M31951</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2016-03-07T05:51:37Z</dc:date>
    </item>
    <item>
      <title>Re: SPI FATFS KEA128</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508087#M31952</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello &lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;Jingjing,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;I add this 5 files to my project in coe warrior &lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_1.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58458i84DABA8200C4B741/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_1.png" alt="pastedImage_1.png" /&gt;&lt;/span&gt;&lt;SPAN style="color: #51626f; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt; there is no error wheni build it. I write this code in the main part&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;#include "derivative.h" /* include peripheral declarations */&lt;/P&gt;&lt;P&gt;#include "CLK.h"&lt;/P&gt;&lt;P&gt;#include "SPI.h"&lt;/P&gt;&lt;P&gt;#include "typedefs.h"&lt;/P&gt;&lt;P&gt;#include "SD.h"&lt;/P&gt;&lt;P&gt;#include "ff.h"&lt;/P&gt;&lt;P&gt;#include "diskio.h"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static UINT8 errorSD;&lt;/P&gt;&lt;P&gt;static UINT8 errorwrite;&lt;/P&gt;&lt;P&gt;static UINT8 errorread;&lt;/P&gt;&lt;P&gt;static UINT8 errorFAT;&lt;/P&gt;&lt;P&gt;static UINT8 datos[512];&lt;/P&gt;&lt;P&gt;static UINT8 datosr[512];&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;static FRESULT fr1;&lt;/P&gt;&lt;P&gt;static FRESULT fr2;&lt;/P&gt;&lt;P&gt;static FRESULT fr3;&lt;/P&gt;&lt;P&gt;static FIL fil;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;int main(void)&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;&amp;nbsp; int counter = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; unsigned char FILE_NAME[9]="text5.txt";&lt;/P&gt;&lt;P&gt;&amp;nbsp; FATFS FatFs;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; int i;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;256;i++)datos[i]=i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=256;i&amp;lt;512;i++)datos[i]=511-i;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(i=0;i&amp;lt;512;i++)datos[i]=45;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Clk_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; initSPI();&lt;/P&gt;&lt;P&gt;&amp;nbsp; errorSD=SD_Init();&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(errorSD==0){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr1 = f_mount(SD, &amp;amp;FatFs);&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr2 = f_open(&amp;amp;fil, "log_data.txt", FA_WRITE | FA_OPEN_ALWAYS);&lt;/P&gt;&lt;P&gt;&amp;nbsp; fr3 = f_close(&amp;amp;fil);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; for(;;) { &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; counter++;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; return 0;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I create fr1, fr2 and fr3 to sea the error in each step of f_mount, f_open and f_close and i got this result:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="pastedImage_9.png"&gt;&lt;img src="https://community.nxp.com/t5/image/serverpage/image-id/58480iEBA3AB87ED4FECD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="pastedImage_9.png" alt="pastedImage_9.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What I don't understand is how to link the SPI initialitation of the card and this 3 funtions. Where can I say to this functions to use the spi that I already configure?&lt;/P&gt;&lt;P&gt;I attache the project.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Emilio&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 07 Mar 2016 16:22:08 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508087#M31952</guid>
      <dc:creator>emilioaronmoyer</dc:creator>
      <dc:date>2016-03-07T16:22:08Z</dc:date>
    </item>
    <item>
      <title>Re: SPI FATFS KEA128</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508088#M31953</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Emillio Aron Moyers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If you want to connect your SPI interface to the Fatfs, you need to modify your disk interface function to connect your SPI function.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; The interface function contains: disk_initialize, disk_status, disk_read, disk_write,disk_ioctl, get_fattime.etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; You can find these function in diskio.c, diskio.h , ff.c, ff.h。&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; More details, you can go to the Fatfs official website, there has some sample code, but not for kinetis, even not for kinetis, you still can refer to it:&lt;/P&gt;&lt;P&gt;&lt;A href="http://elm-chan.org/fsw/ff/00index_e.html" title="http://elm-chan.org/fsw/ff/00index_e.html"&gt;FatFs - Generic FAT File System Module&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wish it helps you!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Jingjing&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>Tue, 08 Mar 2016 05:12:06 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/SPI-FATFS-KEA128/m-p/508088#M31953</guid>
      <dc:creator>kerryzhou</dc:creator>
      <dc:date>2016-03-08T05:12:06Z</dc:date>
    </item>
  </channel>
</rss>

