<?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>LPC MicrocontrollersのトピックRe: LPC4357 OEM-Board Embedded Artist Filesystem fpr SD/MMC Card</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588896#M21866</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bavarian on Fri Jan 24 07:39:05 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Examples for this can be found in various packages:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc43xx-packages"&gt;http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc43xx-packages&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/nxpfile/lpc4350apdlzip"&gt;http://www.lpcware.com/content/nxpfile/lpc4350apdlzip&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/project/LPC4300-Internet-Radio-Demo"&gt;http://www.lpcware.com/content/project/LPC4300-Internet-Radio-Demo&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/project/Dual-USB-Host-Device-solution"&gt;http://www.lpcware.com/content/project/Dual-USB-Host-Device-solution&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NXP Support Team&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 15 Jun 2016 19:12:56 GMT</pubDate>
    <dc:creator>lpcware</dc:creator>
    <dc:date>2016-06-15T19:12:56Z</dc:date>
    <item>
      <title>LPC4357 OEM-Board Embedded Artist Filesystem fpr SD/MMC Card</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588894#M21864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragooon on Thu Jan 23 06:43:58 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;English:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Good day,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I would like for the memory card adapter of the LPC4357 mu.C.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to view and edit the data by a computer. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;for that I have quite a bit to me through reading. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to build a simple FAT32 system. are there already projects or aid.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Greetings Andreas&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Deutsch ( Orginaltext):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Guten Tag,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ich möchte für den Speicherkarten Adapter von dem LPC4357 µC.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ich möchte die Daten von einem Rechner sehen und bearbeiten können. dazu habe ich mir schon einiges angelesen. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Ich möchte ein einfaches FAT32 system aufbauen. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Gibt es dazu schon projekte oder hilfen. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Grüße Andreas &lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:12:54 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588894#M21864</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:12:54Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4357 OEM-Board Embedded Artist Filesystem fpr SD/MMC Card</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588895#M21865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by Martin84 on Thu Jan 23 09:45:48 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Andreas,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;most people are using the FS from &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.nxp.com/external-link.jspa?url=http%3A%2F%2Felm-chan.org%2Ffsw%2Fff%2F00index_e.html" rel="nofollow" target="_blank"&gt;http://elm-chan.org/fsw/ff/00index_e.html&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;See you tomorrow ;-)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards, Martin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:12:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588895#M21865</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4357 OEM-Board Embedded Artist Filesystem fpr SD/MMC Card</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588896#M21866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by bavarian on Fri Jan 24 07:39:05 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Examples for this can be found in various packages:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc43xx-packages"&gt;http://www.lpcware.com/content/nxpfile/lpcopen-software-development-platform-lpc43xx-packages&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/nxpfile/lpc4350apdlzip"&gt;http://www.lpcware.com/content/nxpfile/lpc4350apdlzip&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/project/LPC4300-Internet-Radio-Demo"&gt;http://www.lpcware.com/content/project/LPC4300-Internet-Radio-Demo&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://http://www.lpcware.com/content/project/Dual-USB-Host-Device-solution"&gt;http://www.lpcware.com/content/project/Dual-USB-Host-Device-solution&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;NXP Support Team&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:12:56 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588896#M21866</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:12:56Z</dc:date>
    </item>
    <item>
      <title>Re: LPC4357 OEM-Board Embedded Artist Filesystem fpr SD/MMC Card</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588897#M21867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;STRONG&gt;Content originally posted in LPCWare by dragooon on Tue Mar 04 05:47:44 MST 2014&lt;/STRONG&gt;&lt;BR /&gt;&lt;SPAN&gt;Good day, I further came to gather file system unfortunately still not. I started with a simple SD card integration in a project.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Guten Tag, ich bin mit meinerm Filesystem leider noch nicht weiter gekommen. Angefangen habe ich mit einer einfachen SD-Karten einbindung in einem Projekt.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I found an example and adjusted:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Ich habe ein Beispiel gefunden und angepasst:)&lt;/SPAN&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;border:1px solid black;background-color:#cacaca;background-color:#cacaca;border:1px solid black;"&gt; &lt;PRE&gt;
