2015-01-03 02:37 PM
Hello all,
While using USB as a mass storage (STM32L MSC, FS_Device_Lib_4.0), can MCU read PC system time and update RTC date/time accordingly?Any idea how to do that or any sample code? USB MSC configuration for STM32L is [DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/windows%20gets%20hanged%20in%20USB%20MSC%20%28with%20uSD%29%20example&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx?Paged%3DTRUE%26p_StickyPost%3D%26p_DiscussionLastUpdated%3D20151229%252018%253a19%253a42%26p_ID%3D61589%26View%3D%257bF47A9ED8%252dE726%252d42BE%252dACED%252d732F13B66581%257d%26FolderCTID%3D0x012001%26PageFirstRow%3D41¤tviews=27]here.Thanks in advance.2016-01-03 04:21 PM
While using USB as a mass storage (STM32L MSC, FS_Device_Lib_4.0), can MCU read PC system time and update RTC date/time accordingly?
No the mechanics really don't work in that direction. If you wanted anything from the PC you'd have to write an application or device driver.If the PC writes to the file system structures of the media, you could potentially fish the time stamp out of a file name entry to the directory.2016-01-03 04:55 PM
Thanks, from PC side, I may write Time-stamp to a text file. Another thing:
At the start-up, my code checks whether USB cable is plugged in or not, it'll halt code execution if plugged, bypass if not plugged. What's necessary to change here to resume execution immediately after USB unplugged (without reset). Timing accuracy might be a concern. Thank you again. USB_Conf(); delay_us(45000); // Minimum 45ms needed here for USB port to get configured while(bDeviceState == CONFIGURED) { } // Halts for read write from PC side. ........ ........ ret=f_open(&fil,''Timestamp.txt'',FA_READ); // Sample code starts for text file read ret=f_read(&fil, buffer, sizeof(buffer),&br); sscanf(buffer, ''%d %d %d'',&RTC_TimeStructure.RTC_Hours,&RTC_TimeStructure.RTC_Minutes ,&RTC_TimeStructure.RTC_Seconds); // sample read from text file .......