|
|
Elektronika.lt portalo forumas
Jūs esate neprisijungęs lankytojas. Norint dalyvauti diskusijose, būtina užsiregistruoti ir prisijungti prie forumo.
Prisijungę galėsite kurti naujas temas, atsakyti į kitų užduotus klausimus, balsuoti forumo apklausose.
Administracija pasilieka teisę pašalinti pasisakymus bei dalyvius,
kurie nesilaiko forumo taisyklių.
Pastebėjus nusižengimus, prašome pranešti.
Dabar yra 2024 12 27, 01:51. Visos datos yra GMT + 2 valandos.
|
|
|
|
Forumas » Mikrovaldikliai » eeprom 24c32
|
Jūs negalite rašyti naujų pranešimų į šį forumą Jūs negalite atsakinėti į pranešimus šiame forume Jūs negalite redaguoti savo pranešimų šiame forume Jūs negalite ištrinti savo pranešimų šiame forume Jūs negalite dalyvauti apklausose šiame forume
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 06, 22:46 |
|
|
|
AlgisL rašo: |
LCD valyti nebutina, tik tada tenka paaukoti RAM video bufferiui, o sinchronizuoti galima kai per paskutines kazkiek ms buvo pastebimu pakeitimu (dar galima organizuoti pakeistu plotu sarasus). |
gal gali placiau, kaip tai igyvendinti? arba bent nuorodas kur butu pasiskaityti su pavyzdziais. |
|
_________________ Skype: dmb-220 |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 06, 23:32 |
|
|
|
Atsirieki tiek RAM, kiek reikia video buferiui (reikia zinoti LCD valdiklio vidines atminties struktura).
Tada pasidarai visus reikalingus primityvus piesimui (ir pakitimu sarasui).
kas kazkiek ms pasitikrini ar buvo pakitimu ir juos atnaujini LCD atmintyje ir RAM, bei isvalai pakitimu sarasa, bet cia gali prireikti dvigubos buferizacijos.
Gali ir pastoviai siusti video buferio turini i LCD per DMA, tada uztenka vieno video buferio, bet DMA irgi gali konkuruoti laiko resursais su uCU.
Netycia ant akiu papuole tavo tema pvz:
Kodas: |
/*******************************************************************************
* Function: I2C_Read_Reg
* Author: Matt Mielke
* Desctription: This function will read the contents of the slave's memory
* starting at the specified address. The user must specify which
* I2C peripheral to use, the slave address, the address of the
* register to start from, and the number of bytes to be read.
* Also, a buffer for the data to be stored in must be provided.
* Date: 09-13-16
*******************************************************************************/
void I2C_Read_Reg( I2C_TypeDef* pI2C, uint16_t dev_addr, uint8_t reg, uint8_t* data, uint8_t count )
{
uint32_t temp_CR2;
// begin transaction by sending the register address
temp_CR2 = pI2C->CR2;
temp_CR2 &= ~( I2C_CR2_RELOAD | I2C_CR2_NBYTES | I2C_CR2_RD_WRN | I2C_CR2_SADD | I2C_CR2_AUTOEND );
temp_CR2 |= ( dev_addr & I2C_CR2_SADD ) | ( ( 1 << 16 ) & I2C_CR2_NBYTES )
| I2C_CR2_START;
pI2C->CR2 = temp_CR2;
while ( !( pI2C->ISR & I2C_ISR_TXIS ) ); // wait for TXDR to be empty
pI2C->TXDR = reg; // send register address
while ( !( pI2C->ISR & I2C_ISR_TC ) ); // wait for transfer to complete
// continue transaction by reading from slave
temp_CR2 = pI2C->CR2;
temp_CR2 &= ~( I2C_CR2_RELOAD | I2C_CR2_NBYTES | I2C_CR2_SADD );
temp_CR2 |= ( dev_addr & I2C_CR2_SADD ) | ( ( count << 16 ) & I2C_CR2_NBYTES )
| I2C_CR2_RD_WRN | I2C_CR2_AUTOEND | I2C_CR2_START;
pI2C->CR2 = temp_CR2;
do
{
while ( !( pI2C->ISR & I2C_ISR_RXNE ) ); // wait for data to be received
*data = pI2C->RXDR;
data++;
count--;
} while ( count > 0 );
while ( !( pI2C->ISR & I2C_ISR_STOPF ) ); // wait for stop to be detected
pI2C->ICR |= I2C_ICR_STOPCF; // clear the stop detection flag
}
/*******************************************************************************
* Function: I2C_Write_Reg
* Author: Matt Mielke
* Desctription: This function will write to the slave's memory starting at the
* provided starting address. Besides this, the I2C peripheral to
* be used, the slave address, the number of bytes to write,
* and a buffer containing the data to be written must be provided.
* Date: 09-13-16
*******************************************************************************/
void I2C_Write_Reg( I2C_TypeDef* pI2C, uint16_t dev_addr, uint8_t reg, uint8_t* data, uint8_t count )
{
uint32_t temp_CR2;
// begin transaction
temp_CR2 = pI2C->CR2;
temp_CR2 &= ~( I2C_CR2_RELOAD | I2C_CR2_NBYTES | I2C_CR2_RD_WRN | I2C_CR2_SADD );
temp_CR2 |= ( dev_addr & I2C_CR2_SADD ) | ( ( ( count + 1 ) << 16 ) & I2C_CR2_NBYTES )
| I2C_CR2_AUTOEND | I2C_CR2_START;
pI2C->CR2 = temp_CR2;
while ( !( pI2C->ISR & I2C_ISR_TXIS ) ); // wait for TXDR to be empty
pI2C->TXDR = reg; // send register address
// send data
do
{
while ( !( pI2C->ISR & I2C_ISR_TXIS ) ); // wait for TXDR to be empty
pI2C->TXDR = *data;
data++;
count--;
} while ( count > 0 );
while ( !( pI2C->ISR & I2C_ISR_TXE) ); // TXDR is empty and all data has been sent
while ( !( pI2C->ISR & I2C_ISR_STOPF ) ); // wait for stop to be detected
pI2C->ICR |= I2C_ICR_STOPCF; // clear the stop detection flag
}
|
|
|
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 20:33 |
|
|
|
ACIU uz kodo pvz.
su HAL man netiko nes LCD per letai veikia, gryzau prie senojo kodo, ir vis kovoju su EEPROM. man jis kaip uzburtas ratas, negaliu toliau kodo rasyti.
CHAR duomenis nuo 1 iki 255 iraso kuo puikiausiai.
bandant yrasyti INT ar FLOAT. nuskaites gaunu skaiciu kratini, arba 0.0 arba -0.0. jei bandant irasyt float 0.0 visada nuskaicius 0 ir buna cia atsitiktinumas ar ne, nezinau. gal 0 ir isiraso.
Kodas: |
void eeprom_write( uint8_t address, uint16_t reg, uint8_t *data, size_t length ) {
i2c_start();
i2c_address_direction( address << 1, I2C_Direction_Transmitter );
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
while(length--) {
i2c_transmit( *data);
data++;
if ( !((++reg) & 31 ) ) // perkopei 32 bytes puslapi
delay(20); // milliseconds
}
i2c_stop();
}
char tu = 18;
float t2 = 36.85;
eeprom_write(0x56, 0, (uint8_t*)&t2, sizeof(t2));
eeprom_write(0x56, 47, (uint8_t*)&tu, sizeof(tu));
|
cia mano transmit funkcija, buvai rases kad ten reik ziuret kazkokie "navarotai". bet cia nieko ypatingo ir keisti nera.
Kodas: |
void i2c_transmit(uint8_t byte)
{
// Send data byte
I2C_SendData(I2Cx, byte);
// Wait for I2C EV8_2.
// It means that the data has been physically shifted out and
// output on the bus)
while (!I2C_CheckEvent(I2Cx, I2C_EVENT_MASTER_BYTE_TRANSMITTED));
} |
I2C_SendData(I2Cx, byte); sita jau oficiali library funkcija |
|
_________________ Skype: dmb-220 |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 21:04 |
|
|
|
dmb-220 rašo: |
su HAL man netiko nes LCD per letai veikia, |
Na tai kažkur kitur "pribūrei". Specialiai lyginau tą patį grafikos testą, paleistą ant STM32F407 ir Arduino UNO. Su STM32 greitis beveik keturis kartus didesnis. Bet draiveris senokai rašytas, tada GPIO valdymui dar nenaudojau LL bibliotekos. HAL pakeitus LL, greitis būtų dar didesnis.
Atsiųsk AŽ savo el. pašto adresą, pasidalinsiu ST7735 draiveriais ir tuo testu. Tik reikės šiek tiek modifikuoti CubeMX nustatymus, jei naudosi kitos šeimos mikrovaldiklį. |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 21:05 |
|
|
|
Ok, primink ta savo tikrai veikianti koda, kuris VISDA TEISNGAI iraso ir perskaito viena baita, ir as tau padesiu privesti ji iki norimo duomenu tipo. |
|
|
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 21:39 |
|
|
|
AlgisL rašo: |
Ok, primink ta savo tikrai veikianti koda, kuris VISDA TEISNGAI iraso ir perskaito viena baita, ir as tau padesiu privesti ji iki norimo duomenu tipo. |
nuskaito teisiangai char tipa, baita
Kodas: |
void eeprom_read_char(uint8_t address, uint16_t reg){
//writeCommand(address, reg);
i2c_start();
i2c_address_direction(address << 1, I2C_Direction_Transmitter);
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
//jei stop, start uzkomentuoju, nebenuskaito
i2c_stop();
i2c_start();
i2c_address_direction(address << 1, I2C_Direction_Receiver);
read_char = i2c_receive_nack();
i2c_stop();
} |
cia iraso baita, CHAR, tavo duotas kodas
Kodas: |
void eeprom_write( uint8_t address, uint16_t reg, uint8_t *data, size_t length ) {
i2c_start();
i2c_address_direction( address << 1, I2C_Direction_Transmitter );
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
while(length--) {
i2c_transmit( *data);
data++;
if ( !((++reg) & 31 ) ) // perkopei 32 bytes puslapi
delay(20); // milliseconds
}
i2c_stop();
} |
i sita fukcija kreipiuosi
Kodas: |
char tu = 18;
eeprom_write(0x56, 47, (uint8_t*)&tu, sizeof(tu)); |
reiksme nuskaitau, kintamasis read_char aprasytas i kuri reiksme atsiduria
Kodas: |
eeprom_read_char(0x56, 47); |
|
|
_________________ Skype: dmb-220 |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 22:10 |
|
|
|
nepatinka man tokie bajeriai, tad kai pribres reikalas isbandyti (o jis jau beldziasi pro duris), tai pranesiu.
o dabar galima bandyti bukai bukai:
Kodas: |
void eeprom_write( uint8_t address, uint16_t reg, uint8_t *data, size_t length ) {
while(length--) {
i2c_start();
i2c_address_direction( address << 1, I2C_Direction_Transmitter );
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
i2c_transmit( *data++);
i2c_stop();
++reg;
// if ( !((reg) & 31 ) ) // perkopei 32 bytes puslapi
delay(20); // milliseconds
}
}
|
man cia ack/nack problema labiau svieciasi. |
|
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 08, 23:12 |
|
|
|
AlgisL rašo: |
nepatinka man tokie bajeriai, tad kai pribres reikalas isbandyti (o jis jau beldziasi pro duris), tai pranesiu.
o dabar galima bandyti bukai bukai:
Kodas: |
void eeprom_write( uint8_t address, uint16_t reg, uint8_t *data, size_t length ) {
while(length--) {
i2c_start();
i2c_address_direction( address << 1, I2C_Direction_Transmitter );
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
i2c_transmit( *data++);
i2c_stop();
++reg;
// if ( !((reg) & 31 ) ) // perkopei 32 bytes puslapi
delay(20); // milliseconds
}
}
|
man cia ack/nack problema labiau svieciasi. |
neiraso vistiek. |
|
_________________ Skype: dmb-220 |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 09, 09:51 |
|
|
|
Tada kaip pas tave iraso TEISINGAI baita, jei neiraso vistiek keliu baitu is eiles po baita?
Lauk tada, pakol teks prisesti prie vieno ARM su isoriniu EEPROM, jei paciam nera fantazijos. (arba daryk per HAL)
Tikrink ir dar karta tikrink nustatymus, gal pas tave daugiau nei 100kHz i2c daznis, nors maitini nuo 3v3?
Kad veikia nuo Arduino tikiu, net ten default buna 100kHz, o ir maitini ten turbut 5V.
Citata: |
BYTE WRITE:A write operation requires two 8-bit data word addresses following the
device address word and acknowledgment. Upon receipt of this address, the EEPROM
will again respond with a zero and then clock in the first 8-bit data word. Following
receipt of the 8-bit data word, the EEPROM will output a zero and the addressing
device, such as a microcontroller, must terminate the write sequence with a stop condition. At this time the EEPROM enters an internally-timed write cycle, tWR, to the
nonvolatile memory. All inputs are disabledduring this write cycle and the EEPROM will
not respond until the write is complete (refer to Figure 2).
PAGE WRITE:The 32K/64K EEPROM is capable of 32-byte page writes.
A page write is initiated the same way as a byte write, but the microcontroller does not
send a stop condition after the first data word is clocked in. Instead, after the EEPROM
acknowledges receipt of the first data word, the microcontroller can transmit up to 31
more data words. The EEPROM will respond with a zero after each data word received.
The microcontroller must terminate the page write sequence with a stop condition (refer
to Figure 3).
The data word address lower 5 bits are internally incremented following the receipt of
each data word. The higher data word address bits are not incremented, retaining the
memory page row location. When the word address, internally generated, reaches the
page boundary, the following byte is placed at the beginning of the same page. If more
than 32 data words are transmitted to the EEPROM, the data word address will roll
over and previous data will be overwritten.
ACKNOWLEDGE POLLING:Once the internally-timed write cycle has started and the
EEPROM inputs are disabled, acknowledge polling can be initiated. This involves sending a start condition followed by the device address word. The read/write bit is
representative of the operation desired. Only if the internal write cycle has completed
will the EEPROM respond with a zero, allowing the read or write sequence to continue. |
zek 11..12 datasheeto lapus |
|
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 11, 23:33 |
|
|
|
Pagaliau veikia EEPROM nuskaitymas ir irasymas. Pasidalinsiu kodu
Kodas: |
uint8_t read_char;
uint16_t read_int;
uint32_t read_float;
void eeprom_read(uint8_t address, uint16_t reg, void *buf, size_t length){
unsigned char *p = (unsigned char *)buf;
writeCommand(address, reg);
i2c_start();
i2c_address_direction(address << 1, I2C_Direction_Receiver);
while(length--) {
if(length){
*p++ = i2c_receive_ack();
}else{
*p++ = i2c_receive_nack();
}
}
i2c_stop();
}
void eeprom_write( uint8_t address, uint16_t reg, void *data, size_t length ) {
unsigned char *p = (unsigned char *)data;
i2c_start();
i2c_address_direction( address << 1, I2C_Direction_Transmitter );
i2c_transmit(reg >> 8);
i2c_transmit(reg & 0xFF);
while(length--) {
i2c_transmit(*p++);
if ( !((++reg) & 31 ) ) // perkopei 32 bytes puslapi
delay(10); // milliseconds
}
i2c_stop();
//jei darai keleta irasymu, nespeja i2c sustoti, reik laiko pauzes
delay(20);
}
//nuskaitomas EEPROM, irasom i sizeof kokio ilgio duopmenis norim nuskaityti
eeprom_read(0x56, 47, &read_char, sizeof(char));
eeprom_read(0x56, 99, &read_int, sizeof(int));
eeprom_read(0x56, 0, &read_float, sizeof(float));
//EEPROM irasymas
char tu = 29;
int ta = 569;
float t2 = 37.75;
eeprom_write(0x56, 0, (uint8_t*)&t2, sizeof(t2));
eeprom_write(0x56, 99, (uint8_t*)&ta, sizeof(ta));
eeprom_write(0x56, 47, (uint8_t*)&tu, sizeof(tu));
|
Aciu visiems padejusiems. jei yra kokiu durnu klaidu, parasykite pasitaisysiu |
|
_________________ Skype: dmb-220 |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 11, 23:58 |
|
|
|
Skirtingiems eepromams prie skirtingu itampu skirtingos pauzes irasant / trinant |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 12, 10:38 |
|
|
|
AlgisL rašo: |
Skirtingiems eepromams prie skirtingu itampu skirtingos pauzes irasant / trinant |
man labiausiai pazdejo sita eilute. radau netycia interneto platybese, pasinaudojau ir suvceike. nors realiai tuos pointer (jei teisingai issireskiu) sunkiai ikertu,, kaip ir kada reik naudoti.
Kodas: |
unsigned char *p = (unsigned char *)data; |
tiek irasyme tiek nuskaityme.
o laiko pauze padaryti reikejo tik tam jei iseiles nori irasyt kelias skirtingas reiksmes I2C pakibdavo. |
|
_________________ Skype: dmb-220 |
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 12, 11:16 |
|
|
|
tau padejo nack/ack, o papildomas rodykles kintamasis geriausiu atveju nepadidino atminties poreikio (jei kompileris pakankamai protingas). |
|
|
|
|
|
eeprom 24c32 |
Parašytas: 2019 01 13, 20:11 |
|
|
|
nenoriu kurti naujos temos, gal kasnors isgelbes
taip rasant veikia, isveda temperatura i lcd.
Kodas: |
char res[5];
ftoa(temperaTURA, res, 2);
ST7735_WriteString(5, 40, RES, Font_11x18, COLOR565_ORANGE_RED, COLOR565_BLACK);
|
bet sitas konvertavimas daug kartu kartojasi su vis kitokiais skaiciais, sugalvojau pasirasyti funkcija.
Kodas: |
const char* ftoa_convert(float skaicius){
char buffer[5];
ftoa(skaicius, buffer, 2);
return buffer;
}
ST7735_WriteString(5, 40, ftoa_convert(temperatura), Font_11x18, COLOR565_ORANGE_RED, COLOR565_BLACK);
|
nesupranta to ka grazina ftoa_convert.
function returns address of local variable [-Wreturn-local-addr] |
|
_________________ Skype: dmb-220 |
|
|
|
|
|
Google paieška forume |
|
|
Naujos temos forume |
|
|
FS25 Tractors
Farming Simulator 25 Mods,
FS25 Maps,
FS25 Trucks |
|
ETS2 Mods
ETS2 Trucks,
ETS2 Bus,
Euro Truck Simulator 2 Mods
|
|
FS22 Tractors
Farming Simulator 22 Mods,
FS22 Maps,
FS25 Mods |
|
VAT calculator
VAT number check,
What is VAT,
How much is VAT |
|
LEGO
Mänguköök,
mudelautod,
nukuvanker |
|
Thermal monocular
Thermal vision camera,
Night vision ar scope,
Night vision spotting scope |
|
FS25 Mods
FS25 Harvesters,
FS25 Tractors Mods,
FS25 Maps Mods |
|
Dantų protezavimas
All on 4 implantai,
Endodontija mikroskopu,
Dantų implantacija |
|
FS25 Mods
FS25 Maps,
FS25 Cheats,
FS25 Install Mods |
|
GTA 6 Weapons
GTA 6 Characters,
GTA 6 Map,
GTA 6 Vehicles |
|
FS25 Mods
Farming Simulator 25 Mods,
FS25 Maps |
|
ATS Trailers
American Truck Simulator Mods,
ATS Trucks,
ATS Maps |
|
|
|