ESP32 _ESP32_SDMode (4Bit) OpenFile return

For general Flowcode discussion that does not belong in the other sections.
stefan.erni
Valued Contributor
Posts: 758
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by stefan.erni »

Hi Ben

SD_Component: ESP32_SDMode (4Bit):
Snag_1500405.png
Snag_1500405.png (8.64 KiB) Viewed 263 times
It's working perfect ESP32_SD Mode (4Bit) AppendIntAarayToFile.


SD_Component:File SD/SDHC
Snag_14e35bd.png
Snag_14e35bd.png (6.6 KiB) Viewed 263 times
So I tested the "normal SD-component" as well. Something is not working properly there.
One part of the integer is always dec 61 an "a"

Testet with the same macro but alway an "a":
Snag_145638f.png
Snag_145638f.png (27.5 KiB) Viewed 263 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by BenR »

This one is odd, I can't see anything obviously wrong and I exported and imported the macro for the SD mode component so it's very odd. Please can you just double check your array your passing in is a INT type array.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by stefan.erni »

Hi Ben

Yes This one is odd.

Variable a have used:
Snag_556b0ae.png
Snag_556b0ae.png (25.6 KiB) Viewed 253 times
Command a have used:
Snag_5573d9c.png
Snag_5573d9c.png (30.81 KiB) Viewed 253 times
I get the same as yesterday

so I made a new test and used Byte Array, Int Array and Long Aarray
Also I reduced to 16 numbers so it' easy to read in the file later
Snag_566ed0d.png
Snag_566ed0d.png (19.18 KiB) Viewed 253 times
Snag_5587bd9.png
Snag_5587bd9.png (35.79 KiB) Viewed 253 times
I open it with a HEX editor, a very practical tool
Result Byte Array is ok, Int Array and Long Array has a little problem:
:
Snag_56373b5.png
Snag_56373b5.png (30.9 KiB) Viewed 253 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by BenR »

Many thanks for that, it helped.

I've found the problem, I'm using the type conversion to get the bytes but this is then being used again inside the append byte and so the value gets corrupted.

I've put a new version on the library updates for you now that should solve the problem by reloading the type conversion INT/LONG/FLOAT value before getting each byte.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by stefan.erni »

Hi Ben


Perfect! It's working fine.

Now I just have one small problem left, with this hardware. I have already written a post that something is wrong with the SPI clock. Display and SD-Card are on the same Spi- Bus and I have to set the clock to the slowest clock from the SD-Card initial. That makes it slow. With the FC9 it was different. There the clock setting worked. Can you do something about it.
I suspect set sd initial clock no longer works
Snag_5dce4a3.png
Snag_5dce4a3.png (17.39 KiB) Viewed 236 times
https://flowcode.co.uk/forums/viewtopic ... 9&start=10



Test with Arrays is perfect!:
Snag_5dad480.png
Snag_5dad480.png (33.44 KiB) Viewed 236 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by BenR »

As for your SPI speed issue the difference between v9 and v10 could just be the order of the components in the project. There was a change for v10 which meant that shared peripherals like the SPI now only produce one set of code instead of having two or more sets of code that essentially did the same thing and controlled the same registers.

I assume that the order of things at the moment looks like this.

Display starts up and sets the base SPI rate.
SD Card initialises and the initial speed setting appears to be being ignored. I'll look into this.
High speed mode kicks in and the SPI rate is altered.

Please could you try Display - 5MHz, Initial - 5MHz and High speed 10MHz. This should startup the display and the SD card at the correct low speed and then the SPI clock should jump to 10MHz for everything. If this works then you can try increasing the high speed setting further.

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by BenR »

Aha right the SD initial rate in v10 was being ignored if the SPI channel was already initialised by something else e.g. the display.

So I've hopefully solved this now in the latest version and the low speed mode should be imposed.

So this will now happen.

Display starts up and sets the SPI clock to the display setting.
SD card initialises and sets the SPI clock to the initial speed.
If SD card init is ok then SPI clock will be increases to the high speed setting. The display and SD operations will now operate at this high speed setting.

You can now try this.

Display - 10MHz, Initial - 5MHz and High speed 10MHz, if this works ok then you can increase the Display and High Speed settings.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by stefan.erni »

Hi Ben

Yes the display is working with 32Mhz (with 35Mhz not anymore) so I set to 30Mhz.
That's great! The card still init.

If i set the Initial 1Mhz and Highspeed to 8Mhz, the card init is ok.

But if I set Initial 1Mhz and Highspeed to 10Mhz the cards does not init anymore.
Actually I'm only testing whether the card is init or not.
I have not read or written data.
Maybe the hispeedmode switches not correct? too early?
This is just an idea.


Card does not init:
Snag_666da43.png
Snag_666da43.png (15.59 KiB) Viewed 219 times

How I test: In a loop 10x with a delay of 500mSec to init the card. No data to read/write
Attachments
Snag_669bae5.png
Snag_669bae5.png (46.8 KiB) Viewed 219 times

BenR
Matrix Staff
Posts: 1739
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 440 times
Been thanked: 603 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by BenR »

8MHz seems to be a bit slow but could potentially be down to the SD card you're using or maybe the wiring to the card if you're using flying leads. I've happily had 20MHz + working on a custom PCB.

stefan.erni
Valued Contributor
Posts: 758
Joined: Wed Dec 02, 2020 10:53 am
Has thanked: 149 times
Been thanked: 171 times

Re: ESP32 _ESP32_SDMode (4Bit) OpenFile return

Post by stefan.erni »

Hi Ben

The card is working in ESP32_SD_Mode 4Bit perfect with the maximal speed I can choose 40Mhz .
So this is a very good solution with Flowcode.

The same type of card is working in my hardware with a PIC32MZ on 50Mhz.
I'm recording a lot and most time 8 hours nonstop.
This is a very stable and reliable solution with Flowcode

I don't know why I have problems with this board, card and ESP32.
It is a purchased hardware in a case.
From 8Mhz to 20Mhz or 40Mhz would be good,
but it's not that bad. A doubling of the clock frequency does not necessarily mean a doubling of the write speed.

One small remark. The PIC32MZ also has a Quad Serial Peripheral Interface (QSPI) :)
Perhaps there will also be a component in the future.

Post Reply