2018-06-06 03:18 AM
I have written some simple code (with the help of STM32CubeMx) for STM32F407VGTx to create a file in SDcard. Although it works perfectly with 407, it is not working with STM32F401ReTx. To be clear, I have generated code with CubeMx specifically for 401(did not use the code for 407).
Even for 407, I am able to work with only Version 21 of CubeMx and firmware version I have added the code below. Any ideas?
int main(void){ /* USER CODE BEGIN 1 */ /* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_DMA_Init(); MX_SDIO_SD_Init(); MX_FATFS_Init(); /* USER CODE BEGIN 2 */ if(f_mount(&myFatFS,SD_Path,1)==FR_OK) { HAL_Delay(1000); f_open(&myFil,'new document.txt\0',FA_CREATE_ALWAYS | FA_WRITE); f_close(&myFil); } /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */}
#f_mount-sdcard #stm32f401-nucleo #stm32f4 #stm32f401-fatfs #sdcard-stm32f4-sdio-fatfs
2018-06-06 04:12 AM
Top level code is not really very helpful.
Failure occurs in lower level code, or due to electrical connectivity of the card.
You should instrument the DISKIO and SDIO layer code.
Provide schematic of current wiring. You really what relatively short and consistent wire lengths. Pull-ups at the socket.
See if it is checking for a card detect pin.