9 years ago.

How to use SDcard in LPC4088DM ?

I want to save data from the external ADC as "AD.txt" to the SDcard. How to do that? I using the code as following to test the SDcard. It shows up the second code, was there something broke ?

 #include "mbed.h"
 #include "MCIFileSystem.h"
 
 MCIFileSystem mcifs("mci");
 
 int main() {
     printf("Please insert a SD/MMC card\n");
     while(!mcifs.cardInserted()) {
         wait(0.5);
     }
     
     printf("Found SD/MMC card, writing to /mci/myfile.txt ...\n");
     
     FILE *fp = fopen("/mci/myfile.txt", "w");
     if (fp != NULL) {
         fprintf(fp, "Hello World!\n");
         fclose(fp);
         printf("Wrote to /mci/myfile.txt\n");
     } else {
         printf("Failed to open /mci/myfile.txt\n");
     }
 }

__attribute__ ((section(".after_vectors")))
void HardFault_Handler(void)
{
    while(1)
    {
    }
}
Be the first to answer this question.