Forum: Mikrocontroller und Digitale Elektronik PIC 18F4550 und DS1307 RTC


von Andy L. (nemai)


Lesenswert?

Hi,

irgendwie bringe ich die beiden nicht so recht dazu, sich zu verstehen 
(oder ich missverstehe die RTC).
Zum Schaltplan mache ich mal keine größeren Angaben, der sollte korrekt 
sein. I²C Schnittstellen verbunden, am SQW Ausgang des DS1307 hängt eine 
LED. Die SDA/SCL sind mit 1,2K gegen +5V gelegt.

Die Adresse des DS1307 ist 0x68.
Das Datenblatt des DS1307 sagt mir:

The DS1307 control register is used to control the operation of the 
SQW/OUT pin.
Bit 7: Output Control (OUT). This bit controls the output level of the 
SQW/OUT pin when the squarewave output is disabled. If SQWE = 0, the 
logic level on the SQW/OUT pin is 1 if OUT = 1 and is 0 if OUT = 0.

Mein Sourcecode in C sieht so aus:


  //Fcy = 4Mhz

  TRISBbits.TRISB0 = 1;  //SDA
  TRISBbits.TRISB1 = 1;  //SCL

  SSPSTAT = 0x80;
  SSPADD = 0x28;
  SSPCON1 = 0x28;

  SSPCON2bits.SEN = 1;
  Delay100TCYx(10);
  SSPBUF = 0xD0;  //0x68 + R/W(0)
  Delay100TCYx(10);
  SSPBUF = 0x07;  //Adresse des Kontrollregisters
  Delay100TCYx(10);
  SSPBUF = 0x80;  //hier müsste die LED doch leuchten ..tut sie nicht.
  Delay100TCYx(10);
  SSPCON2bits.PEN = 1;

  while(1);

Da die LED nicht an geht, schließe ich, dass meine ganze Kommunikation 
scheitert. Hat jemand einen Tipp was falsch ist, oder ist das komplett 
Müll?

Mfg.

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.