#include "allHeader.h"

#define PRINTF1
#define UART2

#define DEBUG_PRINT PRINTF
//Ausgaben Print F = Console(Semihost), USART über uart deklaration
#if DEBUG_PRINT == PRINTF

uint32_t inputValue = 0;

#elif DEBUG_PRINT == UART

#endif

/************************** PRIVATE DEFINITIONS ***********************/
/* CAUTION!!!!!!! READ THIS FIRST!!!!!!!
&amp;nbsp;&amp;nbsp; Only enable write mode if you are using a SD/MMC card that can
&amp;nbsp;&amp;nbsp; affort to lose data. This example actively writes to the card and
&amp;nbsp;&amp;nbsp; will overwrite any data there corrupting files or file data. You
&amp;nbsp;&amp;nbsp; may need to re-format your card after using this example with
&amp;nbsp;&amp;nbsp; write enable. Use with care! */
//#define ENABLE_WRITE_MODE

/* If you want to try multiple sector read/write capability, enable
&amp;nbsp;&amp;nbsp; this define. Multiple read/write uses a different command vs the
&amp;nbsp;&amp;nbsp; single sector read write for faster data transfer rates */
#define USE_MULTPLE_TRANSFER

/* Maximum multiple sector transfer size, 128 max limited by size
&amp;nbsp;&amp;nbsp; of memory */
#define MULT_XFER_MAX_SECTORS 28

/* I've found it's easier to understand the pullup/pulldown defines
&amp;nbsp;&amp;nbsp; seperate instead of using the combo MD_* macros */
#define MD_ENAB_PD (1&amp;lt;&amp;lt;3) /* Enable pull down resistor at pad */
#define MD_DIS_PU (1&amp;lt;&amp;lt;4) /* Disable pullup resistor at pad */


/* SD clock/data pins have fast slew rate, not glitch filter,
&amp;nbsp;&amp;nbsp; buffered input, and no pulldown or pullup. Note that the board
&amp;nbsp;&amp;nbsp; already has pullups on the necessary SD signals */
#define SDFASTINOUTPIN (MD_DIS_PU | MD_EZI | MD_EHS | MD_ZI)

//#define MD_PLN_FAST (MD_PLN | MD_EZI | MD_ZI | MD_EHS) // Abweichung zum SCU.h

/************************** PRIVATE VARIABLES *************************/
uint8_t menu1[] =
"********************************************************************************\n\r"
"Hello NXP Semiconductors \n\r"
" SD/MMC read/write demo \n\r"
"\t - MCU: LPC18xx \n\r"
"\t - Core: ARM CORTEX-M3 \n\r"
"\t - Communicate via: UART0 - 115200 bps \n\r"
" Use SDIO to perform read and write into from/to Card\n\r"
"********************************************************************************\n\r";

#ifdef USE_MULTPLE_TRANSFER
static uint32_t lbuff[(MULT_XFER_MAX_SECTORS * MMC_SECTOR_SIZE) / sizeof(uint32_t)];
#else
static uint32_t lbuff[MMC_SECTOR_SIZE / sizeof(uint32_t)];
#endif
static volatile uint32_t u32Milliseconds = 0;
static volatile uint32_t mci_status, Leddelay = 500;

/* Keeping errorc global makes it easier to see it in the debugger */
int32_t errorc;
uint32_t tstartr, tstopr, tstartw, tstopw;
struct _mci_card_struct sdcardinfo;
static volatile int32_t sdio_wait_exit = 0;

