char sdWriteBlock (const unsigned long address)
{
  unsigned long i = 0;
  char rvalue;
  char answerto;

  // Blocklänge setzen
  if (sdSetBlockLength (512) == MMC_SUCCESS)	
    {
      // CS auf LOW setzen
	  CS_LOW();
      //CMD24 zum schreiben eines Blocks(512 Bytes) auf die SD-Karte senden
      sdSendCmd (0x58, address, 0xFF);
      //answerto = sdGetResponse();
      	answerto = sdGetXXResponse(MMC_R1_RESPONSE);

      // check, ob CMD24 bestätigt wurde
      if (answerto == MMC_R1_RESPONSE)
      {
    	  spiSendByte(0xff);

    	  // Datatoken senden
    	  spiSendByte(0xfe);

    	  do
    	  {
    		  gps_buffer[i] = read_char_USART0_nonstop();
    		  if (gps_buffer[i] != '\0')
    		  {
    			  spiSendByte(gps_buffer[i]);	//sende die NMEA-Daten zur Karte
    		  }
    		  i++; 
    	  }while(i<512);	

    	  spiSendByte(0xff);
    	  spiSendByte(0xff);

    	  /* check das "Data Response"-Byte xxx0<status>1:
    	   * status 010: Data angenommen
    	   * status 101: Data abgelehnt wegen CRC-Fehlers
    	   * status 110: Data abgelehnt wegen Schreibfehlers
    	   */
    	  //
         rvalue = sdCheckBusy();
      }
      else
      {
    	  // the MMC never acknowledge the write command
    	  rvalue = MMC_RESPONSE_ERROR;	// 2
      }
    }
  else
    {
      rvalue = MMC_BLOCK_SET_ERROR;	// 1
    }
  CS_HIGH();
  spiSendByte(0xff);
  return rvalue;
  //return answerto;
}
