Hello professors,
These days I'm trying to use SPI mode to write data directly into the sd card without the FATfs system, but now I'm facing some problems...
The standard size of each block in sd card is 512 bytes, it means everytime when the block is full, it will then write the data into the sd card. I tested the speed of this operation, each byte the spi buffer send is 14us, so the overall 512 bytes should be sent in around 5ms. However, my project requires me to speed up the writing speed to 1ms when I just transfer 35 bytes every time.. So, I decided to minimize the size of the block to 64 bytes, so the speed of the block is just around 1ms. But before that, I need to confirm whether my sd card block could be partioned or not. Thus, I need to use send_cmd(command byte cmd, argument arg), but I'm so confused about this function.
For example:
if(Timer1 && send_cmd(CMD24,0) == 0) //Timer is 50ms w
{
for (n = 0; n < 4; n++) ocr[n] = rcvr_spi(); //to get the data response which is 32 bit
ty = (ocr[1] & 0x20) ? 1:0; //to confirm the 21-bit of the csd register
}
After I checked the specification, I know that everytim when the master send the command byte(6 bytes) to the sd card, firsly the master will get the command response from the (R1,R2,R3...) , but after I don't exactly what the data response I will get. The argument I send is 0, so the sd card will give me the same response 0? but I foud it is not... so my question is what's the relationship between the argument I send and the data response, how do I know the exactly the data response?
Hope my question is clear to you, thanks for your patience and time
looking forward to your reply
Best regards