cancel
Showing results for 
Search instead for 
Did you mean: 

HAL i2c 0x78 problem

adelsaeed
Associate II

iam using nucleo f446re for reading from and writing to i2c eeprom 
on arduino i used to extrat the 7bit address from the 10 bit 
using this core for that 

void writeLexChip(uint16_t TenBits_slave_address, uint8_t firstRegisterByte, uint8_t secondRegisterByte, uint8_t thirdRegisterByte, uint8_t *contentBuffer, uint16_t writeSize) {
ChipOn();
uint16_t slave_address_LSB = TenBits_slave_address & 0x0FF;
uint16_t slave_address_MSB = TenBits_slave_address & 0x300;
slave_address_MSB = slave_address_MSB >> 8;
uint8_t SevenBits_compat_address = 0x78 | slave_address_MSB;
contentBuffer[0] = slave_address_LSB;
contentBuffer[1] = firstRegisterByte;
contentBuffer[2] = secondRegisterByte;
contentBuffer[3] = thirdRegisterByte;
Wire.beginTransmission(SevenBits_compat_address);
Wire.write(contentBuffer, 4 + writeSize);
Wire.endTransmission(true);
Serial.println(F("Write OK"));
ChipOff();
}

on stm32 cube ide i worked for many many weeks for even show the i2c address on any i2c scanner source on internet 
or try to make one 
try to use for (i=o i<127; i++)
time 127 and time 177 like some arduino codes 
the nucleo f446re totally refuse to show 0x78 address while it is so easy to do that using eso8266 or arduino uno or nano or any other trademark 
i used HAL isdevice ready 
mem read
i2c master recive 
with all possible ways 
like using software i2c on arduino with this board 
using internal pullups or external
and then i found that this address is reserved for RTC BKP register 10 in the stm32fxx.h file 
can i avoid that or change the reserved address in the source 
can any one help me please 

 

5 REPLIES 5
TDK
Guru

> iam using nucleo f446re for reading from and writing to i2c eeprom 

What EEPROM are you using? How is it hooked up to the Nucleo board, specifically? What pins, are external pullups present? Do SDA/SCL lines read 3.3V when probed with a multimeter?

Once hooked up, create a CubeMX project, initialize the I2C peripheral and pins you are using and write a program which uses HAL_I2C_IsDeviceReady to look for the device. Show the code you are using. Do you get HAL_OK back?

 

> try to use for (i=o i<127; i++)

It does no good to post rubbish code like this. Show the actual code you are using.

If you feel a post has answered your question, please click "Accept as Solution".

uint32_t RESERVED6[2];  /*!< Reserved, 0x78-0x7C
__IO uint32_t BKP10R;     /*!< RTC backup register 10, Address offset: 0x78 */

stm32f412rx.h

i found the 0x78 address is used for the RTC in the bkp register 10 as reserved address and i need to use it for my i2c eeprom 
and my i2c eeprom 
working with this address 
and i provided the arduino code i used to use it for my eeprom 
and its working very good 
how does agood microprocessor like nucleo f446re cannot handle such process 





> how does agood microprocessor like nucleo f446re cannot handle such process 

well that's easy, bad coding

 

I'm not following your logic at all. You're using an STM32F446RE chip, and you're using an STM32F412 as the EEPROM? And you think a register in the RTC is the slave address of that chip? It just doesn't make any logical sense. A STM32F412 will not act as an I2C device unless its firmware is coded to do that.

After re-reading, maybe you're not using the F412 at all, but then why are we talking about it? I asked which EEPROM chip you're using and your answer only mentions the F412 chip.

 

Showing arduino can't explain why you're HAL code (unshown) will not work.

 

I feel like I'm not being very useful here, but perhaps if you run through exactly what you're doing, with code, I could provide more assistance. If you just want to complain about why things won't work, you can do that here, but you probably won't get to the root of the issue either. And if you just want to complain, that's fine too. Cheers.

If you feel a post has answered your question, please click "Accept as Solution".

the eeprom am using is 
TIOB46B1
you will not find datasheet for it 
but i used to read it or write with these steps and discribtion
**********************************************************************************************************

//We use 10 bits I2C address but Atmega is only compatible with 7 bits address. That's not a problem.
//We just have to trick a little bit because 10 bits addressing is completely fine with the standard I2C physical protocol

//Let's say address = [9876543210] (10 bits)

//Here is how to write communication to a 10bits addressed slave : (A = ACK)
//[START] [0b1111 098W]A [76543210]A [WRITE_1]A [WRITE_2]A ... [WRITE_N]A [STOP]

//We begin with the template '1111 0' in order to talk to 10-bits addressed slaves, followed by 2 address bits, and W.
//Then the first byte we transmit are the 8 following bits of the address, in order to finish the 10 bits addressing.
//Nothing else changes. In order to know if the slave is missing, it's the second ACK that should be checked.


//Read communication (NA = NACK)
//[START] [0b1111 098W]A [76543210]A [RESTART] [0b1111 098R]A [ANSWER_1]A [ANSWER_2]A ... [ANSWER_N]NA [STOP]
//We begin as a standard 10 bits addressed write in order to ask our question to the slave, then we do a restart in order to get the answer

