Atmel AT45DB041 Serial SPI Bus DataFlash Driver



The Atmel AT45DB041D is a 4-megabit SPI serial bus flash memory device.

This is an Embedded-Code.com Free Driver Project !

Our Free Driver Projects are provided as a simple bare bones driver which you may download and use for free! Typically they will be the driver files taken from a product design project we have worked on and are provided to help other programmers get up and running quickly and easily when using the same or a similar device in their project. Free Driver projects have often been designed with specific usage of the target device in mind and the driver will not necessarily provide functionality that utilises all of the device capabilities.

These projects are typically not supplied with separate documentation as the code is well commented. Please look through the header file and source code for full details of the drivers functionality.

This driver has been tested by Embedded-Code.com. Please note that we do not provide technical support for free driver projects.

This Free Driver project is provided with a Commercial Use Licence - please read the 'Free Driver Project Source Code Licence Agreement' section of our Licence page before downloading.


The Atmel AT45DB041 flash memory IC is a SPI bus device. It provides very low cost bulk memory to embedded designs.

Memory organisation:

0×00000 – 0x7FFFF

524288 bytes x 8 (512KB)

Organised as 2,048 pages of 256 bytes (To avoid non binary complexities this driver only uses 256 bytes of each page instead of the 264 which are actually available)

This driver provides the following functions:

TEST FLASH MEMORY

BYTE flash_test_memory (void)

An example of how to use this drivers functions.

Also a useful function if you want to verify the flash memory driver is working properly.

Returns 1 if test passed, 0 if not.

IS FLASH IC PRESENT

BYTE flash_check_present (void)

Useful to check flash chip is there and working

ERASE FLASH MEMORY

void flash_erase_all (void)

WRITE PAGE

void flash_write_page (DWORD address, BYTE *buffer, BYTE erase_first)

Call with:

address Binary byte address (must be the 1st byte of a page)

buffer Array of 256 bytes of data to be written

erase_first 1 = erase buffer first, 0 = don’t erase (if you’ve previously called flash_erase_all)

READ PAGE

void flash_read_page (DWORD address, BYTE *buffer)

Call with:

address Binary byte address (must be the 1st byte of a page)

buffer Array of 256 bytes of data to store read bytes in

READ STATUS

BYTE flash_read_status (void)

Returns status byte (bit 7 low = device is busy)

Please view the sample source code files for full information regarding the driver.


This source code product is written in C and has been designed to be used with any ANSI compliant C compiler on any platform. Direct compatibility has been tested with the compilers and processors / microcontrollers listed below. Using the driver with other ANSI compliant C compilers and devices should not present significant problems.
Tested with the Microchip C18 MPLAB C Compiler for PIC18 family of 8 bit microcontrollers. Free version of the compiler available from Microchip.
Tested with the Microchip C30 MPLAB C Compiler for PIC24 family of 16 bit microcontrollers. Free version of the compiler available from Microchip.


Download our generic header file
Download driver .h header file
Download driver .c code file
Download AT45DB041D datasheet


Please ensure you read and understand the 'Free Driver Project Source Code Licence Agreement' section of our Licence page before downloading these project files.