News:

;) This forum is the property of Proton software developers

Main Menu

Best/biggest/easiest way to store data in RAM or EEPROM

Started by Amateurtje, Apr 16, 2023, 06:49 AM

Previous topic - Next topic

Pepe

Put
Print At 1,9,Dec3 SD_Buffer0_Intern[i]
no
Print At 1,9,Dec3 SD_Buffer0_Intern[1]

Amateurtje

#41
but then it will show the complete  buffer?? it is not that i wat to see the whole buffer, the problem is that when reading, it does not go down,, therefore the saving or the reading of this variable goes wrong....

I just use the 1 to see one of the values in the buffer to check if it changes... the 1 or any number is just a choice for a check..

Frizie

You have:
FOR i = 256 TO 1000 STEP - 1

What you should do is:
FOR i = 1000 TO 256 STEP - 1
or
FOR i = 1000 DOWNTO 256
Ohm sweet Ohm | www.picbasic.nl

Amateurtje

Quote from: Frizie on May 02, 2024, 05:23 PMYou have:
FOR i = 256 TO 1000 STEP - 1

What you should do is:
FOR i = 1000 TO 256 STEP - 1
or
FOR i = 1000 DOWNTO 256

Thanks frits, but that is not relevant for the problem. This was even a unused piece of code from an old test. The variable on 1,9 shows that there is no read or no write action.... But can the SD script for write sector be used like this???

Amateurtje

I have made a zipfile with the small program.

The goal is to write to an address on a SD card some information (512 bytes) and that I can read that information back from that address.

I need a bit less than 512 bytes but that is the size of a sector as far as I understand, so, to make it easier (I hoped) I choose to read and write a complete sector..

Can anybody take a look at it while I am soooo stuck..

The numbers are chosen arbitrairy... but you can see that the chosen testvalue "SD_Buffer0_Intern[1]" stays the same during reading, independend from the address (or is the same for all addresses)....


Pepe

simulation in proteus with corrected source

Amateurtje

Quote from: Pepe on May 03, 2024, 02:20 PMsimulation in proteus with corrected source

Wow, Thanks very much.. IT works!!Great..
I never learned how to use that and always test on physical board.

What was wrong? Did I do something stupid (probably :) )?

Is it correct that a  1 GB SD card has approximately 2,097,152 sectors of 512 bytes each? So I can use the addresses up untill that number.. a 2 GB SD card has the double amount / (aprr 4 million?).

A bigger card than 2 Gb can not be read, correct?

It is for a datalogger .
I want to write around 3 sectors a  second.
For 75 stages/Trips.

So that gives for 1Gb card:
                                        2097152    Sectors
75 stages:                         27962    Sectors per stage
3 Lines per second:           9320    Seconds per stage
/60:                                         155    minutes per stage
/60:                                          2,5    hours per stage

Is that about correct?

Pepe

You must use SD_Sector_Num_Intern as a parameter in the read or write subroutines no SD_Address_Intern

Amateurtje

Quote from: Pepe on May 03, 2024, 03:49 PMYou must use SD_Sector_Num_Intern as a parameter in the read or write subroutines no SD_Address_Intern

Maybe not too smart of me.. Thanks soo much...

Pepe

I think it also works on 1GB

Amateurtje

What do you mean with 128SD? An 128Gb SD card? That would be very big...

I am going to try.. I think i have some laying around and otherwise I will order some..

 

Amateurtje

with my 1Gb card I have a maximum sector address of 1.966.078. Above that, it does not read and write anymore. it lost connection, it seemed.

As far as I understand is that the first addresses are also unusable so therefore I kept the first 256 unused.... Is that correct?

To be flexible when using a different SD card,it might be nice if it can see the maximum number of sectors which can be used. So, it does it keeps on working and i cna use the maximum amount of space.

There are some variables that are made in the connection script:

The following values I get for some variables which I hoped were possibly related to the maximum usable sector address but I do not see the relation with my number 1.966.078
"SD_Secs_Per_Cluster"       00245
"SD_Reserved_Secs"          63.478
"SD_Secs_Per_FAT"           65.534
"SD_Num_of_FATs"             00248
"SD_Num_of_Secs"      5.207.048
"SD_Bytes_Per_Sec"          62.707
"SD_Last_Cluster"             33.992

Can anybody help me how I can find the maximum usable sector address?


Pepe

with 1gb it should reach 2097150 sectors as shown in the simulation

Amateurtje

As I also thought, an 1 gb sd card should have 2097152 sectors. a 1Gb card gives in your computer also always a lot less.. The 1 Gb cards I have here are not of a special brand or anything, but I doubt if that is the problem..

In your script, like I saw also, the higher numbers are "written" very slowly, and when reading they are also slow and give all the same values.

So therefore I think these addresses are maybe there, but can not be used. Only in theory, but not in practise..
Therefore it would be nice to know untill what address they really can be used in practise.

John Drew

There are also many fakes about that pretend to be much larger than they are.
Be wary and buy from reputable sellers.

charliecoutas

I've now had a couple of MicroSD cards that start OK, run for many months, then just stop working.
I think it's what you suggest John, cheap fakes.

Charlie

Amateurtje

Yes,  but if you want to find a 1 or 2 Gb SD card, there is no shop were you can find them anymore except Alie....... I tried to buy some because I did not want to wait, but......

And this script only worked up till 2 or 4 Gb (I forgot). the older definition of SD card.... I also recieved some 1 Gb but they were of the newer format and did not work also....

keytapper

I'd like to point out that 2 Gb is the limit of FAT32.
Ignorance comes with a cost