- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello community,
I'm trying to write to the microSD card as fast as I can. Unfortunately, there seems to be a considerable amount of time between each byte.
Oscilloscope showing the clock emFile.sclk0 clocking out bytes (ignore the upper line).
(Apologies for the low quality oscilloscope)
As shown above, the period time between bytes is nearly four times as much as the time it takes to clock out the byte itself. I assumed that emFile is inflexible and a hidden layer of the code, but the amount of time between bytes makes the write time quite long, even though my master clock (MASTER_CLK) is running at 48MHz. Is there any way of increasing the efficiency of writing short of getting a new file system module?
Thanks!
- Phoenix
Solved! Go to Solution.
- Labels:
-
PSoC 5LP
- Tags:
- emfile
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
As I was writing this question to the SEGGER forum, I suddenly realised the cause - which is less technical than it appeared to be.
This graph explains the gaps between the bytes.
The top line shows those "clumps" mentioned earlier, and the bottom is a pin I raise high during the sample-timer interrupt.
Since emFile writing is not interrupt-driven, my interrupt that triggers 10000 times a second pauses the writing. I hadn't realised how long is spent in the sample interrupt. Frustratingly, most of that time is spent writing zeros to the ADC so that it can be read (since SPIM is synchronous). Thankfully, sending those zero bytes via DMA makes the interrupt take much less time, and the oscilloscope now looks like this:
Much better!
Takeaways:
- emFile will stop writing for an interrupt of any priority
- using DMA with the SPI is much faster
Thanks for the replies Len, turns out it was my code that caused the issue - as usual.
- Phoenix