cancel
Showing results for 
Search instead for 
Did you mean: 

The problem of simultaneous access to the data SD-card with a PC and a MCU with FATFs.

trooper_bass
Associate II
Posted on June 12, 2015 at 18:24

For access to the data SD-card from side the MCU is used a FATFs technology. From the PC side is used USB mass storage device (MSD) with direct access to data from SD-card without FAT system on the MCU. 

To guarantee only one access to methods SD card is used following code:

HAL_NVIC_DisableIRQ(OTG_FS_IRQn); 

if(SD_state == MSD_OK)

{

/* Write block(s) in DMA transfer mode */

if(HAL_SD_WriteBlocks_DMA(&hsd, pData, WriteAddr, BlockSize, NumOfBlocks) != SD_OK) 

{

SD_state = MSD_ERROR;

}

else

{

SD_state = MSD_OK;

}

}

HAL_NVIC_EnableIRQ(OTG_FS_IRQn); 

When MCU is create or modify files on SD-card, data in the browser from the PC side don't updated. It's refresh is only when plug of USB cable is remove and insert. How can i update data on the browser without remove and insert of a USB cable?

4 REPLIES 4
Posted on June 12, 2015 at 18:41

I guess you'd need to write some Windows drivers and file system drivers to manage the incoherency you've caused.

You could get the MSC to throw a SENSE ERROR indicating that the media changed?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
trooper_bass
Associate II
Posted on June 13, 2015 at 18:29

My device is doing some measuring and have saved results on the SD-card. When measure is finished i can reset MSD to show Windows browser is data have been changed. I can't understand what is SENSE ERROR, where can i find it? 

Posted on June 13, 2015 at 19:04

You'd want to review the SCSI command protocol used here, probably the ATAPI/MMC specification, which breaks down a list of SENSE CODEs the device can throw in case of error or status conditions it wishes to tell the PC side driver stack.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
trooper_bass
Associate II
Posted on June 13, 2015 at 19:47

I saw all file usbd_mcs_scsi.c, but can't find any command for my task.