Troubles using microSD on SMARTGPU2 as storage device.

Hi arduinians!

I'm usig a SMARTGPU2 as storage device attached to ARDUINO UNO. But there is a big problem with the file pointer when data are stored (stored on micro SD) I programmed an inner loop (just a timer) that goes in to the storage function every 15 seconds, over and over, but after the third access to this function the pointer gets an insane value (12352!!) and the SD gets about 70 MB of unsensed data.

This is the function I've used:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

/**** function that reports errors and loops forever ******/

void die(FILERESULT response){

if(response!=F_OK){

lcd.string(100, (MAX_Y_LANDSCAPE+1)-50, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,"Error...",0);

while(1); } }

/************************ Save data *********************/ void SaveData(void) {

FILERESULT res; //this variable that will store all SMARTGPU2 commands responses

char message[11]="JAJAJAJAJA"; //data to store

unsigned int writtenBytes=0;

char Spointer[4];

//Other variables used on this function are globally declared

/************ find the file and try to open it ************************/

res=lcd.SDFopenDir("Datos");

res=lcd.SDFopenFile("Data00.txt", WRITEONLY, WORKSPACE0); //Try to open a file Data00.txt"

if(res!=F_OK){ //If the file doesn't Open is because it doesn't exist

res=lcd.SDFnewFile("Data00.txt"); //Creates the file

die(res); //If any error loop forever

res=lcd.SDFopenFile("Data00.txt", WRITEONLY, WORKSPACE0); //Try to open again die(res); //If any error loop forever }

/****** now let`s write data into the memory **************/

pointer+=sizeof(message); //move pointer forward

sprintf (Spointer, "%04i", pointer);

lcd.drawRectangle(95,(MAX_Y_LANDSCAPE+1)-52, 150, (MAX_Y_LANDSCAPE+1)-37,BLUE,FILL);

lcd.string(100, (MAX_Y_LANDSCAPE+1)-50, MAX_X_LANDSCAPE,MAX_Y_LANDSCAPE,Spointer,0);

// just prints on SMARTGPU2 the new pointer position

res=lcd.SDFsetFilePointer(pointer, WORKSPACE0); // sets a new position pointer on the file

delay(2);

die(res);

res=lcd.SDFwriteFile(message, sizeof(message), &writtenBytes, WORKSPACE0);

die(res);

lcd.SDFcloseFile(WORKSPACE0); //Close the file --------------------

lcd.SDFopenDir(".."); //return one level up

// repeat over and over every 15 seconds } ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ At the begining of programmig Ive used the function lcd.SDFgetFilePointer to get the initial pointer position, but after some experiments it seems that it always read position at the begining of file each time you open a file. - it does not make sense! but I got this results. So I tried just to increment the pointer value in a number of "messages" bytes.

The expected behavior is a repeated message JAJAJAJAJA in the SD every 15 seconds, but a got this:

JAJAJAJAJA AJAJAJAJA AJAJAJAJA 4127.529.329.40.030.030.06127.5127.529.329.40.050.0 dzbvsfb

¥I…èVŠù K¼eu ejah~"¯ÆƱ jaz"UÇ:}ï=ƒó6rï¿'PØAvêOŽòH‡ê?sÝ5cÒ

K½?­ '“~ ~ ^ X v(®-^ß2oé=lë,RÓ 6±...... and so on upto 70Mbytes!!

Does any one faced this problem and found a solution?

I would appreciate any help.

Regards.