/************************** PRIVATE FUNCTION *************************/
void print_menu(void);
void initPorts(void);
static int verify_data(int sectors, int initval, int inc);
static void prep_data(int initval, int inc);
/*-------------------------PRIVATE FUNCTIONS------------------------------*/
/*******************************************************************************
* @briefSystem tick interrupt handler
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; None
* @returnNone
*******************************************************************************/
void SysTick_Handler (void)
{
u32Milliseconds += 10;
}

/*********************************************************************//**
 * @briefPrint menu
 * @param[in]None
 * @return None
 **********************************************************************/
void print_menu(void)
{
#if DEBUG_PRINT == PRINTF
printf(menu1);
#elif DEBUG_PRINT == UART
_DBG(menu1);
#endif
}

/*******************************************************************************
* @briefWait for card program to finish
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; None
* @returnNone
*******************************************************************************/
 static void wait_for_program_finish(void)
{
/* Poll card for program completion */
while (sdmmc_get_state() != SDMMC_TRAN_ST);
}



/*******************************************************************************
* @briefSDIO interrupt handler callback
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; rinsts Optional input parameter
* @returnReturn value is 0, not currently used
*******************************************************************************/
static uint32_t sdmmc_irq(uint32_t rinsts)
{
/* Set wait exit flag to tell wait function we are ready. In an RTOS,
&amp;nbsp;&amp;nbsp; this would trigger wakeup of a thread waiting for the IRQ. */
NVIC_DisableIRQ(SDIO_IRQn);
sdio_wait_exit = 1;

return 0;
}

/*********************************************************************//**
* @brief Sets up the SD event driven wakeup
* @param[in]bits Status bits to poll for command completion
* @return None
**********************************************************************/
static void sdmmc_setup_wakeup(uint32_t bits)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Wait for IRQ - for an RTOS, you would pend on an event here
&amp;nbsp;&amp;nbsp; with a IRQ based wakeup. */
NVIC_ClearPendingIRQ(SDIO_IRQn);
sdio_wait_exit = 0;
LPC_SDMMC-&amp;gt;INTMASK = bits;
NVIC_EnableIRQ(SDIO_IRQn);
}

/*********************************************************************//**
* @brief A better wait callback for SDMMC driven by the IRQ flag
* @param[in]bits Status bits to poll for command completion
* @return 0 on success, or failure condition (-1)
**********************************************************************/
static uint32_t sdmmc_irq_driven_wait(uint32_t bits)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp; uint32_t status;

/* Wait for event, would be nice to have a timeout, but keep it
&amp;nbsp;&amp;nbsp; simple */
while (sdio_wait_exit == 0);

/* Get status and clear interrupts */
status = LPC_SDMMC-&amp;gt;RINTSTS;
LPC_SDMMC-&amp;gt;RINTSTS = status;
LPC_SDMMC-&amp;gt;INTMASK = 0;

return status;
}

/*********************************************************************//**
* @brief Delay callback for timed SDIF/SDMMC functions
* @param[in]time Number of milliSeconds to wait
* @return None
**********************************************************************/
void sdmmc_waitms(uint32_t time)
{
/* In an RTOS, the thread would sleep allowing other threads to
&amp;nbsp;&amp;nbsp; run. For standalone operation, we just spin on a timer */
TIM_Waitus(time * 1000);
}

/*-------------------------MAIN FUNCTION------------------------------*/
/*********************************************************************//**
 * @briefMain SDIO program body
 * @param[in]None
 * @return int
 **********************************************************************/
