8 years, 3 months ago.  This question has been closed. Reason: Off Topic

multi-sector sd card read stops after 33 sectors

I am using sd card manipulation in RAW data (i.e. no file system). And for read and write the only software i found is https://developer.mbed.org/users/cicklaus/code/FinalProgram/ from which i took only SDCard.h and SDCard.cpp.

The problem is that the multi block read (specific method of SDCard.cpp) does not work so i thought i can test it another way: in a for loop i am doing single sector read for the next 100 sectors. What i am not understanding is the code stops after reading 33 sectors. Can someone help me in that. Why cant i read as much sectors as i need?

the code i wrote is:

#include "mbed.h"
#include "SDCard.h"
#include <string>
#include <string>

Serial pc(SERIAL_TX, SERIAL_RX);
SDCard sd(PA_7, PA_6, PA_5, PB_6, "sd");

std::string convertToString(unsigned char newdata) {
	std::string str;
	str.append(reinterpret_cast<const char*>(newdata));
	return str;
}

std::string convertToString(unsigned char* newdata) {
	std::string str;
	str.append(reinterpret_cast<const char*>(newdata));
	return str;
}

int main() {
	pc.baud(115200);
	for(int i=3; i>0; i--)
	{
		pc.printf("Wait %i seconds..\r\n",i);
		wait(1);
	}

	unsigned int baseddress = (unsigned int) (0x0001A000);
	for (int i = 0; i < 100; i++) {
		if (i != 0 && i % 8 == 0) {
			pc.printf("waiting before read chunk: %d ... \n", i);
			wait(1);
		}
		unsigned int newaddress = baseddress + i * 512;
		unsigned char* newdata = new unsigned char[512]();
		unsigned char result = sd.Read(newaddress, newdata);
		std::string str = convertToString(result);
		pc.printf(("Read result : <" + str + ">\n").c_str());
		str = convertToString(newdata);
		pc.printf(("Read Content: %X : <" + str + ">\n").c_str(), newaddress);
	}
}

p.s. If anyone can point me to other examples/libs i can use for the sdcard manipulation in RAW format it would be great.