Sunday, November 19th 2017, 8:48pm UTC+1

You are not logged in.

  • Login
  • Register


Dear visitor, welcome to SEGGER Forum. If this is your first visit here, please read the Help. It explains how this page works. You must be registered before you can use all the page's features. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

Message information
Automatically converts internet addresses into links by adding [url] and [/url] around them.
Smiley code in your message such as :) is automatically displayed as image.
You can use BBCode to format your message, if this option is enabled.
Security measure

Please enter the letters that are shown in the picture below (without spaces, and upper or lower case can be used).

The last 4 posts

Thursday, March 9th 2017, 9:20pm

by Dave_A

[SOLVED] but I can't explain it... very well.

The code I used to send multi bytes of data to the MMC/SD card:

Source code

  /* Check flags to make sure SPI is idle */

  do {
	/* Send byte of data */
	SPI_SendData8(SD_CARD_SPI, *pData++);
	/* Wait for SPI complete send */
	/* Read data register */
  } while (--NumBytes);

Looks reasonable, right? Except, remember that the data register is a 16-bits in the STM32F303 (and others).

When I change the code to this:

Source code

	/* Read data register */

Everything works great. The call to function only reads 8-bits from the register and not 16 like I originally had. Again, it works but I can't really explain why reading the "throw away" data differently makes it work.

Credit given to Tilen Majerle for his SPI code that I adapted.

Thanks for the response. You were right... it was in the pfWrite code, but not how I imagined it would be.


Thursday, March 9th 2017, 9:57am

by SEGGER - Marius

Hello Dave,

We are not aware of this behavior.

The error messages suggest that the SPI data transfer is not working properly.
I suggest you to check first if the SPI controller is correctly configured:
- Data is sampled on the rising edge of the clock signal.
- The clock signal is HIGH in idle state.
You can find more information in the section " (*pfWrite)()" of the emFile manual.

Best regards,

Wednesday, March 8th 2017, 10:37pm

by Dave_A

I didn't think to check this yesterday, but I did today. The volume is mounted read/write.... so that's not it.

Wednesday, March 8th 2017, 5:38pm

by Dave_A

MMC_SPI - Reads but won't write

This problem really has me stumped.

I'm using emFile to interface a NAND flash and SD card on my own hardware. The NAND works perfectly, no issues.

The SPI MMC/SD is another issue. If my application allowed, I could probably stream a MP3 off of the SD card, but I can't seem to write to it. Yes, I have checked that the card is not write-protected.

This is what emFile is reporting:
FS error: MMC_SPI: _WriteSectors: Data not accepted.
FS error: MMC_SPI: _WriteSectors: Data not accepted.
FS error: MMC_SPI: _WriteSectors: Command not accepted.
FS error: MMC_SPI: _WriteSectors: Command not accepted.
FS error: LOGBLOCK: Failed to write sector(s): 0x000080FD-0x000080FD to "mmc:0:".

After this, the card is not accessible. For example, I can't do a directory listing. I have to remove the card, and re-insert it into the holder to gain access again.

These errors were obtained when I ran the sample code that just writes a simple text file. The file creation is successful, but the file is empty.

Some board specifics:
STM32F303VE processor running at 72Mhz.
(SPI3) SPI clock rate is 281khz as measured with a scope.
emFile version V4.04a

I have tried a couple different cards. Both had a FAT file system and when that didn't work, I formatted one of them to a FAT32 file system (didn't fix anything).

Any direction would be helpful. I'm not sure where to look.