RE: [bascom] Q to Mark...Read/Write 24C16/32/64 EEprom


From "Mark Alberts" <mark@mcselec.com>
Date Thu, 22 Feb 2001 01:08:03 +0100

Hi,

Thanks for the usefull addition on this topic! I will add it to the faq too.

Best regards,
Mark Alberts

> -----Original Message-----
> From: owner-bascom@grote.net [mailto:owner-bascom@grote.net]On Behalf Of
> Koen Starre
> Sent: woensdag 21 februari 2001 23:51
> To: bascom@grote.net
> Cc: bascom@grote.net
> Subject: Re: [bascom] Q to Mark...Read/Write 24C16/32/64 EEprom
>
>
> When using AT24C16 (or similair) its crucial to understand that bytes are
> accessed in pages of 16 bytes. After addressing a page the internel
> bytecounter (of EEPROM) is autoincremented by 1 and rolls-over after 16
> bytes. There is no direct way of addressing a random byte! This is crucial
> to understand. Otherwhise you only access only one byte of each page!
> Futhermore take notice of the WP-pin which can protect the upper
> half of the
> memory if set high.
> If you set WP-pin high and only acces 1 byte per page (thus ignoring page
> adressing) their are only 256 bytes left to write, which seems to be your
> problem.
> Read the damn datasheet over and over, and put it under your pillow while
> you are asleep!
>
> N.B.: AT24C16 and 24C65 and their software (addressing) are NOT
> compatible!
>          Also keep capasitive load to I2C-bus low (no long cables).
>
> ----- Original Message -----
> From: "Javier Casillas" <fjcasillas@retemail.es>
> To: <bascom@grote.net>
> Sent: Wednesday, February 21, 2001 5:26 PM
> Subject: Re: [bascom] Q to Mark...Read/Write 24C16/32/64 EEprom
>
>
> > Thanks Eric:
> > With the example that I send you, it works fine until &HFF
> > connected at a 89C52 in P0.0 and P0.1
> > with BASCOM-8051 2.0.7.0
> >
> > Thank you
> > Javier Casillas
> >
> > Eric Le Baron wrote:
> >
> > > I tried a program that reads/writes a 24C65.
> > > It used to work before with an earlier version but with 2.0.6.0 it
> doesn't.
> > > To test it I used the program to fill the 24C65 and I read it with a
> > > programmer.
> > > All addresses remained FF.
> > > Then I manually filled the first addresses with the (Galep)
> programmer.
> > > The program read these locations and displayed the contents, only
> FF's...
> > >
> > > $regfile = "89s8252.dat"
> > > Waitms 255
> > > Dim Address As byte , Value As Byte
> > > Dim Test As Byte
> > > Const Addressr = &B1010_0001
> > > Declare Sub Read_eeprom(address As Byte , Value As Byte)
> > > Cls
> > > '
> > > Address = 0
> > > For Test = 1 To 255
> > >   Call Read_eeprom(address , value)
> > >   Waitms 10
> > >   Incr Address
> > >   Lcd Chr(value);
> > > Next
> > > '
> > > End
> > >
> > > Sub Read_eeprom(address As Byte , Value As Byte)
> > >    I2cstart                             'generate start
> > >    I2cwbyte Addressw                    'slave adsress
> > >    I2cwbyte Address                     'address of EEPROM
> > >    I2cstart                             'repeated start
> > >    I2cwbyte Addressr                    'slave address (read)
> > >    I2crbyte Value , 9                   'read byte
> > >    I2cstop                              'generate stop
> > > End Sub
> > >
> > > Eric Le Baron
> > > Wageningen
> > > The Netherlands
> >
>
>
> ------------------------------------------------------------------
> ----------
> ----
>
>
> >
> > BASCOM-8051 Version 2.0.7.0
> >
> > $regfile = "89C51.DAT"
> > $ramstart = 0                                       'Inicio de la XRAM
> > $ramsize = 256                                      'Tamaño de la XRAM
> >
> > $crystal = 12000000
> > Dim Direccion As Byte
> > Dim Valor As Byte
> > dim Byte_W As Const 160                            'Byte para
> escribir en
> la eeprom 000
> > dim Byte_R As Const 161                            'Byte para leer en la
> eeprom     000
> >
> >
> >
> > call Read_eeprom(&FA,Valor)
> >
> >
> > '*************************************************************
> > '************* Rutina de lectura en EEPROM *******************
> > Sub Read_eeprom(Direccion As Byte , Valor As Byte)
> >    I2cstart                                         'Condicion
> de arranque
> >    I2cwbyte Byte_w                                 'Codigo de escritura
> >    I2cwbyte Direccion                               'Direccion de
> escritura MSB
> >    I2cstart                                         'Condicion
> de arranque
> >    I2cwbyte Byte_r                                 'Codigo de lectura
> >    I2crbyte Valor , 9                               'Carga el dato en
> valor
> >    I2cstop                                          '
> > End Sub
> > '*************************************************************
> > '*************************************************************
>
>