int c_entry(void)
{
uint8_t tmpVar =0;
uint32_t dms;
int32_t loops, blk;

errorc = 1;

//System init
SystemInit();
//Clocks Init
CGU_Init();
//Port/Pins Init
initPorts();


/* Initialize debug via UART / Console
 * see"PLATFORM" &amp;amp; "DEBUG_PRINT" define
 * – 115200bps
 * – 8 data bit
 * – No parity
 * – 1 stop bit
 * – No flow control
 */
debug_frmwrk_init();

// print welcome screen
print_menu();

//while ((tmpVar=_DG) != 0);


/* Wait for a card to be inserted (note CD is not on the
&amp;nbsp;&amp;nbsp; SDMMC power rail and can be polled without enabling
&amp;nbsp;&amp;nbsp; SD slot power */
while (!(sdif_card_ndetect()));
lpc_printf("Card inserted...\r\n");

/* Enable slot power, 0 to enable */
sdif_power_onoff(0);

/* Allow some time for the power supply to settle and the
&amp;nbsp;&amp;nbsp; card to fully seat in the slot */
dms = u32Milliseconds + 500;//+250
while (dms &amp;gt; u32Milliseconds);

/* Enumerate the card once detected. Note this function may
&amp;nbsp;&amp;nbsp; block for a little while. */
if (!sdmmc_acquire(sdmmc_setup_wakeup, sdmmc_irq_driven_wait,
sdmmc_waitms, &amp;amp;sdcardinfo)) {

errorc = -1;
goto error_exit;
}

/* Setup card specific callbacks - use driver functions, but these can
&amp;nbsp;&amp;nbsp; be changed to custom functions or unique functions per slot. These
&amp;nbsp;&amp;nbsp; aren't used in the drivers, so setup of these is optional, but they
&amp;nbsp;&amp;nbsp; are setup here to be complete. */
sdcardinfo.sdck_det = sdif_card_ndetect;
sdcardinfo.sdck_wp = sdif_card_wp_on;
sdcardinfo.sd_setpow = sdif_power_onoff;
sdcardinfo.sd_setrst = sdif_reset;

if (sdcardinfo.sdck_wp()){
lpc_printf("Card is write protected, so write tests will be skipped\r\n");
}//if...

memset(lbuff, 0, sizeof(lbuff));
if (sdmmc_read_blocks((void *) lbuff, 0, 0) == 0) {
errorc = -2;
goto error_exit;
}
#ifdef ENABLE_WRITE_MODE
lpc_printf("Press 1 to write data to sector 1 and verify:\r\n");
while ((tmpVar=_DG) != 1);
/* Write a single sector of data (512 bytes) */
if (!sdcardinfo.sdck_wp()) {
prep_data(0, 1);
/* Warning: This may corrupt SD card data! */
if (sdmmc_write_blocks((void *) lbuff, 1, 1) == 0) {
errorc = -3;
goto error_exit;
}
/* Wait for write to finish (at the card) */
wait_for_program_finish();
}
#endif
memset(lbuff, 0, sizeof(lbuff));
/* Read a single sector of data (512 bytes) */
if (sdmmc_read_blocks((void *) lbuff, 1, 1) == 0) {
errorc = -4;
goto error_exit;
}
#ifdef ENABLE_WRITE_MODE
/* Verify data and halt if an error occurs */
if (!sdcardinfo.sdck_wp()) {
if (verify_data(1, 0, 1) == 0) {
errorc = -5;
goto error_exit;
}
lpc_printf("Verified!\r\n");
}
#endif

#ifdef USE_MULTPLE_TRANSFER
#ifdef ENABLE_WRITE_MODE

lpc_printf("Press 2 to write data in Multitransfer mode and then verify:\r\n");
while (_DG != 2);

/* Write data using multiple sector write */
if (!sdcardinfo.sdck_wp()) {
prep_data(0x10, 3);
/* Warning: This may corrupt SD card data! */
if (sdmmc_write_blocks((void *) lbuff, 1, MULT_XFER_MAX_SECTORS) == 0) {
errorc = -6;
goto error_exit;
}
wait_for_program_finish();
}
#endif
memset(lbuff, 0, sizeof(lbuff));
/* Read data using multiple sector read */
if (sdmmc_read_blocks((void *) lbuff, 1, MULT_XFER_MAX_SECTORS) == 0) {
errorc = -7;
goto error_exit;
}

#ifdef ENABLE_WRITE_MODE
/* Verify data and halt if an error occurs */
if (!sdcardinfo.sdck_wp()) {
if (verify_data(MULT_XFER_MAX_SECTORS, 0x10, 3) == 0) {
errorc = -8;
goto error_exit;
}
lpc_printf("Verified!\r\n");
}
#endif

lpc_printf("Press 3 to measure continuous read speed...\r\n");
while (_DG != 3);
tstartr = u32Milliseconds;
loops = 1000;
blk = 64;
while (loops-- &amp;gt; 0) {
if (sdmmc_read_blocks((void *) lbuff, blk, (blk + MULT_XFER_MAX_SECTORS - 1)) == 0) {
errorc = -8;
goto error_exit;
}

blk += MULT_XFER_MAX_SECTORS;
}
tstopr = u32Milliseconds;
lpc_printf("read speed = %d kB/s\r\n", MULT_XFER_MAX_SECTORS*512*1000/(tstopr-tstartr));

#ifdef ENABLE_WRITE_MODE
lpc_printf("Press 4 to measure continuous write speed...\r\n");
while (_DG != 4);
if (!sdcardinfo.sdck_wp()) {
tstartw = u32Milliseconds;
loops = 200;
blk = 64;
while (loops-- &amp;gt; 0) {
if (sdmmc_write_blocks((void *) lbuff, blk, (blk + MULT_XFER_MAX_SECTORS - 1)) == 0) {
errorc = -9;
goto error_exit;
}
blk += MULT_XFER_MAX_SECTORS;
wait_for_program_finish();
}
tstopw = u32Milliseconds;
}
lpc_printf("write speed = %d kB/s\r\n", MULT_XFER_MAX_SECTORS*512*200/(tstopw-tstartw));
#endif
#endif

sdif_power_onoff(1); /* 1 to disable for Hitex board */
sdif_deinit();
while(1);

return errorc;

error_exit:
lpc_printf("Application failed.\r\n");
while (1);
return errorc;
}

