Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 8 months ago.
LPC11u24 SDHC card hangs on fopen
Hi everyone I am hoping you can help me out.
I have a pcb I made with an lpc11u24 on it. I am trying to write to an sd card with this simple code:
#include "mbed.h" #include "SDFileSystem.h" SDFileSystem sd(P0_9, P0_8, P0_10, P1_23, "sd"); // MOSI, MISO, SCLK, SSEL Serial serial(P1_27, P1_26); DigitalOut led(P0_2); int main() { serial.baud(9600); wait(2); serial.printf("Hello World!\r\n"); wait(.2); FILE *fp = fopen("/sd/mbed.txt", "w"); fprintf(fp, "Hello World!\n"); fclose(fp); while(1) { while(serial.readable()) serial.putc(serial.getc()); led = 1; wait(0.25); led = 0; wait(0.25); serial.printf("Goodbye World!\r\n"); } }
When I run the code without an sd card connected, it gives the expected output
Quote:
Hello World! No disk, or could not put SD card in to SPI idle state Didn't get a response from the disk Set 512-byte block timed out
But when I connect the sd card to the bus, It will just print Hello World and then hang. I think it is stuck on the fopen command.
This code works fine on my mbed LPC1768 dev board (if I change pin numbers of course)
I have read a bunch, some people talk about this operation not fitting in the heap... idk I am hoping you guys and ladies can help!
Thanks a ton! -Eric