LCD5110 and SD: fails to save on file

Hi there,

After a long search on this forund and in other sitesin internet, i was not able to figure out how to solve the issue.

I have an arduino nano (3.0) together with an nokia 5110 LCD and and microSD holder. I use the Adafruit PCD8544 and GFX libraries to control the LCD, and the SD library of the Arduino IDE. From the hardware point of view, they do not share any pin. Meanwhile SD use the hardware SPI pins (SS on pin 10), the LCD uses the software SPI pin (3 to 7 digital pins)…

I have both LCD and SD card connected and they works independenty if i upload an example of each library, however, in my sketch LCD works perfect, and the SD card begins, and creates a file of it does not exist in the Sd card, BUT it does not save data into that file…

I tried many things following old forum topics such as to begin the SD after and before the LCD, to modify the SD library to reduce the SD spi speed to a quarter,… but nothings results on saving the data into the file.

I think it is not an issue related to hardware, since the fileis already writed in the SD card, but later it is not oppened to be writted…

I attach my present code. It could be something disorganized, but i am stil working on it…
In line 100 i begin the card and chekt it.
in line 107 check if the datafile exist, and if not i create it (it works)
in line 116 i create a heather into the file (this does not work)
Latter in the code a savedata() function (line 348) is called in different sites (they neither work).

Any idea of how to solve this? What am i doing wrong?
Thanks!

SPPS_Control_01.ino (10.2 KB)