Close

Write speeds

A project log for Heartbeat Logger

A portable device that logs a snippet of your heart at the push of a button.

Ole Andreas UtstumoOle Andreas Utstumo 05/31/2019 at 15:082 Comments

I was unable to edit any files on the drive or format the drive itself untill I implemented the following function:

int8_t STORAGE_IsReady_FS(uint8_t lun)
{
  /* USER CODE BEGIN 4 */
	if(MMC_disk_status()==0)
		return (USBD_OK);
	else
		return USBD_FAIL;
  /* USER CODE END 4 */
}

 Now the drive can be formatted at will in Windows, and the data is persistent.

Nice, let's try copying a jpeg to the drive. 


Copying a 1.52 MB file to the newly formatted drive took a solid 1 minute and 13 seconds..

32STMCubeMX tells me I should have a baud rate of 2.0 MBits/sec, which equals approx 250 kB/s. Quite a bit of overhead there... Let's try a quick fix and crank up the clock speed. According to the datasheet for the flash IC, it should be able to handle 50 MHz. So let's set the SPI peripheral clock to 40 MHz and see what happens. I'm a bit too lazy to look up if the Prescaler in the CubeMX settings prescales the outbound SPI clock, or what it actually does, so let's start gently and increase the settings untill something breaks.

20 MBit / sec should give us a 10x speed increase. 

That didn't quite work... Let's turn the settings back for a second. The clock should not have surpassed what the SPI flash can handle..

Damn, looks like I broke something. 

Restoring the working project doesn't seem to cut it either. Now I'm stuck in a eternal loop waiting for the flash IC to clear it's busy flag...

Discussions

Ken Yap wrote 05/31/2019 at 23:03 point

That bit of C code can be simplfied to:

return MMC_disk_status()==0 ? USBD_OK : USBD_FAIL;

  Are you sure? yes | no

Ole Andreas Utstumo wrote 06/01/2019 at 09:26 point

You're right, thanks for the tip!

  Are you sure? yes | no