//After the restart, only one byte can be placed (with Read Bit at the end) before reading, so we cant put the full 10 bits address. We put only but the begining of the address.
//The fully adressed component just before the restart will be the only one to answer.

************************************************************************************************************************************
and am not using STM32F412  as i2c eeprom
am just using nucleo f446re  and i think that the RTC bkp register is the problem that makes nucleo cannot deal with address 0x78 
because o ised RPI 1 and arduino and every this is too good 
this is the arduino code i used to use old 

bool read_TI046B1_register(uint16_t TenBits_slave_address, uint8_t firstRegisterByte, uint8_t secondRegisterByte, uint8_t thirdRegisterByte, uint8_t * destinationBuffer, uint16_t readSize)
{
  uint16_t slave_address_LSB = TenBits_slave_address & 0x0FF; //0076543210 //8 LSB
  uint16_t slave_address_MSB = TenBits_slave_address & 0x300; //9800000000 //2 MSB
 
  //Put the MSB bits to the Left :
  slave_address_MSB = slave_address_MSB >> 8; //For example, 0x300 becomes 0x003
 
  //7 bits address equivalent for the begining :
  uint8_t SevenBits_compat_address = 0x78 | slave_address_MSB; //TWI library will put send those 7 bits followed by read/write bit.
 
 
  //Preparation of the write buffer : 8LSB of the slave's address, then 3 bytes writes to call a register read.
  uint8_t txBuffer[4];
  txBuffer[0] = slave_address_LSB;
  txBuffer[1] = firstRegisterByte;
  txBuffer[2] = secondRegisterByte;
  txBuffer[3] = thirdRegisterByte;
 
  //Execution of the 4 bytes write
  uint16_t nRet = twi_writeTo(SevenBits_compat_address, txBuffer, 4, 1, false); //4 bytes, wait, and no stop, since we will do a restart in order to read just after
  if (nRet == 1)
  {
    //it seems, reading TWI code, that the stop is sent anyway when there is a NACK. No need to call twi_stop().
    Serial.println("Error occured wile trying to write to the slave : TWI class's buffer is too small");
    return false;
  }

  else if (nRet == 2)
  {
    //it seems, reading TWI code, that the stop is sent anyway when there is a NACK. No need to call twi_stop().
    Serial.println("Error occured wile trying to write to the slave : Slave's address not acknowldged (begning only) - is it connected ?");
    return false;
  }
 
  else if (nRet == 3)
  {
    //it seems, reading TWI code, that the stop is sent anyway when there is a NACK. No need to call twi_stop().
    Serial.println("Error occured wile trying to write to the slave :");
    Serial.println("Slaves's begining of address acknowledged but NACK encountered during the following writes - are all of the 10 bits of slave's address correct ? Are the writes value are meaningful to the slave ?");
   
    return false;
  }

  else if (nRet == 4)
  {
    //it seems, reading TWI code, that the stop is sent anyway when there is a NACK. No need to call twi_stop().
    Serial.println("I2C protocol error occured wile trying to write to the slave. Is the wiring correct ? TWI Initialisation ?");
    return false;
  }
 
  //else :
  nRet = twi_readFrom(SevenBits_compat_address, destinationBuffer, readSize, true); //xxx bytes read with a Stop at the end.  
  if (nRet == 0x00)
  {
    //Incomplete reading : twi_stop() already done anyway when there is a NACK on Addr + read.
    Serial.println("Error occured wile trying to read from the slave.");
    return false;
  }

  if (nRet != readSize)
  {
    //Incomplete reading : twi_stop() already done anyway when there is a NACK on Addr + read.
    Serial.print("Unable to read all the bytes from the slave : ");
    Serial.print(nRet, DEC);
    Serial.println(" bytes read");
   
    return false;
  }

  //else :

  Serial.print("uint8_t destinationBuffer[");
  Serial.print(readSize);
  Serial.print("] = {");
  for (uint16_t i=0; i<readSize; i++)
  {
    char bufferHex[5];
    sprintf(bufferHex, "0x%02X", destinationBuffer[i]);
    Serial.write(bufferHex);
    if (i != readSize-1) Serial.print(", ");
    else Serial.print("};");
  }
  Serial.println(""); //prints a new line


  //Uncomment this to print as ASCII.
  // It doesn't print very well, prefer using a c computer program, fopen and fwrite, and
  // recopy previous results (looking like a C/C++ buffer declaration with the content included)
  // Then you can see it with the editor of your choice (wich is, of course, notepad++).
  /*Serial.print("destinationBuffer = ");
  for (uint16_t i=0; i<readSize; i++)
  {
    Serial.write(destinationBuffer[i]);
  }
  Serial.println(""); //prints a new line
  */
  return true;
}

 

Lexmark toner chip Ti046b1

here:

https://www.eevblog.com/forum/projects/lexmark-toner-chip-ti046b1/

AScha3_0-1710431183333.png

 

 

If you feel a post has answered your question, please click "Accept as Solution".