cancel
Showing results for 
Search instead for 
Did you mean: 

STm32F205RBt6 as USB Host, interfacing code for pen drive

vindhyachal
Associate II
Posted on December 07, 2017 at 06:21

1. Need to interface pen drive with stm32f205rbt6 for logging data in text file in pen drive.

2. Generated code from stm32cube & link for total code is here:

https://community.st.com/external-link.jspa?url=https%3A%2F%2Fdrive.google.com%2Fopen%3Fid%3D1oJSXOmWXzn_xduLmcJWXdiNxtMTpdmtP

3. Made changes in fatfs.c file generated as below.

4. Problem is code always struk in if(FR_OK != res) & return disk_error always. What error I am doing.

5. is there any example code for STM32F2 using pen drive for storage purpose to see exactly where changes are to be made.

&sharpinclude 'fatfs.h'

uint8_t retUSBH; /* Return value for USBH */

char USBHPath[4]; /* USBH logical drive path */

FATFS USBHFatFS; /* File system object for USBH logical drive */

FIL USBHFile; /* File object for USBH */

FRESULT res;

/* USER CODE BEGIN Variables */

/* USER CODE END Variables */

void MX_FATFS_Init(void)

{

/*♯♯ FatFS: Link the USBH driver ♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯♯*/

retUSBH = FATFS_LinkDriver(&USBH_Driver, USBHPath);

/* USER CODE BEGIN Init */

/* additional user code for init */

/* USER CODE END Init */

res = f_mount(&USBHFatFS , USBHPath ,0U);

if(FR_OK != res)

{

while(1);

}

res = f_setlabel('DATA DISK');

if(FR_OK != res)

{

while(1);

}

res = f_open(&USBHFile, '/_SERIAL.txt', FA_OPEN_ALWAYS);

if(FR_OK != res)

{

while(1);

}

}

/**

* @brief Gets Time from RTC

* @param None

* @retval Time in DWORD

*/

DWORD get_fattime(void)

{

/* USER CODE BEGIN get_fattime */

return 0;

/* USER CODE END get_fattime */

}

#usb-host #stm32f205
1 REPLY 1
vindhyachal
Associate II
Posted on December 08, 2017 at 06:53

any update