Solved:
Found a bug in SD_Write_Bloc (SD.C)
This software implements a software timer - wich is against Flexis recommendations - after sending the block to be written. It tipically worked on 9S08JM60 but crashed in MCF51.
The changes were from:
=============================================
for(u16Counter=0;u16Counter<BLOCK_SIZE;u16Counter++);
if((ReadSPIByte() & 0x0F) != 0x05)
=============================================
To:
=======================================================================
SD_response=0xFF; // #001 created this variable
while (SD_response==0xFF) SD_response=ReadSPIByte(); // #001 wait for SD response <> 0xFF
if((SD_response & 0x0F) != 0x05) // #001 checks if response = 0101 = data accepted
{
SPI_SS=DISABLE;
return(WRITE_DATA_FAILS);
}
========================================================================
Preliminary test appears to be working.
And I look like a lunatic, talking to myself.
At least maybe it helps someone.
Celso