ESP32 4Bit SD-Mode Init problem

Any bugs you encounter with Flowcode should be discussed here.
medelec35
Matrix Staff
Posts: 1950
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 624 times
Been thanked: 656 times

Re: ESP32 4Bit SD-Mode Init problem

Post by medelec35 »

Hi Stefan.
Apologies for the delay.
I will make this a priority to sort the issue out for you.
Martin

medelec35
Matrix Staff
Posts: 1950
Joined: Wed Dec 02, 2020 11:07 pm
Has thanked: 624 times
Been thanked: 656 times

Re: ESP32 4Bit SD-Mode Init problem

Post by medelec35 »

Hi Stefan.
I have thoroughly looked into this.
Unfortunately, the write functions are not supported, which is the reason they don't work correctly.
Many thanks for bringing this to our attention.

What I'm going to do is check all the functions, and if not supported I will add a tooltip with states its not supported.
Martin

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

Thanks Martin
if the Sd-card works fast enough, I can do without some modes.

I guess these 3 points would already help me, to store data fast enough.

1. change to the next sector much faster
2. SPI clock should work and set to 50Mhz as an option
3. 4Bit mode working (there is no difference to 1Bit detectable)

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

1. change to the next sector much faster

It would already help if this time was reduced by half. It's just a change to the next sector

reduce the "orange" time:
2025-03-12_16-36-12.PNG
2025-03-12_16-36-12.PNG (150.42 KiB) Viewed 3169 times

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

I made a second version of my programme. I have used the normal SD card component and am testing it now with this
I have replaced all commands.
i guess it is slow but i can maybe write sectoren with 512byte like by the PIC32

The pins are like this:
2025-03-13_17-16-30.PNG
2025-03-13_17-16-30.PNG (221.03 KiB) Viewed 3068 times
config the Sd component:
2025-03-13_18-03-47.PNG
2025-03-13_18-03-47.PNG (35.76 KiB) Viewed 3068 times
add 2 pins and set to high
2025-03-13_18-04-53.PNG
2025-03-13_18-04-53.PNG (5.89 KiB) Viewed 3068 times

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

I can write sectors with the old SD component, is this also possible with the 4bit SD component?
And can the 4Bit Sd component also work on an STM32?

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

any news on the points yet?

1. change to the next sector much faster
2. SPI clock should work and set to 50Mhz as an option
3. 4Bit mode working (there is no difference to 1Bit detectable)

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Martin

I looked at the writing on the disk again and noticed something even worse.
I always write the same amount of bytes to the disk. Once it takes 54uSec then after 2-3 times it takes 1.12mSec and then also once 3.25mSec.
So 60 times longer. This always happens at regular intervals.
These 3.25mSec rarely but regularly.
It prevents me from being able to sample and save easily with 480Hz (2.08mSec)

Osciloscope I measured the other values separately in order to have the exact duration.
2025-05-15_16-03-25.PNG
2025-05-15_16-03-25.PNG (156.94 KiB) Viewed 493 times

BenR
Matrix Staff
Posts: 1936
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 506 times
Been thanked: 688 times

Re: ESP32 4Bit SD-Mode Init problem

Post by BenR »

Hi Stefan,

I'd probably need to see your program to be able to comment.

One thing could be the ESP IDF adding delays. Are you writing byte by byte? It might be better if you can put in an array in one go as the SD mode likely uses DMA to write to the card in a burst and writing byte by byte probably doesn't allow the DMA to run efficiently.

stefan.erni
Valued Contributor
Posts: 1009
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 192 times
Been thanked: 217 times

Re: ESP32 4Bit SD-Mode Init problem

Post by stefan.erni »

Hi Ben

I will prepare a program to post.

I always append a string with length 147Byte and that works perfectly.
Hour-long recordings succeed.
Writing (append) a string 147Byte without changing sector or cluster takes only 54uSec (2.7Mbyte per Second?)
Writing with changing sector or cluster takes 3.25mSec (45Kbyte per Second?)

Do you remember a few years ago my PIC32 with SD-Card?
I had some problems with the SD-Card speed and you reduced the time to change sector and cluster.

My goal is to sample at 480hz and save to csv. I am making another device that samples at 8Khz and generates wave files

Actual result of recording with 120Samplerate on ESP32 are perfect!
2025-05-16_11-11-07.PNG
2025-05-16_11-11-07.PNG (67.46 KiB) Viewed 295 times

Post Reply