Page 1 of 1

AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Tue Feb 13, 2024 1:25 pm
by asking
Hi,

I have tried below code to test the simple byte function and read the same.

Circuit is connected to port and I2C Scanner is detecting Chip @ 0x50 Address. Working @ 3.3V. WP on AT24C32 Pin is left open.

What else could be issue ?

Code: Select all

#include <Wire.h>

#define EEPROM_ADDRESS 0x50 // I2C address of the EEPROM

void setup() {
  Wire.begin();
  Serial.begin(9600);
}

void writeByteToEEPROM(byte data, int address) {
  Wire.beginTransmission(EEPROM_ADDRESS); // Start communication with the EEPROM
  Wire.write(address >> 8); // Send high byte of the address
  Wire.write(address & 0xFF); // Send low byte of the address
  Wire.write(data); // Send data byte
  Wire.endTransmission(); // End communication with the EEPROM
}

byte readByteFromEEPROM(int address) {
  byte data = 0;
  Wire.beginTransmission(EEPROM_ADDRESS); // Start communication with the EEPROM
  Wire.write(address >> 8); // Send high byte of the address
  Wire.write(address & 0xFF); // Send low byte of the address
  Wire.endTransmission(false); // End transmission with repeated start
  Wire.requestFrom(EEPROM_ADDRESS, 1); // Request 1 byte from the EEPROM
  if (Wire.available() >= 1) {
    data = Wire.read(); // Read data byte
  }
  return data;
}

void loop() {
  byte dataToWrite = 42; // Byte data to write to the EEPROM
  int addressToWrite = 0; // Address in the EEPROM where you want to write the byte

  writeByteToEEPROM(dataToWrite, addressToWrite); // Write the byte to the EEPROM

  // Read the byte back from the EEPROM for verification
  byte readData = readByteFromEEPROM(addressToWrite);

  Serial.print("Data written to EEPROM: ");
  Serial.println(dataToWrite);
  Serial.print("Data read from EEPROM: ");
  Serial.println(readData);

  delay(1000);
}


Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Tue Feb 13, 2024 2:22 pm
by stevestrong
Which core do you use?
Which board have you selected in the Arduino IDE?

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 5:37 am
by asking
In Arduino its showing as

STM32F1XX/GD32F1XX Boards by stm32duino.

I have Selected Generic STM32F103C6/fake STM32F103C8T6

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 10:40 am
by stevestrong
OK, @fpiSTM should be able to give you more support.

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 12:09 pm
by fpiSTM
Unfortunately not. This menu is not in the stm32 core.

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 12:18 pm
by stevestrong
@asking which core do you use?
How did yo get this board in Arduino boards menu?

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 1:29 pm
by fpiSTM
@stevestrong
This menu is part of the libmaple core:
https://github.com/rogerclarkmelbourne/ ... s.txt#L446

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 1:42 pm
by stevestrong
fpiSTM wrote: Wed Feb 14, 2024 1:29 pm @stevestrong
This menu is part of the libmaple core:
https://github.com/rogerclarkmelbourne/ ... s.txt#L446
That is true, just that
STM32F1XX/GD32F1XX Boards by stm32duino.
is not known.

@asking supposed it is the Libmaple core, what exactly is not working?
Please select "Generic STM32F103C" as board from Arduino menu and check again.


@fpiSTM could you eventually move this post under Cores -> Libmaple?

Re: AT24C32 not able to write in Test Program for STM32F103C8T6

Posted: Wed Feb 14, 2024 1:47 pm
by fpiSTM
stevestrong wrote: Wed Feb 14, 2024 1:42 pm
fpiSTM wrote: Wed Feb 14, 2024 1:29 pm @stevestrong
This menu is part of the libmaple core:
https://github.com/rogerclarkmelbourne/ ... s.txt#L446
That is true, just that
STM32F1XX/GD32F1XX Boards by stm32duino.
is not known.
Guess it is linked to dandrown package json file.
stevestrong wrote: Wed Feb 14, 2024 1:42 pm @fpiSTM could you eventually move this post under Cores -> Libmaple?
Already done :mrgreen: