OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 183|回复: 0

Mastering STM32 and EV24C MCU + EEPROM (ST + EVASH)

[复制链接]

47

主题

47

帖子

0

精华

初级会员

Rank: 2

积分
154
金钱
154
注册时间
2024-6-22
在线时间
12 小时
发表于 2024-7-1 12:04:49 | 显示全部楼层 |阅读模式
IntroductionThis guide aims to help you get started with the STM32 microcontroller and EVASH's EV24C series EEPROM chip. Through this tutorial, you'll learn how to use these components in practical projects, from basic to advanced techniques.
Required Materials
  • STM32 development board (e.g., STM32F103C8T6)
  • EVASH EV24C256A EEPROM development kit
  • Connecting wires (DuPont lines)
  • Basic electronic tools (soldering iron, multimeter, etc.)
Connecting the Development Board to EEPROMConnect the STM32 development board to the EV24C256A EEPROM development board as follows:
  • VDD (development board) to VDD (EEPROM)
  • GND (development board) to GND (EEPROM)
  • SCL (development board) to SCL (EEPROM)
  • SDA (development board) to SDA (EEPROM)
Basic Operations1. Initialize I2CInitialize the I2C interface on the STM32:
c复制代码

#include "stm32f1xx_hal.h"I2C_HandleTypeDef hi2c1;void MX_I2C1_Init(void){    hi2c1.Instance = I2C1;    hi2c1.Init.ClockSpeed = 100000;    hi2c1.Init.DutyCycle = I2C_DUTYCYCLE_2;    hi2c1.Init.OwnAddress1 = 0;    hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;    hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;    hi2c1.Init.OwnAddress2 = 0;    hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;    hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;    if (HAL_I2C_Init(&hi2c1) != HAL_OK)    {        // Initialization Error        Error_Handler();    }}

2. Read/Write EEPROMFunctions to read and write to the EEPROM:
c复制代码

HAL_StatusTypeDef EEPROM_Write(uint16_t MemAddress, uint8_t *pData, uint16_t Size){    return HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, MemAddress, I2C_MEMADD_SIZE_16BIT, pData, Size, HAL_MAX_DELAY);}HAL_StatusTypeDef EEPROM_Read(uint16_t MemAddress, uint8_t *pData, uint16_t Size){    return HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, MemAddress, I2C_MEMADD_SIZE_16BIT, pData, Size, HAL_MAX_DELAY);}

Advanced Operations1. Page Write OperationThe EEPROM page write function allows writing multiple bytes of data at once, improving write efficiency.
c复制代码

#define EEPROM_PAGE_SIZE 64HAL_StatusTypeDef EEPROM_PageWrite(uint16_t MemAddress, uint8_t *pData, uint16_t Size){    uint16_t remaining = Size;    while (remaining > 0)    {        uint16_t write_size = remaining > EEPROM_PAGE_SIZE ? EEPROM_PAGE_SIZE : remaining;        if (HAL_I2C_Mem_Write(&hi2c1, EEPROM_ADDRESS, MemAddress, I2C_MEMADD_SIZE_16BIT, pData, write_size, HAL_MAX_DELAY) != HAL_OK)        {            return HAL_ERROR;        }        remaining -= write_size;        pData += write_size;        MemAddress += write_size;        HAL_Delay(5); // Delay to ensure write completion    }    return HAL_OK;}

2. Sequential Read with Auto Address IncrementUse the auto address increment feature to read continuous data from the EEPROM.
c复制代码

HAL_StatusTypeDef EEPROM_SequentialRead(uint16_t MemAddress, uint8_t *pData, uint16_t Size){    return HAL_I2C_Mem_Read(&hi2c1, EEPROM_ADDRESS, MemAddress, I2C_MEMADD_SIZE_16BIT, pData, Size, HAL_MAX_DELAY);}

Taobao Store LinkTo purchase related products, visit our Taobao store: EVASH Taobao Store.
WeChat Message TemplateDear Customer,
We are excited to offer a special promotion, giving away EVASH Ultra EEPROM Development Kits for free, including software code. The first 500 kits are free!
To claim your kit, please provide:
  • Company Name
  • Project Name
  • Contact Person
We look forward to your response!
EVASH Team
Visit our website at evash.top and Taobao store at link.

Contact Information for Free Dev KitWe are pleased to introduce our EVASH Ultra EEPROM Development Kit. We are giving away the first 500 kits for free, including software code.
To receive your free kit, please provide your company name, project name, and contact person.
For more information, visit evash.top.
Best regards,EVASH Team

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2024-11-23 18:47

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

快速回复 返回顶部 返回列表