EEPROM ansprechen AT89C61CC03

Gast #6851300
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
#6851335
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
}

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren