2017-02-20 01:57 PM
Everyone,
How can I use cubeMX for SDcard ? I have generated for MDK but :
this function doesn't work , from UM1721
User manualDeveloping Applications on STM32Cube with FatFs page 21.:
uint32_t wbytes; /* File write counts */
uint8_t wtext[] = 'text to write logical disk'; /* File write buffer */if(FATFS_LinkDriver(&mynewdisk_Driver, mynewdiskPath) == 0){if(f_mount(&mynewdiskFatFs, (TCHAR const*)mynewdiskPath, 0) == FR_OK){if(f_open(&MyFile, 'STM32.TXT', FA_CREATE_ALWAYS | FA_WRITE) == FR_OK){if(f_write(&MyFile, wtext, sizeof(wtext), (void *)&wbytes) == FR_OK);{f_close(&MyFile);}}}}FATFS_UnLinkDriver(mynewdiskPath);This variable :
&mynewdisk_Driver doesn't exist, which file is related ?
Thank you
2017-02-27 05:39 PM
Here you can find an example
https://github.com/nichtgedacht/mini-sys
You should really learn to analyze things by your self.
2017-02-28 02:18 AM
Yes I tried analyzing myself, but it seems that STM32CubeMX is not straighfoward, and,
Some question,
1. After I initialized SDIO with SDcard option, is it initialized already ?
2. I saw FATFs init as well on the code ? so if it's already initialized, SD card must be initialized, otherwise FATFs can not be initialized, I got until f_mount but can not do f_open ?
Confusing me...it would be nice if I used SDIO and FatFS in straightforward.
Thanks
2017-02-28 04:11 AM
what's this function for ??
MX_SDIO_SD_Init(); ??
2017-02-28 04:37 AM
I tried to follow the step on UM1718 page 193, but I think it's not working properly.. ??
Does it work at all ? Has it it been tested on Eval board from ST ? or just an abstract and confusing ST end user like me ?
2017-02-28 06:52 AM
I diagnosed until ff.c :
FRESULT f_open (
FIL* fp, /* Pointer to the blank file object */ const TCHAR* path, /* Pointer to the file name */ BYTE mode /* Access mode and file open mode flags */){ FRESULT res; DIR dj; BYTE *dir; DEFINE_NAMEBUF; printf('f_open function Line 2533 ff.c! \n'); ===> stop here for now#if !_FS_READONLY DWORD dw, cl;#endif2017-02-28 09:07 AM
>>I tried to follow the step on UM1718 page 193, but I think it's not working properly.. ??
Top level functionality of FatFs is predicated on the correct functionality of the block read/write layer below. If that can't perform a basic job of returning blocks previously written accurately and repeatedly then anything built on top is going to fail in some form or fashion. The manual describes FatFs usage on a board you aren't using, and is dependent on drivers below to be functioning correctly.
>>Does it work at all ? Has it it been tested on Eval board from ST ? or just an abstract and confusing ST end user like me ?
You are wasting your time debugging the FatFs level, this isn't the root of your problem, and doesn't have any chronic bugs. The confusion is mostly of your own making, validate the SDIO layer FIRST, the clocking and connectivity is important, but it is CRITICAL that blocks are read/written correctly, to the correct spot on the media, and with 100% reliability. It is like delivering mail, if you keep delivering to the wrong houses in the wrong streets, you are going to get fired. Or a taxi driver who always gets lost and has no sense of direction.
Do you have an ST EVAL board?
2017-02-28 01:36 PM
If this board doesn't work, it will not working with my old code for SDIO and USB mass storage,
It's working now with 16GB SDcard and USB as mass storage I can read and write file correctly...
I don't understand at all, probably I put a wrong speed for SDIO ?? any clues ? really confusing me..
2017-02-28 02:31 PM
1.I'm currently using STM32F103VET6 and it's my own board, so I need to trace the SDIO timing and connection ?
Any ideas how ?
I have USART1 as diagnostic
2. I have STM32F4 discovery and STM32F429 discovery board, will they help ? but I wanna make it work on STM32F103, because I have connected SDCARD module on it and tested with old STM32F103 library and it worked ok.
Making me confused, it's working with old code but not working with STM32CubeMX ??
2017-02-28 02:38 PM
Probably I put this clock too fast ? 0 = 24 MHz ??
2017-02-28 02:40 PM
This is from my Old code :
♯ define SDIO_TRANSFER_CLK_DIV ((uint8_t)0x3)
♯ define SD_DETECT_PIN GPIO_Pin_14 /* PB.14 */
♯ define SD_DETECT_GPIO_PORT GPIOB /* GPIOB */ ♯ define SD_DETECT_GPIO_CLK RCC_APB2Periph_GPIOB/**
* @brief SDIO Intialization Frequency (400KHz max) */ ♯ define SDIO_INIT_CLK_DIV ((uint8_t)0xB2) ♯ define SDIO_FIFO_ADDRESS ((uint32_t)0x40018080)Is there anything different with STM32CubeMX, where can I find this setting on STM32CubeMX generated code ? thanks Clive..