cancel
Showing results for 
Search instead for 
Did you mean: 

Two mcu's accessing sdcard

con3
Senior

Hey everyone,

I have an stm32f722ze, The sdcard driver seems to be working well although I have a weird issue.

I have a secondary mcu that also needs to access the sdcard.The secondary mcu can succesfully mount and unmount the sdcard multiple times, although as soon as the stm mounts the sdcard, the secondary mcu can not mount the sdcard at all. I do close the file, unmount and unlink the driver, but it doesn't seem to work. As soon as I erase the flash of the stm, the secondary mcu access the sdcard without issue. How could I resolve this?

Here's an example of a test snippet, after this executes, I'm assuming that the stm has left the sdcard, although it seems the stm seems to hold onto it.

void SDcard(void) {
	FATFS_UnLinkDriver(SDPath);
	FATFS_LinkDriver(&SD_Driver, SDPath);
	mount_ret = f_mount(&SDFatFS, SDPath, 1);
	if (mount_ret == FR_OK) {
		open_ret = f_open(&SDFile, "test.txt", FA_CREATE_ALWAYS | FA_WRITE);
		f_close(&SDFile);
		umount_ret = f_mount(&SDFatFS, SDPath, 1);
	FATFS_UnLinkDriver(SDPath);
 
	}
 
}

The second mount call should unmount the sdcard as far as I know and then I unlink it.

Thanks in advance for any help!

1 ACCEPTED SOLUTION

Accepted Solutions

Debug things, perhaps use a scope or logic analyser to determine the state of the bus/pins.

Make sure the unmount/unlink tristate the pins, and deinitialize the interface completely. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

View solution in original post

3 REPLIES 3

Debug things, perhaps use a scope or logic analyser to determine the state of the bus/pins.

Make sure the unmount/unlink tristate the pins, and deinitialize the interface completely. ​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
con3
Senior

Hi @Community member​ !

Thank you for the reply.

I was worried that the method I was following to release the sdcard wasn't correct.

I'll have a look what the function does with the pins when it unmounts.

What do you mean when to refer to this: "deinitialize the interface completely"

How would I know if this has happened?

Thanks for all the help!

con3
Senior

Hi @Community member​ ,

I found the issue,

You were correct about the pins, After unmounting and unlinking the driver, the de-initiation function need to be called, after which it works like a charm!

When the sdcard is used again, it just needs to be initiated again