AT24C32 not able to write in Test Program for STM32F103C8T6

Post here all questions related to LibMaple core if you can't find a relevant section!
Post Reply
asking
Posts: 16
Joined: Mon May 29, 2023 1:15 pm

AT24C32 not able to write in Test Program for STM32F103C8T6

Post 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);
}

stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post by stevestrong »

Which core do you use?
Which board have you selected in the Arduino IDE?
asking
Posts: 16
Joined: Mon May 29, 2023 1:15 pm

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

Post by asking »

In Arduino its showing as

STM32F1XX/GD32F1XX Boards by stm32duino.

I have Selected Generic STM32F103C6/fake STM32F103C8T6
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post by stevestrong »

OK, @fpiSTM should be able to give you more support.
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

Unfortunately not. This menu is not in the stm32 core.
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post by stevestrong »

@asking which core do you use?
How did yo get this board in Arduino boards menu?
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post by fpiSTM »

@stevestrong
This menu is part of the libmaple core:
https://github.com/rogerclarkmelbourne/ ... s.txt#L446
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

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

Post 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?
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

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

Post 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:
Post Reply

Return to “General discussion”