Forum: Mikrocontroller und Digitale Elektronik EEPROM ansprechen AT89C61CC03


von yasinho (Gast)


Lesenswert?

Guten Tag,
Ich habe eine Uhr mit einem Alarm programmiert und mein Problem ist, 
dass den Alarm mit EEPROM abspeichern muss, was ich auch versucht habe. 
Das ging leider nicht. Ich benutze uVision und den IC AT89C51CC03. Ich 
wäre froh, wenn ich von Ihnen ein Paar Tipps erhalten würde.

LG yasinho

von Peter D. (peda)


Lesenswert?

1
// Read one Byte from the EEPROM. Can Interrupt must be disabled, because
2
// XDATA Acess is directed to the EEPROM.
3
uchar eeReadByte (uint off)
4
{
5
   register uchar ret;
6
7
   EA = 0;                      // No Interrupts
8
   AUXR |= 0x20;                // Stretch Memory Cycle
9
   EECON = 0x02;                // Enable EEPROM Access
10
   ret = *((uchar xdata *)(off));
11
   EECON = 0x00;                // Disable EEPROM Access
12
   AUXR &= ~0x20;               // UnStretch Memory Cycle
13
   EA = 1;                      // Interrupts On
14
   return (ret);
15
}
16
17
// Write one Byte to the EEPROM. Can Interrupt must be disabled, because
18
// XDATA Acess is directed to the EEPROM.
19
fbit eeWriteByte (uint off, uchar val)
20
{
21
   EA = 0;                      // No Interrupts
22
   AUXR |= 0x20;                // Stretch Memory Cycle
23
   EECON = 0x02;                // Enable EEPROM Access
24
   *((uchar xdata *)(off)) = val;
25
   EECON = 0x00;                // Disable EEPROM Access
26
   EECON = 0x50;                // Start EEPROM Programming
27
   EECON = 0xa0;                //            "
28
   AUXR &= ~0x20;               // UnStretch Memory Cycle
29
   EA = 1;                      // Interrupts On
30
   while (EECON & 0x01) ;       // Wait for Programming Ready
31
   return (1);
32
}

von yasinho (Gast)


Lesenswert?

Vielen Dank.

LG yasinho

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.