Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

Atmega8 i eksterni eeprom 24c08

[es] :: Elektronika :: Mikrokontroleri :: Atmega8 i eksterni eeprom 24c08

[ Pregleda: 1986 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

d_a_l_3

Član broj: 79516
Poruke: 51
193.198.72.*



Profil

icon Atmega8 i eksterni eeprom 24c0802.11.2011. u 14:27 - pre 151 meseci
Vozra ljudi

Ima li netko slučajno gotov kod ali mora biti WinAVR GCC treba mi samo read i write, našao sam na netu kojekakve biblioteke ali ne rade :(
Za sada samo jedna radi i to Write, a s read ne mogu nikako da pročitam što sam zapisao

Ako netko ima neka posta ako ne, onda postam večeras kod pa pokušamo zajedno osposobiti da radi

Fala
 
Odgovor na temu

milanmeh
Novi Sad

Član broj: 206027
Poruke: 213
*.dynamic.sbb.rs.



+7 Profil

icon Re: Atmega8 i eksterni eeprom 24c0802.11.2011. u 21:08 - pre 151 meseci
I ja trenutno preturam net trazeci dobar soft i2c tutorial.

Da li si probao ovde?

LINK

Na sajtu ima biblioteka za TWI (HW i2c) i soft i2c sa primerom za 24c02.

A i naleteo sam na ovaj sajt sa soft i2c: LINK

Probaj mozda radi.
 
Odgovor na temu

d_a_l_3

Član broj: 79516
Poruke: 51
193.198.72.*



Profil

icon Re: Atmega8 i eksterni eeprom 24c0803.11.2011. u 08:08 - pre 151 meseci
Ma jesam gledao sam sve, I2C je ok i radi mi (imam DS1307) i s njim sve 5, ali me zeza samo taj EEPROM, interni EEPROM čitam i pišem bez problema, ali ga je malo, samo 512byte-a zato mi i treba vanjski

Nema druge morat ću izgleda pisati svoje funkcije....ako rješim problem stavim kod ovdje :)
 
Odgovor na temu

milanmeh
Novi Sad

Član broj: 206027
Poruke: 213
*.dynamic.sbb.rs.



+7 Profil

icon Re: Atmega8 i eksterni eeprom 24c0803.11.2011. u 08:45 - pre 151 meseci
Da li si probao da poredis tu biblioteku za 24c08 sa datasheetom proizvodjaca? Mozda se rutine razlikuju malo za taj eeprom.
 
Odgovor na temu

d_a_l_3

Član broj: 79516
Poruke: 51
193.198.72.*



Profil

icon Re: Atmega8 i eksterni eeprom 24c0803.11.2011. u 14:31 - pre 151 meseci
Nikad nisam volio glupe datasheetove a ovo je jedna od takvih

http://www.datasheetcatalog.org/datasheets/134/80474_DS.pdf

Ne mogu se snaći tu i jako malo ima o tome kako pročitati nešto iz eeproma...trenutno nisam kući ali probam nešto navečer...
 
Odgovor na temu

d_a_l_3

Član broj: 79516
Poruke: 51
*.adsl.net.t-com.hr.



Profil

icon Re: Atmega8 i eksterni eeprom 24c0803.11.2011. u 19:19 - pre 151 meseci
Uspio sam napokon :) malo truda i trazenja

nasao u libc manualu oko 100stranice, bas za eeprome 24cxx

Evo funkcija za citanje i fala milanmeh :)

ee24xx_read_bytes(uint16_t eeaddr, int len, uint8_t *buf)
{
uint8_t sla, twcr, n = 0;
int rv = 0;

#ifndef WORD_ADDRESS_16BIT
/* patch high bits of EEPROM address into SLA */
sla = TWI_SLA_24CXX | (((eeaddr >> 8) & 0x07) << 1);
#else
/* 16-bit address devices need only TWI Device Address */
sla = TWI_SLA_24CXX;
#endif

/*
* Note [8]
* First cycle: master transmitter mode
*/
restart:
if (n++ >= MAX_ITER)
return -1;
begin:

TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); /* send start condition */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_REP_START: /* OK, but should not happen */
case TW_START:
break;

case TW_MT_ARB_LOST: /* Note [9] */
goto begin;

default:
return -1; /* error: not in start condition */
/* NB: do /not/ send stop condition */
}

/* Note [10] */
/* send SLA+W */
TWDR = sla | TW_WRITE;
TWCR = _BV(TWINT) | _BV(TWEN); /* clear interrupt to start transmission */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_MT_SLA_ACK:
break;

case TW_MT_SLA_NACK: /* nack during select: device busy writing */
/* Note [11] */
goto restart;

case TW_MT_ARB_LOST: /* re-arbitrate */
goto begin;

default:
goto error; /* must send stop condition */
}

#ifdef WORD_ADDRESS_16BIT
TWDR = (eeaddr >> 8); /* 16-bit word address device, send high 8 bits of addr */
TWCR = _BV(TWINT) | _BV(TWEN); /* clear interrupt to start transmission */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_MT_DATA_ACK:
break;

case TW_MT_DATA_NACK:
goto quit;

case TW_MT_ARB_LOST:
goto begin;

default:
goto error; /* must send stop condition */
}
#endif

TWDR = eeaddr; /* low 8 bits of addr */
TWCR = _BV(TWINT) | _BV(TWEN); /* clear interrupt to start transmission */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_MT_DATA_ACK:
break;

case TW_MT_DATA_NACK:
goto quit;

case TW_MT_ARB_LOST:
goto begin;

default:
goto error; /* must send stop condition */
}

/*
* Note [12]
* Next cycle(s): master receiver mode
*/
TWCR = _BV(TWINT) | _BV(TWSTA) | _BV(TWEN); /* send (rep.) start condition */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_START: /* OK, but should not happen */
case TW_REP_START:
break;

case TW_MT_ARB_LOST:
goto begin;

default:
goto error;
}

/* send SLA+R */
TWDR = sla | TW_READ;
TWCR = _BV(TWINT) | _BV(TWEN); /* clear interrupt to start transmission */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_MR_SLA_ACK:
break;

case TW_MR_SLA_NACK:
goto quit;

case TW_MR_ARB_LOST:
goto begin;

default:
goto error;
}

for (twcr = _BV(TWINT) | _BV(TWEN) | _BV(TWEA) /* Note [13] */;
len > 0;
len--)
{
if (len == 1)
twcr = _BV(TWINT) | _BV(TWEN); /* send NAK this time */
TWCR = twcr; /* clear int to start transmission */
while ((TWCR & _BV(TWINT)) == 0) ; /* wait for transmission */
switch ((twst = TW_STATUS))
{
case TW_MR_DATA_NACK:
len = 0; /* force end of loop */
/* FALLTHROUGH */
case TW_MR_DATA_ACK:
*buf++ = TWDR;
rv++;
break;

default:
goto error;
}
}
quit:
/* Note [14] */
TWCR = _BV(TWINT) | _BV(TWSTO) | _BV(TWEN); /* send stop condition */

return rv;

error:
rv = -1;
goto quit;
}
 
Odgovor na temu

[es] :: Elektronika :: Mikrokontroleri :: Atmega8 i eksterni eeprom 24c08

[ Pregleda: 1986 | Odgovora: 5 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.