Flash Memory Library

This library provides routines for accessing microcontroller's (internal) Flash memory.

The program Flash array for the PIC32MX device is built up of a series of rows. A row contains 128 32-bit instruction words or 512 bytes. A group of 8 rows compose a page; which, therefore, contains 8 × 512 = 4096 bytes or 1024 instruction words.

A page of Flash is the smallest unit of memory that can be erased at a single time. The program Flash array can be programmed in one of two ways:

The CPU stalls (waits) until the programming operation is finished. The CPU will not execute any instruction, or respond to interrupts, during this time. If any interrupts occur during the programming cycle, they remain pending until the cycle completes.

Library Routines

Flash_Write_Word

Prototype

void Flash_Write_Word(unsigned long address, unsigned long wdata);

Description

Writes one 32-bit word in the program Flash memory on the designated address.

Parameters
  • address: address of the Flash memory word.
  • wdata: data to be written.
Returns

Nothing.

Requires

Nothing.

Example

Notes

None.

Flash_Write_Row

Prototype

void Flash_Write_Row(unsigned long address, void *rdata);

Description

Writes one row in the program Flash memory (128 32-bit words or 512 bytes) on the designated address.

Parameters
  • address: address of the Flash memory word.
  • rdata: data to be written.
Returns

Nothing.

Requires

Nothing.

Example

Notes

None.

Flash_Erase_Page

Prototype

void Flash_Erase_Page(unsigned long address);

Description

Erases one page (8 rows, 1024 32-bit word, 4096 bytes) from the program Flash memory.

Parameters
  • address: starting address of the Flash memory block.
Returns

Nothing.

Requires

Nothing.

Example

Notes

None.

Copyright (c) 2002-2012 mikroElektronika. All rights reserved.
What do you think about this topic ? Send us feedback!
Want more examples and libraries? 
Find them on LibStock - A place for the code