So.

Mein LCD gibt jetzt endlich eine brauchbare Zeit aus. Allerdings hatte ich wieder Probleme mit der i2c_start_wait();-Funktion. Das hat sich aber wie von allein auf einmal gegeben. Keine Ahnung woran das lag muss aber beobachtet werden.


Hier erstmal der Code der jetzt läuft:
Code:
#include <avr/io.h> 
#include <stdio.h>
#include <util/delay.h> 
#include "i2cmaster/i2cmaster.h" 
#include "lcdlibrary/lcd.h"

#define DS1307		0xD0

unsigned char time_s;         // Sekundenvariable
unsigned char time_m;         // Sekundenvariable
unsigned char time_h;         // Sekundenvariable

unsigned char buffer[10];

unsigned char set_clock(unsigned char reg, unsigned char val) 
{ 
	if (i2c_start(DS1307+I2C_WRITE) != 0) return 1; 
	i2c_write(reg); 
	i2c_write(val); 
	i2c_stop(); 
	return 0; 
}

unsigned char get_time_s() 
{ 
	i2c_start_wait(DS1307+I2C_WRITE); 
	i2c_write(0x00); 
	i2c_stop(); 
	i2c_start(DS1307+I2C_READ); 
	time_s = i2c_readNak(); 
	i2c_stop();  
	return time_s;
}

unsigned char get_time_m() 
{ 
	i2c_start_wait(DS1307+I2C_WRITE); 
	i2c_write(0x01); 
	i2c_stop(); 
	i2c_start(DS1307+I2C_READ); 
	time_m = i2c_readNak(); 
	i2c_stop();  
	return time_m;
}


unsigned char get_time_h() 
{ 
	i2c_start_wait(DS1307+I2C_WRITE); 
	i2c_write(0x02); 
	i2c_stop(); 
	i2c_start(DS1307+I2C_READ); 
	time_h = i2c_readNak(); 
	i2c_stop();  
	return time_h;
}


int main (void) 
{
	DDRB = (1<<PB0);					//   PB0 als Ausgang 
	DDRC = ~(1<<PC3);					//   PC3 als Eingang 

	lcd_init(LCD_DISP_ON);
	lcd_clrscr();

	i2c_init();

	lcd_puts("Bereit");
	_delay_ms(1000);
	lcd_clrscr();

//	set_clock(0x02, 0x09); 
//	set_clock(0x01, 0x12);
//	set_clock(0x00, 0x58);

	while (1) 
	{ 
		get_time_s();
		get_time_m();
		get_time_h();

		sprintf(buffer, "Zeit: %02x:%02x:%02x", time_h, time_m, time_s); 
		lcd_puts(buffer);   
		lcd_gotoxy(0,0);
		_delay_ms(100);   
	} 
	return 0; 
}
Einzig die Spalte
Code:
sprintf(buffer, "Zeit: %02x:%02x:%02x", time_h, time_m, time_s);
habe ich mir aus dem Netz geklaut und noch nicht verstanden. Zusammen mit dieser zeile treten beim kompilieren auch zwei Warnungen auf:
Code:
../exp_RTC.c: In function 'main':
../exp_RTC.c:86: warning: pointer targets in passing argument 1 of 'sprintf' differ in signedness
../exp_RTC.c:87: warning: pointer targets in passing argument 1 of 'lcd_puts' differ in signedness
Kann mir bei diesen beiden Punkten grad mal jemand vom Schlauch helfen?