How To Use The AT24C32 EEPROM For 4KB External Memory For Microcontrollers

Electronic Wizard in his lab wearing his wizards hat

Over on YouTube [Electronic Wizard] explains how to use the AT24C32 EEPROM for external memory for microcontrollers.

He begins by explaining that you don’t want to try modifying your microcontroller flash memory for storing settings, you want to use a separate EEPROM for that. Sometimes your microcontroller will have EEPROM memory attached, but you might still find yourself needing to attach more. The AT24C32 EEPROM is a 4KB non-volatile memory chip. It’s available in various 8-pin packages and two voltage levels, either 2.7 to 5.5 volts or 1.8 to 5.5 volts, and it’s programmed using the I2C protocol.

The AT24C32 has three address pins, A{0,1,2}, a Serial Data pin (SDA), a Serial Clock Input (SCL), and a Write Protect pin. He explains how to use the address pins to set the device I2C address and goes into some detail about how the I2C protocol works. Microcontrollers usually have an API for talking to I2C devices, for STM32 controllers that is functions such as HAL_I2C_Master_Transmit(). He refers the viewer to the datasheet for how to accomplish various write and read operations over I2C. The AT24C32 uses 16 bits for addresses of which only 12 are relevant (13 bits are relevant for the 8KB version of the EEPROM the AT24C64).

If you’re interested in EEPROMs you might also like to read Erasing EEPROMs Isn’t Always As Easy As It Seems and How Do You Test If An EEPROM Can Hold Data For 100 Years?

27 thoughts on “How To Use The AT24C32 EEPROM For 4KB External Memory For Microcontrollers

  1. I like to salvage most if not all ICs from old, broken devices that aren’t worth repairing and I’ve gotten a bunch of these I2C EEPROMs over time. They’re quite handy and what’s not to like if you can get them for free, eh?

        1. I have seen no increase on any China Post or consolidator items. In commercial quantities of electronics maybe $300 on $20,000 worth of stuff that cost $2000 in shipping with FedEx.

  2. What’s next, a video telling us how to use a resistor?

    That thumbnail is crazy, an image clearly showing 5 pins on one side of an 8-pin thoughole device, it’s pin-tips are awkwardly bend so that it acts like some sort of hybrid SMD?!?!? Why is that? Showing an AI generated image of a 3 legged resistor was the maker of the video too lazy to point the camera at the device (the topic of the video) in order to create a thumbnail?

      1. I can see why you say that, but the pins look like normal through hole pins, considering they are wider at the top and then taper to a smaller size to fit a hole/socket. The package itself is just too thick for it to be an SMD part. It’s a crazy confusing AI-image and there is just no good reason for using this fake confusing nonsense. If you want to make a video for people of who you assume are not able to figure this out themselves, then at least show them a real image of the part instead of this fake shit.

    1. For settings that are written rarely, sure.

      For small pieces of data that need fairly frequent updating, I have yet to find a good flash storage solution. Because of the nature of flash writes/erases, flash storage needs several pages and a lot of intermediate code to act as a data store. And most of the libraries I’ve tried would still lose everything to an ill-timed power cycle.

      The NRF52 FDS library comes the closest, IMO, but still needed some patches to avoid duplicate records from corrupted data.

      1. A pretty common way to handle it is to use a form of wear levelling, you don’t need to use a full page at a time, just keep appending the new settings and then scan through the flash to find the most recent one, then when you reach the end you can erase the beginning of the storage and start again. Takes slightly longer to read and write the settings but that typically doesn’t need done very often. It also spreads the wear over a larger amount of flash which helps it last longer.

    2. I did a project last year for work where they wanted a totally standalone unit, not dependent on a PC or other host computer, with various tiny plug-in modules for the various applications’ data; so I used a 24C256 I²C EEPROM in the plug-in module that was smaller than a postage stamp and separate from the microcontroller.  I²C of course takes only two interface pins, plus power and ground.

  3. How is it possible that this community, so intelligent and brilliant, can be so upset by an image created by AI? And someone says, “Is this for beginners?” You have to be very obnoxious to write something like that. The guy is working hard to make a video for his audience, and you freely write something like that… Maybe some of you are smart and skilled, but you have no manners and never touched grass

    1. I agree with the “AI” resistance. That image is completely unnecessary crap. IIt would have been so easy to snap a real picture of the chip instead of going to an POS “AI” to ask for a fake, unfactual image.

      You know that old saying: you can’t judge a book by it’s cover? But if the cover and even more so, the title, is garbage that does not fit the story, then it’s not going to interest the target audience. And that cover is the biggest garbage there is. And that is the reason i will not being looking at that video, ever.

      And it is completely justified to call him out on that.

      Don’t know what you mean by touching grass. Are you on some?

    2. okay… I’ll bite.
      “Is this for beginners” is a very reasonable question to ask if you’d ask me.
      Hackaday is (used to be) about hacks and not about stating the obvious. If you want or need to learn more about electronics at this level there are plenty of websites already showing you how things work. Hackaday is (used to be) the place, a guide you could say, to point you towards items/projects that are new, interesting, special and not about pointing to a video of somebody explaining the parts of the datasheet of a very well known widely used component. I’m not saying that the video itself has no worth, sure, it could be of help to many people. But it does not relate to the level of the usual and expected content as previously seen on Hackaday.

Leave a Reply to CodyCancel reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.