BlockoS / arduino-dataflash

Support for Atmel Dataflash for the Arduino
http://blockos.github.com/arduino-dataflash
23 stars 14 forks source link

Does not work under 1.0.3 #10

Closed BlockoS closed 9 years ago

BlockoS commented 11 years ago

see: http://blog.blockos.org/?p=27&cpage=1#comment-12965

julius-kimani commented 8 years ago

BlockoS I'm currently in a fix . I am working with at45db161d and your code is working ok.... I am writing "hello world " but when I try to read its reading numbers i.e 123456 that's just an example... how do I get back to read the word "hello world"

BlockoS commented 8 years ago

Hum... If I understood correctly, it looks like you are printing the ASCII values instead of the characters.

Let's assume that you wrote your string in the page 4 at the offset 0, and you want to display it on the serial bus.

const char* hello = "hello world";

uint8_t buffer = 0;
uint16_t page = 4;

// Write string
dataflash.bufferWrite(buffer, 0);
for(int i=0; i<strlen(hello); i++) {
    SPI.transfer(hello[i]);
}
SPI.transfer('\0');
dataflash.bufferToPage(buffer, page);

// Read string
dataflash.pageRead(page, 0);

for(int i=0; i<128; i++) {
    char c = static_cast<char>(SPI.transfer(0xff));
    if('\0' == c) {
        break;
    }
    Serial.print(c);
}
Serial.print('\n'):

I realize that some helper methods are missing. For example methods to get the page and buffer size.

julius-kimani commented 8 years ago

Hey , I really appreciate your feedback …it has worked for me . Thanks

From: MooZ [mailto:notifications@github.com] Sent: Tuesday, September 15, 2015 4:39 PM To: BlockoS/arduino-dataflash Cc: julius-kimani Subject: Re: [arduino-dataflash] Does not work under 1.0.3 (#10)

Hum... If I understood correctly, it looks like you are printing the ASCII values instead of the characters.

Let's assume that you wrote your string in the page 4 at the offset 0, and you want to display it on the serial bus.

const char* hello = "hello world";

uint8_t buffer = 0; uint16_t page = 4;

// Write string dataflash.bufferWrite(buffer, 0); for(int i=0; i<strlen(hello); i++) { SPI.transfer(hello[i]); } SPI.transfer('\0'); dataflash.bufferToPage(buffer, page);

// Read string dataflash.pageRead(page, 0);

for(int i=0; i<128; i++) { char c = static_cast(SPI.transfer(0xff)); if('\0' == c) { break; } Serial.print(c); } Serial.print('\n'):

I realize that some helper methods are missing. For example methods to get the page and buffer size.

— Reply to this email directly or view https://github.com/BlockoS/arduino-dataflash/issues/10#issuecomment-140323660 it on GitHub. https://github.com/notifications/beacon/ANn4WRVXTGhG3drDpcGaVUyjLWlmGuKBks5ox9CugaJpZM4AKStl.gif

julius-kimani commented 8 years ago

Hey MooZ ,

Hope you are fine. I would like to fill a whole page of at45db161d before I go to the next page. On the example in the library it just logs just 1 log and then proceeds to the next page. I am doing a data logging project . I will really appreciate

From: MooZ [mailto:notifications@github.com] Sent: Tuesday, September 15, 2015 11:39 AM To: BlockoS/arduino-dataflash Cc: julius-kimani Subject: Re: [arduino-dataflash] Does not work under 1.0.3 (#10)

Hum... If I understood correctly, it looks like you are printing the ASCII values instead of the characters.

Let's assume that you wrote your string in the page 4 at the offset 0, and you want to display it on the serial bus.

const char* hello = "hello world";

uint8_t buffer = 0; uint16_t page = 4;

// Write string dataflash.bufferWrite(buffer, 0); for(int i=0; i<strlen(hello); i++) { SPI.transfer(hello[i]); } SPI.transfer('\0'); dataflash.bufferToPage(buffer, page);

// Read string dataflash.pageRead(page, 0);

for(int i=0; i<128; i++) { char c = static_cast(SPI.transfer(0xff)); if('\0' == c) { break; } Serial.print(c); } Serial.print('\n'):

I realize that some helper methods are missing. For example methods to get the page and buffer size.

— Reply to this email directly or view https://github.com/BlockoS/arduino-dataflash/issues/10#issuecomment-140323660 it on GitHub. https://github.com/notifications/beacon/ANn4WRVXTGhG3drDpcGaVUyjLWlmGuKBks5ox9CugaJpZM4AKStl.gif

BlockoS commented 8 years ago

The end of your message is missing. I assume you want to do some kind of "double buffering". Meaning that you want to fill one of the buffer, while the other one is used to performed a buffer to page write. Unfortunately such thing is not possible for the moment. I'd need to look at the datasheet.

julius-kimani commented 8 years ago

Thanks for your response ,

I would like to save information on the page and Before I proceed to save on the next page I would like to fill the first page…i.e if page 1 is not full I the information will not be saved on the next

From: MooZ [mailto:notifications@github.com] Sent: Monday, October 26, 2015 4:05 PM To: BlockoS/arduino-dataflash Cc: julius-kimani Subject: Re: [arduino-dataflash] Does not work under 1.0.3 (#10)

The end of your message is missing. I assume you want to do some kind of "double buffering". Meaning that you want to fill one of the buffer, while the other one is used to performed a buffer to page write. Unfortunately such thing is not possible for the moment. I'd need to look at the datasheet.

— Reply to this email directly or view https://github.com/BlockoS/arduino-dataflash/issues/10#issuecomment-151126646 it on GitHub. https://github.com/notifications/beacon/ANn4Wf_R9xWKOViQ-Dw9fcu3B1oekRWmks5o_hxngaJpZM4AKStl.gif

julius-kimani commented 8 years ago

Since each page has 512 or 528 bytes I would like to fill those bytes first before I go to the next page

From: MooZ [mailto:notifications@github.com] Sent: Monday, October 26, 2015 4:05 PM To: BlockoS/arduino-dataflash Cc: julius-kimani Subject: Re: [arduino-dataflash] Does not work under 1.0.3 (#10)

The end of your message is missing. I assume you want to do some kind of "double buffering". Meaning that you want to fill one of the buffer, while the other one is used to performed a buffer to page write. Unfortunately such thing is not possible for the moment. I'd need to look at the datasheet.

— Reply to this email directly or view https://github.com/BlockoS/arduino-dataflash/issues/10#issuecomment-151126646 it on GitHub. https://github.com/notifications/beacon/ANn4Wf_R9xWKOViQ-Dw9fcu3B1oekRWmks5o_hxngaJpZM4AKStl.gif