SD card interface to read and write .csv file mode FAT32

General discussion on mikroC PRO for ARM.
Post Reply
Author
Message
dquy05
Posts: 40
Joined: 20 Apr 2014 11:00

SD card interface to read and write .csv file mode FAT32

#1 Post by dquy05 » 21 Oct 2021 13:26

Hi,

I need to write and read .csv or .xls files, writable to the rows and columns I want, as well as inset or delete rows and columns
With the program below, I can only write to row 1 and column 1

Code: Select all

  FAT32_ChangeDir("\\");                        // ve main
  FAT32_Close(0);

  FAT32_MakeDir("Test");                      // tao folder neu chua tao
  FAT32_ChangeDir("Test");                    // mo folder ra de truy cap vao file text

  fhandle = FAT32_Open("123.csv",FILE_WRITE);   //tao file
  FAT32_Write(fhandle,"98765", 5);
  FAT32_Close(fhandle);
Wish to have a help from your guys
Many thanks!

sgssn
Posts: 36
Joined: 13 Sep 2021 16:24

Re: SD card interface to read and write .csv file mode FAT32

#2 Post by sgssn » 23 Oct 2021 16:09

Hello
it seems, that this is the wrong function for your purpose. This function does not support a position in the file you want to write.
I am not familiar to the functions you have available, but i think you need a function, that writes a designated part of your RAM to the SD-CARD. In this RAM you can define positions as demanded by Excel. TAB is often used to separate columns.

regards
Gerhard

dquy05
Posts: 40
Joined: 20 Apr 2014 11:00

Re: SD card interface to read and write .csv file mode FAT32

#3 Post by dquy05 » 24 Oct 2021 09:47

sgssn wrote:
23 Oct 2021 16:09
Hello
it seems, that this is the wrong function for your purpose. This function does not support a position in the file you want to write.
I am not familiar to the functions you have available, but i think you need a function, that writes a designated part of your RAM to the SD-CARD. In this RAM you can define positions as demanded by Excel. TAB is often used to separate columns.

regards
Gerhard
Hello
Yes, thanks for your support, currently I am also using internal Ram to process data, but due to the data is too big, internal Ram is not enough, if using external Ram, it takes a lot of In-Out, convenient Here I want to ask, is it possible to use Flash chips (eg W25Q80) to replace external Ram?

Many thanks!

sgssn
Posts: 36
Joined: 13 Sep 2021 16:24

Re: SD card interface to read and write .csv file mode FAT32

#4 Post by sgssn » 24 Oct 2021 14:38

Yes, sure, but FLASH-chips, i think are slower than RAM. There are also SPI-RAM chips available: f.e.:
https://www.digikey.de/de/product-highl ... am-devices

You dont need to erase, you only write and read.

Your code above was written for use with a SD-CARD? This is also possible. You can write a SDCARD in SPI-mode, using RAM-sizes of 512Byte. When you have that size available, you also can use it to save data. But you need a function, that writes that amount of RAM onto your SD-card.

Gerhard

dquy05
Posts: 40
Joined: 20 Apr 2014 11:00

Re: SD card interface to read and write .csv file mode FAT32

#5 Post by dquy05 » 24 Oct 2021 15:14

sgssn wrote:
24 Oct 2021 14:38
Yes, sure, but FLASH-chips, i think are slower than RAM. There are also SPI-RAM chips available: f.e.:
https://www.digikey.de/de/product-highl ... am-devices

You dont need to erase, you only write and read.

Your code above was written for use with a SD-CARD? This is also possible. You can write a SDCARD in SPI-mode, using RAM-sizes of 512Byte. When you have that size available, you also can use it to save data. But you need a function, that writes that amount of RAM onto your SD-card.

Gerhard
Hi !

You are right, currently I am also communicating with Sd card using RAM-sizes of 512Byte, works fine, but that is not enough (I need about 1MByte), also with flash chip (W25Q80), I see max spi clock is 416Mhz, while The Spi SRAM you recommend me to use is 20Mhz, but I think all of them are as slow as when communicating directly with the sd card, maybe I'll have to use external Ram duplex,
Do you have any better ideas to help me out?

Many thanks!

sgssn
Posts: 36
Joined: 13 Sep 2021 16:24

Re: SD card interface to read and write .csv file mode FAT32

#6 Post by sgssn » 24 Oct 2021 15:34

Im not so familia to external storage, that i know by sure that they allow access to a single byte. So every solution depends on a dedicated size, for example 512Byte of your SD-card. You write 512Byte at one time and read 512Byte at one time. But SDcards have 4GB and more, so that should be enough. And if you have problems implementing a FAT-Filesystem, you can create your own. You only adress a "peace of the cake" with a size of 512Byte.

Gerhard

dquy05
Posts: 40
Joined: 20 Apr 2014 11:00

Re: SD card interface to read and write .csv file mode FAT32

#7 Post by dquy05 » 25 Oct 2021 02:02

sgssn wrote:
24 Oct 2021 15:34
Im not so familia to external storage, that i know by sure that they allow access to a single byte. So every solution depends on a dedicated size, for example 512Byte of your SD-card. You write 512Byte at one time and read 512Byte at one time. But SDcards have 4GB and more, so that should be enough. And if you have problems implementing a FAT-Filesystem, you can create your own. You only adress a "peace of the cake" with a size of 512Byte.

Gerhard
Hello

My problem is that, I need to write 1MByte at one time and read 1MByte at one time (because my data is like excel sheet, when delete data in line number N, all data then gets lost change accordingly), so the STM32 will need 1MByte of internal Ram to store and edit data and then write to the memory card, while the STM32's internal Ram is only about 200KByte.
But I believe there will be a solution to this problem, I will keep thinking, when there are good results, I will post them here.

Many thanks!

sgssn
Posts: 36
Joined: 13 Sep 2021 16:24

Re: SD card interface to read and write .csv file mode FAT32

#8 Post by sgssn » 25 Oct 2021 05:51

Hello
understand. But to get real 1MByte RAM it would be necessary to have the complete CPU-Bus lined out. Older uC like the 80C167 had this option. But for 1MByte you need 20 Adresslines. I dont know these STM32-uC. Perhaps there are some which can make the bus available "outside".

Gerhard

sgssn
Posts: 36
Joined: 13 Sep 2021 16:24

Re: SD card interface to read and write .csv file mode FAT32

#9 Post by sgssn » 25 Oct 2021 08:44

Hello again
does your uC support FSMC? I just read, that this would be the external BUS for external RAM:

https://www.st.com/content/ccc/resource ... 200423.pdf

Gerhard

dquy05
Posts: 40
Joined: 20 Apr 2014 11:00

Re: SD card interface to read and write .csv file mode FAT32

#10 Post by dquy05 » 25 Oct 2021 15:06

sgssn wrote:
25 Oct 2021 08:44
Hello again
does your uC support FSMC? I just read, that this would be the external BUS for external RAM:

https://www.st.com/content/ccc/resource ... 200423.pdf

Gerhard
Hi,

Thank you for your kind help, FSMC is a good idea, and the chip I am using is also supported, but I will learn more about the new chip STM32H7, it has 1MByte of RAM inside, I think it will be faster and more convenient than FSMC with external RAM

Many thanks!

Post Reply

Return to “mikroC PRO for ARM General”