Hello,
can me help somebody, please?I have a problem with LPC 1837 with example periph_sdmmc.
I use settings/files this project in my program. I take a card outside from adapter and then I put card again into adapter. The program doesn't write anything on sd card after new inserting. I try to call the function App_SDMMC_Init and fmount after insert the card, but the problem is the same...
What I have to do to processor reads the card again?
I read the comment, that I have to restart the processor. But it isn't possible....
thx
Hi,
I will do it next time...
thank you
Hello,
thank you, I know, I made a case by nxp:smileyhappy:
Hi Jan,
Yeah, that's you!
I just get this community question two days ago.
Ok, if your problem is solved in the case, please help me to mark the correct answer to close this question.
Thank you!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
Hello Jan,
About this question, I meet a customer who have the same question as you in the last month, after he follow my step, he made the SD card reinsert work.
Now, I post my answer directly:
I already make the reinsert SD card works on my side now.
Two points need to do the modification.
1. sdmmc.c , main function.
Folder: lpcopen_3_01_keil_iar_nxp_lpcxpresso_1837\LPC43xx_18xx\examples_43xx_18xx\periph_sdmmc\src
After you take off the SD card, you need to do the reinitialization again.
NVIC_DisableIRQ(SDIO_IRQn);
Chip_Clock_Disable(CLK_MX_SDIO);
Chip_SDIF_DeInit(LPC_SDMMC);
App_SDMMC_Init();
NVIC_EnableIRQ(SDIO_IRQn);
2. fs_mci.c
Folder:lpcopen_3_01_keil_iar_nxp_lpcxpresso_1837\filesystems\fatfslpc
The disk_initialize can be modified like this:
DSTATUS disk_initialize(BYTE drv)
{
if (drv) {
return STA_NOINIT; /* Supports only single drive */
}
/* if (Stat & STA_NODISK) return Stat; *//* No card in the socket */
Stat = STA_NOINIT; // jjadd, do the FSMCI_Cardinit each time.
if (Stat != STA_NOINIT) {
return Stat;
}
#if !_FS_READONLY
FSMCI_InitRealTimeClock();
#endif
/* Initialize the Card Data Strucutre */
hCard = FSMCI_CardInit();
/* Reset */
Stat = STA_NOINIT;
FSMCI_CardInsertWait(hCard); /* Wait for card to be inserted */
/* Enumerate the card once detected. Note this function may block for a little while. */
if (!FSMCI_CardAcquire(hCard)) {
DEBUGOUT("Card Acquire failed...\r\n");
return Stat;
}
Stat &= ~STA_NOINIT;
return Stat;
}
I also attached these two file.
My code function is:
1. after reset, the code will read the MESSAGE.TXT which already in the SD card before insert it, and read the content in the MESSAGE.TXT.
2. wait the uart char input from the uart.
I use the LPCXpresso LPC18S37 board on board virtual com port.
After input the char, the code will do the reintialization again.
3. I test the code by take off the SD card, and insert it again, then input the char, the code will printf:
1Opening jjHello.TXT from SD Card...Done.
Opening jjHello1.TXT from SD Card...Done.
It means I can create jjhello.txt, and jjhello1.txt file in the SD card.
After delete all the file in the SD card, and test it again, I find even I take off the sd card, and insert it again, I can work successfully, no error happens.
On you side, I think you can detect the SD card insert pin, if you get the SD card has been take off, you can do the SD card reintialization again.
More details, please check my attached .c file.
Wish it helps you!
If you still have question, please let me know!
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------