/* Support required entry point for other toolchain */
int main (void)
{
return c_entry();
}

/*******************************************************************************
* @briefGenerates a data pattern in a buffer
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; initval Initial value
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; inc Increment value
* @returnNone
*******************************************************************************/
static void prep_data(int initval, int inc)
{
int i;
unsigned char *p = (unsigned char *) lbuff;

for (i = 0; i &amp;lt; sizeof(lbuff); i++) {
p&lt;I&gt; = ((unsigned char) initval) &amp;amp; 0xff;
initval += inc;
}
}

/*******************************************************************************
* @briefVerifies a data pattern in a buffer
* @param[in]sectors Numbers of sectors to check, 512 bytes per sector
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; initval Initial value
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; inc Increment value
* @return0 if the verify fails, otherwise !0
*******************************************************************************/
static int verify_data(int sectors, int initval, int inc)
{
int i = 0, passed = 1;
uint8_t *cbuf = (uint8_t *) lbuff;
uint8_t tab;

while (i &amp;lt; (sectors * MMC_SECTOR_SIZE)) {
tab = cbuf&lt;I&gt;;
if (cbuf&lt;I&gt; != (uint8_t) (initval &amp;amp; 0xff)){
passed = 0;break;
}
initval += inc;
i++;
}
tab = tab;
return passed;
}
/*******************************************************************************
* @briefInit. Ports,Functions &amp;amp; Clock for SD- Interface
* @param[in]None
* @returnNone
*******************************************************************************/
void initPorts(void){
uint32_t sdio_clk=0;



/* Setup muxing for UART interface */
scu_pinmux(0x2 ,0 , MD_PDN, FUNC1); // PF.10 : UART0_TXD
scu_pinmux(0x2 ,1 , MD_PLN|MD_EZI|MD_ZI, FUNC1); // PF.11 : UART0_RXD



/* Configure the IO's for the LEDs */
/* Setup muxing for SD interface */
scu_pinmux(PORT_C ,PIN_09 , MD_DIS_PU, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.9 SDIO power */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //checked
//scu_pinmux(0xD ,PIN_01 , MD_DIS_PU, FUNC5);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.9 SDIO power */


//scu_pinmux(PORT_C ,PIN_02 , MD_DIS_PU, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.2 SDIO LED *///not_found in user's manual, only there in schematic, LED Powerd over SD_Power
//scu_pinmux(0xf ,PIN_10, MD_DIS_PU | MD_EZI, FUNC6);&amp;nbsp; /* Pf.10 SDIO WP */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Write Protect
//scu_pinmux(0xd ,PIN_15, MD_DIS_PU | MD_EZI, FUNC5);&amp;nbsp; /* Pf.10 SDIO WP */&amp;nbsp;&amp;nbsp;&amp;nbsp; //
scu_pinmux(PORT_C ,PIN_10, SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.10 SDIO command */ //Command Input/Output
scu_pinmux(PORT_C ,PIN_08 , MD_DIS_PU | MD_EZI, FUNC7); /* Pc.8 SDIO CD *///Card Detect
scu_pinmux(PORT_C ,PIN_07 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.7 SDIO D3 */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Data Line 3
scu_pinmux(PORT_C ,PIN_06 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.6 SDIO D2 *///Data Line 2
scu_pinmux(PORT_C ,PIN_05 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.5 SDIO D1 *///Data Line 1
scu_pinmux(PORT_C ,PIN_04 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.4 SDIO D0 */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Data Line 0
scu_pinmux(PORT_C ,PIN_00 , MD_DIS_PU | MD_EHS, FUNC7); /* Pc.0 SDIO clock */&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //Clock


#if 0 /* Not used, SD interfaces bits D4 - D7 */
scu_pinmux(PORT_C ,PIN_11 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.7 SDIO D4 */
scu_pinmux(PORT_C ,PIN_12 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.7 SDIO D5 */
scu_pinmux(PORT_C ,PIN_13 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.7 SDIO D6 */
scu_pinmux(PORT_C ,PIN_14 , SDFASTINOUTPIN, FUNC7);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Pc.7 SDIO D7 */
#endif

LPC_SCU-&amp;gt;SFSCLK_0 = 0x01;

CGU_EntityConnect(CGU_CLKSRC_PLL1, CGU_BASE_SDIO);

/* Generate interrupt @ 100 Hz */
SysTick_Config(CGU_GetPCLKFrequency(CGU_PERIPHERAL_M4CORE) / 100);

/* The SDIO driver needs to know the SDIO clock rate */
sdio_clk = CGU_GetPCLKFrequency(CGU_PERIPHERAL_SDIO);

/* This init sdio with sdio_clk */
sdif_init(sdio_clk, sdmmc_irq);
}

#ifdef&amp;nbsp; DEBUG
/*******************************************************************************
* @briefReports the name of the source file and the source line number
* where the CHECK_PARAM error has occurred.
* @param[in]file Pointer to the source file name
* @param[in]&amp;nbsp;&amp;nbsp;&amp;nbsp; line assert_param error line source number
* @returnNone
*******************************************************************************/
void check_failed(uint8_t *file, uint32_t line)
{
/* User can add his own implementation to report the file name and line number,
 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

/* Infinite loop */
while(1);
}
#endif

/**
 * @}
 */

&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;In the Function" if (! sdmmc_acquire (sdmmc_setup_wakeup, sdmmc_irq_driven_wait, sdmmc_waitms, &amp;amp;amp; sdcardinfo)) "leave the program to error state.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(In der Fktn "if (!sdmmc_acquire(sdmmc_setup_wakeup, sdmmc_irq_driven_wait,sdmmc_waitms, &amp;amp;sdcardinfo))" geht das Programm in den Fehlerzustand.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV class="j-rte-table"&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD bgcolor="#cacaca" style="border:1px solid black;background-color:#cacaca;border:1px solid black;background-color:#cacaca;background-color:#cacaca;border:1px solid black;"&gt; &lt;PRE&gt;
/*********************************************************************//**
* @brief Function to enumerate the SD/MMC/SDHC/MMC+ cards
* @param[in]evsetup_cb Pointer to event setup function callback
* @param[in]waitfunc_cb Pointer to wait function callback
* @param[in]msdelay_func Pointer to function that delays
* @param[in]pcardinfo Pointer to pre-allocated card info structure
* @return 1 if a card is acquired, otherwise 0
**********************************************************************/
int32_t sdmmc_acquire(MCI_EVSETUP_FUNC_T evsetup_cb,
MCI_WAIT_CB_FUNC_T waitfunc_cb, MCI_MSDELAY_FUNC_T msdelay_func,
struct _mci_card_struct *pcardinfo)
{
int32_t status;
int32_t tries = 0;
uint32_t ocr = OCR_VOLTAGE_RANGE_MSK;
uint32_t r;
int32_t state = 0;
uint32_t command = 0;

g_card_info = pcardinfo;

/* Make sure callbacks are valid */
if ((waitfunc_cb == NULL) || (msdelay_func&amp;nbsp; == NULL) ||
(evsetup_cb&amp;nbsp; == NULL))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0;

sdmmc_evsetup_cb = evsetup_cb;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sdmmc_wait_cb = waitfunc_cb;
&amp;nbsp;&amp;nbsp;&amp;nbsp; sdmmc_msdelay_cb = msdelay_func;

/* clear card struct */
memset(g_card_info, 0, sizeof(*g_card_info));

/* clear card type */
LPC_SDMMC-&amp;gt;CTYPE = 0;

/* set high speed for the card as 20MHz */
g_card_info-&amp;gt;speed = MMC_MAX_CLOCK;

status = sdmmc_execute_command(CMD_IDLE, 0, MCI_INT_CMD_DONE);

while (state &amp;lt; 100)
{
switch (state)
{
case 0:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Setup for SD */
/* check if it is SDHC card */
status = sdmmc_execute_command( CMD_SD_SEND_IF_COND, SD_SEND_IF_ARG, 0);
if (!(status &amp;amp; MCI_INT_RTO))/*!&amp;lt; Response timeout error */
{
/* check response has same echo pattern */
if ((g_card_info-&amp;gt;response[0] &amp;amp; SD_SEND_IF_ECHO_MSK) == SD_SEND_IF_RESP)
ocr |= OCR_HC_CCS;
}

++state;
command = CMD_SD_OP_COND;
tries = INIT_OP_RETRIES;

/* assume SD card */
g_card_info-&amp;gt;card_type |= CARD_TYPE_SD;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; g_card_info-&amp;gt;speed = SD_MAX_CLOCK;
break;

case 10:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Setup for MMC */
/* start fresh for MMC crds */
g_card_info-&amp;gt;card_type &amp;amp;= ~CARD_TYPE_SD;
status = sdmmc_execute_command(CMD_IDLE, 0, MCI_INT_CMD_DONE);
command = CMD_MMC_OP_COND;
tries = INIT_OP_RETRIES;
ocr |= OCR_HC_CCS;
++state;

/* for MMC cards high speed is 20MHz */
g_card_info-&amp;gt;speed = MMC_MAX_CLOCK;
break;

case 1:
case 11:
status = sdmmc_execute_command(command, 0, 0);
if (status &amp;amp; MCI_INT_RTO)
state += 9;/* Mode unavailable */
else
++state;
break;

case 2:/* Initial OCR check&amp;nbsp; */
case 12:
ocr = g_card_info-&amp;gt;response[0] | (ocr &amp;amp; OCR_HC_CCS);
if (ocr &amp;amp; OCR_ALL_READY)
++state;
else
state += 2;
break;

case 3:/* Initial wait for OCR clear */
case 13:
while ((ocr &amp;amp; OCR_ALL_READY) &amp;amp;&amp;amp; --tries &amp;gt; 0)
{
sdmmc_msdelay_cb(MS_ACQUIRE_DELAY);
status = sdmmc_execute_command(command, 0, 0);
ocr = g_card_info-&amp;gt;response[0] | (ocr &amp;amp; OCR_HC_CCS);
}
if (ocr &amp;amp; OCR_ALL_READY)
state += 7;
else
++state;
break;

case 14:
/* for MMC cards set high capacity bit */
ocr |= OCR_HC_CCS;
case 4:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* Assign OCR */
tries = SET_OP_RETRIES;
ocr &amp;amp;= OCR_VOLTAGE_RANGE_MSK | OCR_HC_CCS;/* Mask for the bits we care about */
do
{
sdmmc_msdelay_cb(MS_ACQUIRE_DELAY);
status = sdmmc_execute_command(command, ocr, 0);
r = g_card_info-&amp;gt;response[0];
} while (!(r &amp;amp; OCR_ALL_READY) &amp;amp;&amp;amp; --tries &amp;gt; 0);

if (r &amp;amp; OCR_ALL_READY)
{
/* is it high capacity card */
g_card_info-&amp;gt;card_type |= (r &amp;amp; OCR_HC_CCS);
++state;
}
else
state += 6;
break;

case 5:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* CID polling */
case 15:
status = sdmmc_execute_command(CMD_ALL_SEND_CID, 0, 0);
memcpy(&amp;amp;g_card_info-&amp;gt;cid, &amp;amp;g_card_info-&amp;gt;response[0], 16);
++state;
break;

case 6:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* RCA send, for SD get RCA */
status = sdmmc_execute_command(CMD_SD_SEND_RCA, 0, 0);
g_card_info-&amp;gt;rca = (g_card_info-&amp;gt;response[0]) &amp;gt;&amp;gt; 16;
++state;
break;

case 16:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* RCA assignment for MMC set to 1 */
g_card_info-&amp;gt;rca = 1;
status = sdmmc_execute_command(CMD_MMC_SET_RCA, g_card_info-&amp;gt;rca &amp;lt;&amp;lt; 16, 0);
++state;
break;

case 7:
case 17:
status = sdmmc_execute_command(CMD_SEND_CSD, g_card_info-&amp;gt;rca &amp;lt;&amp;lt; 16, 0);
memcpy(&amp;amp;g_card_info-&amp;gt;csd, &amp;amp;g_card_info-&amp;gt;response[0], 16);
state = 100;
break;

default:
state += 100; /* break from while loop */
break;
}
}

/* Compute card size, block size and no. of blocks
&amp;nbsp;&amp;nbsp; based on CSD response recived. */
if (prv_card_acquired()) {&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /////****BRAKEPOINT******//////
prv_process_csd();

/* Setup card data width and block size (once) */
if (prv_set_trans_state() != 0)
return 0;
if (prv_set_card_params() != 0)
return 0;
}

return prv_card_acquired();
}
&lt;/PRE&gt; &lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;The recordings were made at the "///***BRAKEPOINT***///".&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Die Aufnahmen wurden beim "/////****BRAKEPOINT******//////" gefertigt.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried the how to understand but am only with moderate success.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Ich habe versucht die Funktionsweise nachzuvollziehen bin aber mit mäßigem erfolg nur.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Can someone help me?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Kann mir Jemand dabei helfen ?)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with friendly greetings&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(Mit Freundlichen Grüßen )&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Andreas Kullick&lt;/SPAN&gt;&lt;BR /&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 15 Jun 2016 19:12:57 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC4357-OEM-Board-Embedded-Artist-Filesystem-fpr-SD-MMC-Card/m-p/588897#M21867</guid>
      <dc:creator>lpcware</dc:creator>
      <dc:date>2016-06-15T19:12:57Z</dc:date>
    </item>
  </channel>
</rss>

