The Datasheet Archive - 100 Million Datasheets from 7500 Manufacturers.    


Datasheet Search Engine   
 
Part # or Description: • 5V RS232 Driver • 2SC5066* • "Real Time Clock" • "USB connector" • "blue led" 5mm • 10 watt zener diode • 2N3055* motorola
 
Search Tip: Try entering the part number only. Include a wildcard (eg. lm317* or 1n4148*)

 

 

INTRODUCTION This application note provides library source code M58BF0


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Software Drivers M58BF008 Flash Memory
INTRODUCTION This application note provides library source code M58BF008 Flash Memory. M58BF008 supports both Asynchronous Synchronous Burst interfaces. code drivers work layer above hardware used successfully over either interface. Listings source code found this document. source code also available file form from internet site http://www.st.com from your STMicroelectronics distributor. c1204_32.c c1204_32.h files contain libraries accessing M58BF008 Flash Memories. Also included this application note overview programming model M58BF008. This will familiarize reader with operation memory devices provide basis understanding modifying accompanying source code. source code written platform independent possible requires minimal changes user order compile run. application note explains user should modify source code their individual target hardware. source code backed comments explaining used been written has. This application note does replace M58BF008 datasheet. refers datasheet throughout necessary have copy order follow some explanations. software accompanying documentation been fully tested target platform. small size applied target hardware. M58BF008 PROGRAMMING MODEL M58BF008 (256Kb x32) Flash Memory which electrically erased programmed through special coded command sequences most standard microprocessor buses. device broken down into blocks, each Kbytes size. Each block erased individually, whole chip erased once, erasing 8Mb. additional Kbyte Overlay Block provided hold boot code microprocessor; once booted microprocessor hide Overlay Block access Block M58BF008 smart voltage device. differs from first generation dual voltage devices which require supply
INTRODUCTION M58BF008 PROGRAMMING MODEL WRITING CODE M58BF008 LIBRARY FUNCTIONS PROVIDED PORTING DRIVERS TARGET SYSTEM LIMITATIONS SOFTWARE CONCLUSION c1204_32.h LISTING c1204_32.c LISTING
December 2000
1/27
AN1204 APPLICATION NOTE
program erase. M58BF008 therefore easier since hardware does need cater special signal levels. voltages needed erase device generated charge pumps inside device. Three power supply pins used give optimal supply voltage conditions. normal operation core supplied with buffers supplied with 3.3V Supply supplied with (all blcks protected) blocks protected). program/erase section supplied with through speed programming factory; this mode used permanent solution. Included device Program/Erase Controller. With first generation Flash Memory devices software manually program words 0000h before erasing FFFFh using special programming sequences. Program/Erase Controller M58BF008 allows simpler programming model used, taking care necessary steps required erase program memory. This improved reliability that excess 10,000 program/erase cycles guaranteed block device. Operations Commands Most functionality M58BF008 available standard operations: read write. Read operations retrieve data status information from device. Write operations interpreted device commands, which modify data stored behavior device. Only certain special sequences write operations recognized commands M58BF008. various commands recognized M58BF008 listed Instructions Table datasheet; main commands grouped follows: Read Read Electronic Signature Erase Program Program/Erase Suspend Enable/Disable Overlay Block Asynchronous/Synchronous interface toggle. Read command returns M58BF008 Read mode where behaves ROM. this state, read operation outputs onto data data stored specified address device. Read Electronic Signature command places device mode which allows user read Manufacturer, Device Code Version Code device. library software drivers this mode known Auto Select mode make M58BF008 compatible with series Flash Memories. Erase command used bits every memory location selected block. data previously stored erased block will lost. erase command takes longer execute than other commands, because entire block erased once. Attempts erase program block while memory protected (i.e. VIL) generate error modify contents memory. special command used erase Overlay Block, providing additional security data Overlay Block. Program command used modify data stored specified address device. Note that programming only change bits from `0'. Attempting change using Program command will fail, though Status Register indicate failure. therefore necessary erase block before programming addresses within Programming modifies single word time. Programming larger amounts data must done word time, issuing Program command, waiting command complete, then issuing next Program command, special command used program Overlay Block, providing additional security data Overlay Block.
2/27
AN1204 APPLICATION NOTE
Issuing Program/Erase Suspend command during Program Erase operation will temporarily place M58BF008 Program/Erase Suspend mode. While Erase operation being suspended blocks being erased read programmed reset state device. While Program operation being suspended rest device read. This allows user access information stored device immediately rather than waiting until Program Erase operation completes, typically 10µs programming 0.33s erasing M58BF008. Program Erase operation resumed when device receives Program/Erase Resume command. Overlay Block read same address space Block Overlay Block Toggle command used switch between reading Overlay Block reading Block Special commands used program erase Overlay Block independent block selected Read mode. interface read operations toggled between asynchronous synchronous modes. However write operations will either asynchronous synchronous depending factory configuration device. code does include this function would typically performed part hardware initialisation. Status Register While M58BF008 programming erasing, read from device will output Status Register Program/Erase Controller. Status Register, which also accessed issuing Read Status Register command, provides valuable information about most recent Program Erase command. Status Register bits described Status Register Bits Table M58BF008 datasheet. Their main determine when programming erasing complete whether successful not. Completion Program Erase operation indicated Program/Erase Controller Status (Status Register DQ7) becoming `1'. Programming erasing errors then indicated more various error bits (Status Register bits DQ3, DQ5) being `1'. failure occurs Status Register error bits will remain until Clear Status Register command issued device. This should done before performing further operations will possible determine whether following operation resulted error not. Detailed Example Instructions Table M58BF008 datasheet describes sequences write operations that will recognized Program/Erase Controller valid commands. example programming 3F819465h address 03E2h requires user write following sequence *(unsigned long*)(0x0000) 0x00000040; *(unsigned long*)(0x03E2) 0x3F819465; first addresses (0000h) arbitrary, long inside Flash address space. This example assumes that address 0000h M58BF008 mapped address 0000h microprocessor address space. practice likely that Flash will have base offset which needs added address. While device programming specified address, read operations will access Status Register bits. Status Register will while programming on-going will become completion. Status Register bits completion then Program command will have failed. Status Register bits indicate error when attempt change been made; recommended that value memory after programming compared desired value trap this error. WRITING CODE M58BF008 low-level functions (drivers) described this application note have been provided simplify process developing application code STMicroelectronics Flash Memories (M58BF008). This enables users concentrate writing high level functions required their particular applications.
3/27
AN1204 APPLICATION NOTE
These high level functions access Flash Memories calling level drivers, hence keeping details special command sequences away from users' high level code: this will result source code both simpler easier maintain. Code developed using drivers provided decomposed into three layers: hardware specific operations low-level drivers high level functions written user implementation hardware specific read write operations required lowlevel drivers order communicate with M58BF008. This implementation hardware platform dependent affected which microprocessor code runs where microprocessor's address space memory device located. user will have write functions appropriate hardware platform (see FlashRead() FlashWrite() next section). low-level drivers take care issuing correct sequences write operations each command interpreting information received from device during programming erasing. These drivers encode specific details issue commands interpret Status Register bits. high level functions written user will access memory device calling low-level functions. keeping specific details access M58BF008 away from high level functions, user left with code which simple easier maintain. also makes user's high level functions easier apply other STMicroelectronics Flash Memories. When developing application, user advised proceed follows: first write simple program test level drivers provided verify that these operate expected user's target hardware software environments. then user should write high level code application, which will access Flash Memories calling level drivers provided. finally test complete application source code thoroughly. LIBRARY FUNCTIONS PROVIDED software library provided with this application note provides user with source code following functions: FlashReadReset() used reset device into Read Array mode. Note that there should need call this function under normal operation other software library functions leave device this mode. FlashAutoSelect() used identify Manufacturer Code, Device Code Version Code device. function uses Read Electronic Signature mode device. function called FlashAutoSelect() make compatible with series Flash Memories. FlashBlockErase() used erase block device. blocks cannot erased when invalid: attempting generates error leaves Flash indeterminate state. FlashChipErase() used erase entire chip. chip cannot erased when invalid: attempting generates error leaves Flash indeterminate state. FlashProgram() used program data arrays into Flash. Only previously erased double words programmed reliably. Again, programming cannot take place when invalid. FlashOverlayBlockEnable() used enable Overlay Block disable Block future calls FlashRead(). FlashOverlayBlockDisable() used disable Overlay Block enable Block future calls FlashRead().
4/27
AN1204 APPLICATION NOTE
FlashOverlayBlockRead() used read double word from Overlay Block then disable Overlay Block. useful retrieve single values, multiple reads enable Overlay Block, read values required disable again. FlashOverlayBlockErase() used erase Overlay Block. Overlay Block cannot erased when invalid: attempting generates error leaves Flash indeterminate state. FlashOverlayProgram() used program data arrays into Flash. Only previously erased words programmed reliably. Again, Overlay Block cannot programmed when invalid. functions provided software library rely user implementing hardware specific operations. This done writing functions follows: FlashRead() must written read value from Flash. FlashWrite() must written write value Flash. example these functions provided source code. many instances these functions written macros therefore will incur function call time overhead. functions which perform basic device have been provided users have awkward systems. example where addressing system peculiar data D0.D15 device D16.D31 microprocessor. They allow user quickly adapt code virtually target system. Throughout functions assumptions have been made data types. These are: char bits byte). This case microcontrollers. Where will necessary mask unused bits word. bits bytes). Again, like char, this case will necessary variable type which bits longer mask bits above bits (particularly user's FlashRead() function). long bits bytes). necessary have arithmetic greater than bits order address entire device. approaches addressing available: desired address Flash specified linear pointer offset into device could provided user. FlashRead() functions each case would declared unsigned long FlashRead( unsigned long *Addr); unsigned long FlashRead( unsigned long ulOff); pointer option advantage that runs faster. offset needs changed address each access this involves arithmetic. Using offset however, more portable since resulting software easily changed microprocessors with segmented memory spaces (such 8086). maximum portability functions this application note unsigned long offset, rather than pointer. PORTING DRIVERS TARGET SYSTEM Before using software Target System user needs write FlashRead() FlashWrite() functions appropriate Target Hardware. example FlashRead() FlashWrite() functions provided source code should give user good idea what required used many instances without much modification. test source code Target System start simply reading from M58BF008. erased then only FFFFFFFFh data should read. Next read Manufacturer Device codes check they correct. these functions work then likely that functions will work they should tested thoroughly.
5/27
AN1204 APPLICATION NOTE
programmer needs take extra care when device accessed during interrupt service routine. situations exist which must considered: When device Read mode interrupts freely read from device. Interrupts which access device used during functions. programmer should also take care when Reset applied during Program Erase operations. Flash will left indeterminate state data could lost. LIMITATIONS SOFTWARE software provided does implement full M58BF008's functionality. left user implement Program/Erase Suspend command device. Standby mode hardware feature device cannot controlled through software. left user implement Asynchronous/Synchronous Read Toggle command, this considered hardware feature that outside scope these code drivers. Care should taken some while() loops. time-outs have been implemented. Software execution stop loops hardware error. TimeOut! comment been these places user timer them prevent software failing. software only caters device system. software more devices mechanism selecting devices will required. When error occurs software simply returns error message. left user decide what Either command tried again necessary device need replaced. CONCLUSION M58BF008 single voltage Flash Memory ideal product embedded other computer systems, able easily interfaced microprocessors driven with simple software drivers written language.
6/27
AN1204 APPLICATION NOTE
/**** c1204_32.h Header File Flash Memory Filename: c1204_32.h Description: Header file c1204_32.c V1.02. Consult file details Copyright 2000 STMicroelectronics. THIS PROGRAM PROVIDED WITHOUT WARRANTY KIND,EITHER EXPRESSED IMPLIED, INCLUDING LIMITED IMPLIED WARRANTY MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM WITH YOU. SHOULD PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION. Commands various functions Read Signature values #define FLASH_READ_MANUFACTURER (-3) #define FLASH_READ_DEVICE_CODE (-2) #define FLASH_READ_VERSION_CODE (-1) Error Conditions return values. file explanations help #define FLASH_SUCCESS (-1) #define FLASH_BLOCK_INVALID (-5) #define FLASH_PROGRAM_FAIL (-6) #define FLASH_OFFSET_OUT_OF_RANGE (-7) #define FLASH_WRONG_TYPE (-8) #define FLASH_BLOCK_FAILED_ERASE (-9) #define FLASH_UNPROTECTED (-10) #define FLASH_PROTECTED (-11) #define FLASH_FUNCTION_NOT_SUPPORTED (-12) #define FLASH_VPP_INVALID (-13) #define FLASH_ERASE_FAIL (-14) #define FLASH_UNPROTECT_FAIL (-16) #define FLASH_PROTECT_FAIL (-18) #define FLASH_OVERLAY_FAIL (-19) #define FLASH_OVERLAY_DISABLED (-20) #define FLASH_OVERLAY_ENABLED (-21) Function Prototypes extern unsigned long FlashRead( unsigned long ulOff extern void FlashReadReset( void extern FlashAutoSelect( iFunc extern FlashBlockErase( unsigned char ucBlock extern FlashChipErase( *iResults extern FlashProgram( unsigned long ulOff, size_t NumWords, void *Array extern FlashOverlayBlockDisable( void extern FlashOverlayBlockEnable( void extern unsigned long FlashOverlayBlockRead( unsigned long ulOff, *iRetVal extern FlashOverlayBlockErase( void extern FlashOverlayBlockProgram( unsigned long ulOff
7/27
AN1204 APPLICATION NOTE
size_t NumWords, void *Array extern char *FlashErrorStr( iErrNum
8/27
AN1204 APPLICATION NOTE
/**** c1204_32.c M58BFxxx Flash Memory Driver Filename: c1204_32.c Description: Library routines M58BFxxx Flash Memory. Version: Date: Author: 1.02 Initial release. 08/11/2000 Webster, Oxford Technical Solutions (www.ots.ndirect.co.uk)
Copyright 2000 STMicroelectronics. THIS PROGRAM PROVIDED WITHOUT WARRANTY KIND, EITHER EXPRESSED IMPLIED, INCLUDING LIMITED IMPLIED WARRANTY MERCHANTABILITY FITNESS PARTICULAR PURPOSE. ENTIRE RISK QUALITY PERFORMANCE PROGRAM WITH YOU. SHOULD PROGRAM PROVE DEFECTIVE, ASSUME COST NECESSARY SERVICING, REPAIR CORRECTION. Version History. Ver. 1.00 1.01 1.02 1.03 Date Comments
03/10/2000 Initial creation 07/11/2000 programming failure attempt program functions FlashProgram FlashOverlayProgram 08/11/2000 Program Verification functions FlashProgram FlashOverlayBlockProgram 11/12/2000 Changed BASE_ADDR "long*" "int*"
This source file provides library code using M28WxxxC devices. following devices supported code: M58BF008 following functions available this library: FlashRead() FlashReadReset() FlashAutoSelect() FlashBlockErase() FlashChipErase() FlashProgram() FlashOverlayBlockDisable() FlashOverlayBlockEnable() FlashOverlayBlockRead() FlashOverlayBlockErase() FlashOverlayBlockProgram() FlashErrorStr() read from flash reset flash normal memory access information about device erase single block erase whole chip program double-word array enable main block reads enable overlay block reads read double-word from overlay block erase entire overlay block program double-word/array overlay block return error string error
further information consult Data Sheet Application Note. Application Note gives information about modify this code specific application. hardware specific functions which need modified user are: FlashWrite() writing double-word flash
9/27
AN1204 APPLICATION NOTE
FlashRead() reading double-word from flash list error conditions code. There timeouts implemented loops code. each point where infinite loop implemented comment TimeOut! been placed. user implement these avoid code hanging instead timing out. source code assumes that compiler implements numerical types unsigned char unsigned unsigned long bits bits bits
Additional changes code will necessary these correct. #include <stdlib.h> #include "c1204_32.h" #define USE_M58BF008 Constants #define MANUFACTURER_ST (0x00000020L) RSIG manufacturer 0x20 #define BASE_ADDR ((volatile unsigned long*)0x00000000L) BASE_ADDR base address flash, functions FlashRead FlashWrite(). Some applications which require more complicated FlashRead() FlashWrite() BASE_ADDR #define CMD_ADDR (0x00000000L) Address write P/EC #ifdef #define #define #define USE_M58BF008 EXPECTED_DEVICE (0x000000F0L) Device code M58BF008 FLASH_SIZE (0x00040000L) Total device size OVERLAY_SIZE (0x00002000L) Overlay block size Header file with global prototypes
static const unsigned long BlockOffset[] 0x00000000L, Start offset block 0x00002000L, Start offset block 0x00004000L, Start offset block 0x00006000L, Start offset block 0x00008000L, Start offset block 0x0000A000L, Start offset block 0x0000C000L, Start offset block 0x0000E000L, Start offset block 0x00010000L, Start offset block 0x00012000L, Start offset block 0x00014000L, Start offset block 0x00016000L, Start offset block 0x00018000L, Start offset block 0x0001A000L, Start offset block 0x0001C000L, Start offset block 0x0001E000L, Start offset block
10/27
AN1204 APPLICATION NOTE
0x00020000L, 0x00022000L, 0x00024000L, 0x00026000L, 0x00028000L, 0x0002A000L, 0x0002C000L, 0x0002E000L, 0x00030000L, 0x00032000L, 0x00034000L, 0x00036000L, 0x00038000L, 0x0003A000L, 0x0003C000L, 0x0003E000L Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start offset offset offset offset offset offset offset offset offset offset offset offset offset offset offset offset block block block block block block block block block block block block block block block block
#endif USE_M58BF008 #define NUM_BLOCKS Static Prototypes following function only needed this module. static unsigned long FlashWrite( unsigned long ulOff, unsigned long uVal Function: unsigned FlashWrite( unsigned long ulOff, unsigned uVal Arguments: ulOff double-word offset flash write uVal value written Returns: uVal Description: This function used write double-word flash. many microprocessor systems macro used instead, increasing speed flash routines. example: #define FlashWrite( ulOff, uVal BASE_ADDR[ulOff] (unsigned int) uVal function used here instead allow user expand necessary. function made return uVal that compatible with macro. Pseudo Code: Step Write uVal double-word offset flash Step return uVal static unsigned long FlashWrite( unsigned long ulOff, unsigned long uVal Step1, Write uVal double-word offset flash return return BASE_ADDR[ulOff] uVal; Function: unsigned FlashRead( unsigned long ulOff Arguments: ulOff double-word offset into flash read from. Returns: unsigned double-word offset Description: This function used read double-word from flash. many microprocessor systems macro used instead, increasing speed flash routines. example:
11/27
AN1204 APPLICATION NOTE
#define FlashRead( ulOff BASE_ADDR[ulOff] function used here instead allow user expand necessary. Pseudo Code: Step Return value double-word offset ulOff unsigned long FlashRead( unsigned long ulOff Step Return value double-word offset ulOff return BASE_ADDR[ulOff]; Function: void FlashReadReset( void Arguments: none Return Value: none Description: This function places flash Read Array mode described Data Sheet. this mode flash read normal memory. other functions leave flash Read Array mode this strictly necessary. provided completeness. Pseudo Code: Step write command sequence (see Instructions Table Data Sheet) void FlashReadReset( void Step write command sequence FlashWrite( CMD_ADDR, 0xFFFFFFFFL Function: FlashAutoSelect( iFunc Arguments: iFunc should Read Signature values. header file defines values reading Signature. Return Value: When iFunc FLASH_READ_MANUFACTURER (-3) function returns manufacturer's code. Manufacturer code 00000020h. When iFunc FLASH_READ_DEVICE_CODE (-2) function returns Device Code. device codes parts are: M58BF008 0x000000F0
iFunc FLASH_READ_VERSION_CODE (-1) value from reported indicate version flash. When iFunc invalid function returns FLASH_FUNCTION_NOT_SUPPORTED (-12) Description: This function used read electronic signature device manufacturer code. Pseudo Code: Step Send Auto Select Instruction device RSIG instruction Step Read required function from device Step Return device Read Array mode FlashAutoSelect( iFunc iRetVal; Holds return value
12/27
AN1204 APPLICATION NOTE
Step Send Read Electronic Signature instruction FlashWrite( CMD_ADDR, 0x00000090L Step Read required function Note Only valid read addresses A2-17 Don't care iFunc FLASH_READ_MANUFACTURER iRetVal FlashRead( 0x00000000L else iFunc FLASH_READ_DEVICE_CODE iRetVal FlashRead( 0x00000001L else iFunc FLASH_READ_VERSION_CODE iRetVal FlashRead( 0x00000002L else iRetVal FLASH_FUNCTION_NOT_SUPPORTED; Step Return Read Array mode FlashWrite( CMD_ADDR, 0x000000FFL return iRetVal; Function: FlashBlockErase( unsigned char ucBlock Arguments: ucBlock number Block erased. Return Value: function returns following conditions: FLASH_SUCCESS (-1) FLASH_WRONG_TYPE (-8) FLASH_BLOCK_INVALID (-5) FLASH_VPP_INVALID (-13) FLASH_BLOCK_FAILED_ERASE (-9) Description: This function used erase Block specified ucBlock. function checks that block valid before issuing erase command. Once erase completed function checks Status Register errors. errors returned, otherwise FLASH_SUCCESS returned. Pseudo Code: Step Check correct flash type Step Check that block valid Step Issue Erase Command Step Wait until Program/Erase Controller ready Step Check errors Step Return Read Array mode Step Return error condition FlashBlockErase( unsigned char ucBlock iRetVal FLASH_SUCCESS; Holds return value: optimistic initially! unsigned long ulStatus; Holds Status Register reads Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE;
13/27
AN1204 APPLICATION NOTE
Step Check that block valid ucBlock NUM_BLOCKS return FLASH_BLOCK_INVALID; Step Issue Erase Command FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register NOTE also clears well b3,4 FlashWrite( CMD_ADDR, 0x00000020L cycle FlashWrite( BlockOffset[ucBlock], 0x000000D0L cycle Step Wait until Program/Erase Controller ready TimeOut! ulStatus FlashRead(CMD_ADDR); while( (ulStatus&0x00000080L) 0x00000000L Step Check errors ulStatus&0x00000008L iRetVal FLASH_VPP_INVALID; else ulStatus&0x00000020L iRetVal FLASH_BLOCK_FAILED_ERASE; Step Return Read Array mode FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register NOTE also clears well b3,4 FlashWrite( CMD_ADDR, 0x000000FFL Step Return error condition return iRetVal; Function: FlashChipErase( *iResults Arguments: iResults pointer array where results will stored. iResults NULL then results stored. Return Value: function returns following conditions: FLASH_SUCCESS (-1) FLASH_WRONG_TYPE (-8) FLASH_ERASE_FAIL (-14) FLASH_SUCCESS returned then Results left unchanged. FLASH_ERASE_FAIL returned then Results will filled with error conditions each block. possible error conditions are: FLASH_SUCCESS (-1) FLASH_VPP_INVALID (-13) FLASH_ERASE_FAIL (-14) Description: function used erase whole flash chip. Each Block erased turn. function only returns when Blocks have been erased have generated error, except FLASH_VPP_INVALID encountered, which case function aborts reports remaining blocks having FLASH_VPP_INVALID. invalid block then follows that will invalid subsequent blocks (battery failure?). Pseudo Code: Step Check correct flash type Read Array Command
14/27
AN1204 APPLICATION NOTE
Step each block Step Send Block Erase Command Step Register errors array Step FLASH_VPP_INVALID returned fill rest results array abort Step Return error condition FlashChipErase( *iResults unsigned char ucCurBlock; Used track current block range iRetVal FLASH_SUCCESS; Return value: Initially optimistic iError; Holds latest error Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step each block for( ucCurBlock ucCurBlock NUM_BLOCKS; ucCurBlock++ Step Send Block Erase Command iError FlashBlockErase( ucCurBlock iError FLASH_SUCCESS iRetVal FLASH_ERASE_FAIL; Step Register errors array iResults NULL iResults[ucCurBlock] iError; Step FLASH_VPP_INVALID returned fill rest results array abort iError FLASH_VPP_INVALID iResults NULL while( ++ucCurBlock NUM_BLOCKS remaining blocks iResults[ucCurBlock] iError; fill error for() loop will terminate since ucCurBlock NUM_BLOCKS Step Return error condition return iRetVal; Function: FlashProgram( unsigned long ulOff, size_t NumWords, void *Array Arguments: ulOff double-word offset into flash programmed NumWords holds number double-words array. Array pointer array programmed. Return Value: success function returns FLASH_SUCCESS (-1). invalid then function returns FLASH_VPP_INVALID (-13) failure function returns FLASH_PROGRAM_FAIL (-6). address range programmed exceeds address range Flash Device function returns FLASH_ADDRESS_OUT_OF_RANGE (-7) nothing programmed. wrong type flash detected then FLASH_WRONG_TYPE (-8) returned nothing programmed. Description: This function used program array into flash. does
15/27
AN1204 APPLICATION NOTE
erase flash first will fail block(s) erased first. Pseudo Code: Step Check correct flash type Step Check offset range valid Step While there more programmed Step Check changes from Step Program next double-word Step Wait until Program/Erase Controller ready Step Check errors Step Verify program operation Step Update pointers Step 10:Clear status register return read array mode Step 11:Return error condition FlashProgram( unsigned long ulOff, size_t NumWords, void *Array unsigned long *ulArrayPointer; unsigned long access array unsigned long ulLastOff; Holds last offset programmed unsigned long ulStatus; Holds Status Register reads iRetVal FLASH_SUCCESS; Return Value: Initially optimistic Step Check that flash correct type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Check offset range valid ulLastOff ulOff NumWords ulLastOff FLASH_SIZE return FLASH_OFFSET_OUT_OF_RANGE; Step While there more programmed ulArrayPointer (unsigned long *)Array; while( ulOff ulLastOff iRetVal FLASH_SUCCESS Step Check changes from ~FlashRead( ulOff *ulArrayPointer return FLASH_PROGRAM_FAIL; Step Program next double-word FlashWrite( CMD_ADDR, 0x00000050L FlashWrite( CMD_ADDR, 0x00000040L FlashWrite( ulOff, *ulArrayPointer Clear Status Register Program Set-up Program value
Step Wait until Program/Erase Controller ready TimeOut! ulStatus FlashRead(CMD_ADDR); while( (ulStatus&0x00000080L) 0x00000000L Step Check errors ulStatus&0x00000008L iRetVal FLASH_VPP_INVALID; else ulStatus&0x00000010L iRetVal FLASH_PROGRAM_FAIL; FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command
16/27
AN1204 APPLICATION NOTE
Step Verify program operation FlashRead( ulOff *ulArrayPointer iRetVal=FLASH_PROGRAM_FAIL; break; Step Update pointers ulOff++; next double-word offset ulArrayPointer++; next double-word array Step Clear status register return read array mode FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command Step return error condition return iRetVal; Function: FlashOverlayBlockDisable( void Arguments: none Return Value: success this function returns FLASH_SUCCESS (-1) flash overlay block already disabled returns FLASH_OVERLAY_DISABLED. toggle command unsuccessful flash overlay block will disable function returns FLASH_OVERLAY_FAIL. Description: This function gets flash into normal block read mode. Pseudo Code: Step Check correct flash type Step Read Status Register Step Overlay block already disabled nothing inform user that fact Step Disable Overlay Block Step Read Status Register Step Test that Disable Overlay toggle successful Step Return success FlashOverlayBlockDisable( void unsigned long ulStatus; Used store status register value Step Check that flash correct type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Read Status Register ulStatus FlashRead(CMD_ADDR); Step Test already disabled (!(ulStatus 0x00000001L)) FlashWrite( CMD_ADDR, 0x000000FFL return FLASH_OVERLAY_DISABLED;
17/27
AN1204 APPLICATION NOTE
Step Disable Overlay Block Step Read Status Register ulStatus FlashRead(CMD_ADDR); FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command Step Test operation failed (ulStatus 0x00000001L) return FLASH_OVERLAY_FAIL; Step Return Success return FLASH_SUCCESS; Function: FlashOverlayBlockEnable( void Arguments: none Return Value: success function returns FLASH_SUCCESS (-1) flash overlay block already enabled returns FLASH_OVERLAY_ENABLED. toggle command unsuccessful flash overlay block will enable function returns FLASH_OVERLAY_FAIL. Description: This function gets flash into overlay block read mode. Pseudo Code: Step Ensure that have correct flash Step Read Status Register Step Overlay block already enabled nothing inform user that fact Step Enable Overlay Block Step Read Status Register Step Test that Enable Overlay toggle successful Step Return success FlashOverlayBlockEnable( void unsigned long ulStatus; Used store status register value Step Check that flash correct type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Read Status Register ulStatus FlashRead(CMD_ADDR); Step Test already enabled (ulStatus 0x00000001L) FlashWrite( CMD_ADDR, 0x000000FFL return FLASH_OVERLAY_ENABLED; Step Enable Overlay Block Step Read Status Register
18/27
AN1204 APPLICATION NOTE
ulStatus FlashRead(CMD_ADDR); FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command Step Test operation failed (!(ulStatus 0x00000001L)) return FLASH_OVERLAY_FAIL; Step Return Success return FLASH_SUCCESS; Function: unsigned long FlashOverlayBlockRead( unsigned long ulOff, *iRetVal); Arguments: ulOff stores address offset read. iRetVal points return value integer. Return Value: (iRetVal) successful read will return FLASH_SUCCESS (-1). Error conditions possible are: FLASH_OFFSET_OUT_OF_RANGE (-7) when address passed this function outside address space overlay block. FLASH_WRONG_TYPE (-8) part Autoselected expected. Description: This function automatically enables overlay block then reads value address offset ulOff, then resets flash into normal block read mode. Pseudo Code: Step Ensure that address valid overlay block address Step Enable overlay block that read Step Read value address offset ulOff Step Disable overlay block return value read unsigned long FlashOverlayBlockRead( unsigned long ulOff, *iRetVal unsigned long ulTmp; Used store read value from overlay block Step address valid (ulOff OVERLAY_SIZE) else Step overlay block read enable successful return error*/ FLASH_SUCCESS) *iRetVal FLASH_OVERLAY_ENABLED)) Step Read value from overlay block ulTmp FlashRead( ulOff else return Step Return value read from overlay block return ulTmp; return Function: FlashOverlayBlockErase( void Arguments: none Return Value: This function returns FLASH_SUCCESS (-1) overlay block been successfully erased FLASH_BLOCK_FAILED_ERASE (-9) operation
19/27
AN1204 APPLICATION NOTE
failed. Failure return codes are: FLASH_WRONG_TYPE (-8) FLASH_VPP_INVALID (-13) Description: This function erases overlay block. Pseudo Code: Step Check correct flash type Step Issue overlay block erase command Step Wait complete Step Check errors Step Reset device read array mode Step Return iRetVal FlashOverlayBlockErase( void iRetVal FLASH_SUCCESS; Holds return value: optimistic initially! unsigned long ulStatus; Holds Status Register reads Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Issue Erase Command FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register FlashWrite( CMD_ADDR, 0x00000002L cycle FlashWrite( BlockOffset[0], 0x0000000DL cycle Step Wait until Program/Erase Controller ready TimeOut! ulStatus FlashRead(CMD_ADDR); while( (ulStatus&0x00000080L) 0x00000000L Step Check errors ulStatus&0x00000008L iRetVal FLASH_VPP_INVALID; else ulStatus&0x00000020L iRetVal FLASH_BLOCK_FAILED_ERASE; Step Return Read Array mode FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register FlashWrite( CMD_ADDR, 0x000000FFL Step Return error condition return iRetVal; Function: FlashOverlayBlockProgram( unsigned long ulOff, size_t NumWords, void *Array Arguments: ulOff double-word offset into flash programmed NumWords holds number double-words array. Array pointer array programmed. Return Value: success function returns FLASH_SUCCESS (-1). invalid then function returns FLASH_VPP_INVALID (-13) failure function returns FLASH_PROGRAM_FAIL (-6). address range programmed exceeds address range Flash Read Array Command
20/27
AN1204 APPLICATION NOTE
Device function returns FLASH_ADDRESS_OUT_OF_RANGE (-7) nothing programmed. wrong type flash detected then FLASH_WRONG_TYPE (-8) returned nothing programmed. Description: This function used program array into flash. does erase flash first will fail block(s) erased first. Pseudo Code: Step Check correct flash type Step Check offset range valid Step Enable overlay block Step While there more programmed Step Check changes from Step Program next double-word Step Wait until Program/Erase Controller ready Step Check errors Step Verify program operation Step 10:Update pointers Step 11:Disable overlay block Step 12:Clear status register return read array mode Step 13:Return error condition FlashOverlayBlockProgram( unsigned long ulOff, size_t NumWords, void *Array unsigned long *ulArrayPointer; unsigned access array unsigned long ulLastOff; Holds last offset programmed unsigned long ulStatus; Holds Status Register reads iRetVal FLASH_SUCCESS; Return Value: Initially optimistic Step Check that flash correct type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Check offset range valid ulLastOff ulOff NumWords ulLastOff OVERLAY_SIZE return FLASH_OFFSET_OUT_OF_RANGE; Step Enable Overlay Block ((FlashOverlayBlockEnable()) FLASH_OVERLAY_FAIL) return FLASH_OVERLAY_FAIL; Step While there more programmed ulArrayPointer (unsigned long *)Array; while( ulOff ulLastOff iRetVal FLASH_SUCCESS Step Check changes from ~FlashRead( ulOff *ulArrayPointer FlashOverlayBlockDisable(); return FLASH_PROGRAM_FAIL; Step Program next double-word FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register FlashWrite( CMD_ADDR, 0x00000004L Program Set-up FlashWrite( ulOff, *ulArrayPointer Program value
21/27
AN1204 APPLICATION NOTE
Step Wait until Program/Erase Controller ready TimeOut! ulStatus FlashRead(CMD_ADDR); while( (ulStatus&0x00000080L) 0x00000000L Step Check errors ulStatus&0x00000008L iRetVal FLASH_VPP_INVALID; else ulStatus&0x00000010L iRetVal FLASH_PROGRAM_FAIL; FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command Step Verify program operation FlashRead( ulOff *ulArrayPointer iRetVal=FLASH_PROGRAM_FAIL; break; Step Update pointers ulOff++; next double-word offset ulArrayPointer++; next double-word array Step Disable Overlay Block ((FlashOverlayBlockDisable()) FLASH_OVERLAY_FAIL) iRetVal FLASH_OVERLAY_FAIL; Step Clear status register return read array mode FlashWrite( CMD_ADDR, 0x00000050L Clear Status Register FlashWrite( CMD_ADDR, 0x000000FFL Read Array Command Step return error condition return iRetVal; Function: char *FlashErrorStr( iErrNum Arguments: iErrNum error number returned from another Flash Routine Return Value: pointer string with error message Description: This function used generate text string describing error from flash. Call with return value from another flash routine. Pseudo Code: Step Check error message range. Step Return correct string. char *FlashErrorStr( iErrNum static char *str[] "Flash Success", "Flash Poll Failure", "Flash Many Blocks", "MPU slow erase blocks", "Flash Block selected invalid", "Flash Program Failure", "Flash Address Offset Range",
22/27
AN1204 APPLICATION NOTE
"Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash "Flash Wrong Type", Block Failed Erase", Unprotected", Protected", function supported", Invalid", Erase Fail", Toggle Flow Chart Failure", Unprotect failed", Bank Invalid", Protect Failed", Overlay Command Failed", Overlay Disabled already", Overlay Enabled already"
Step Check error message range iErrNum -iErrNum errors negative: make adjust iErrNum iErrNum sizeof(str)/sizeof(str[0])) Check range return "Unknown Error\n"; Step Return correct string else return str[iErrNum]; List Errors Return values, Explanations Help. Return Name: FLASH_SUCCESS Return Value: Description: This value indicates that flash command executed correctly. Error Name: FLASH_POLL_FAIL Notes: Applies series FLASH only. This error condition should occur when using this library. Return Value: Description: Program/Erase Controller algorithm managed complete command operation successfully. This because device damaged Solution: command again. fails second time then likely that device will need replaced. Error Name: FLASH_TOO_MANY_BLOCKS Notes: Applies series FLASH only. This error condition should occur when using this library. Return Value: Description: user chosen erase more blocks than device has. This because array blocks erase contains same block more than once. Solutions: Check that program trying erase valid blocks. device will only have NUM_BLOCKS blocks (defined file). Also check that same block been added twice more array.
23/27
AN1204 APPLICATION NOTE
Error Name: FLASH_MPU_TOO_SLOW Notes: Applies series FLASH only. This error condition should occur when using this library. Return Value: Description: managed write selected blocks device before timeout period expired. BLOCK ERASE COMMAND section Data Sheet details. Solutions: this occurs occasionally then because interrupt occuring between writing blocks erased. Search "DSI!" code disable interrupts during time critical sections. this error condition always occurs then time faster microprocessor, better optimising compiler worse still, learn assembly. immediate solution only erase block time. Disable test #define'ing code) always call function with block time. Error Name: FLASH_BLOCK_INVALID Return Value: Description: request invalid block been made. Valid blocks number from NUM_BLOCKS-1. Solution: Check that block valid range. Error Name: FLASH_PROGRAM_FAIL Return Value: Description: programmed value been programmed correctly. Solutions: Make sure that block containing value erased before programming. erasing block re-programming value. fails again then device have blocks protected. also possible block locked unlikely kept high. program fail still results likely that flash suspect. Error Name: FLASH_OFFSET_OUT_OF_RANGE Return Value: Description: address offset given range device. Solution: Check address offset valid range. Error Name: FLASH_WRONG_TYPE Return Value: Description: source code been used access wrong type flash. Solutions: different flash chip with target hardware contact STMicroelectronics different source code library. Error Name: FLASH_BLOCK_FAILED_ERASE Return Value: Description: previous erase this block managed successfully erase block. Solution: block protected/locked flash suspect. Return Name: FLASH_UNPROTECTED Return Value: Description: user requested unprotect block that already unprotected. This just warning user that their operation make changes necessary.
24/27
AN1204 APPLICATION NOTE
Error Name: FLASH_PROTECTED Return Value: Description: user attempted erase, program protect block flash that protected. operation failed because block protected. Solutions: Choose another (unprotected) block erasing programming. Alternatively change block protection status current block. (see Datasheet more details). case user protecting block that already protected, this warning notifies user that command effect. Return Name: FLASH_FUNCTION_NOT_SUPPORTED Return Value: Description: user attempted make functionality available this flash device (and thus provided software drivers). This simply warning user. Error Name: FLASH_VPP_INVALID Notes: Applies series Flash only. Return Value: Description: Program Block Erase been attempted with supply voltage outside allowed ranges. This command effect since invalid effect protecting whole flash device. Solution: (hardware) configuration will need modified make programming erasing device possible. Error Name: FLASH_ERASE_FAIL Return Value: Description: This indicates that previous erasure whole device failed. Solution: Investigate this failure further attempting erase each block individually. erasing single block still causes failure, then Flash sadly needs replacing. Error Name: Flash_TOGGLE_FAIL Return Value: Notes: Applies series Flash only. This error condition should occur when using this library. Description: Program/Erase Controller algorithm managed complete command operation successfully. This because device damaged. Solution: command again. fails second time then likely that device will need replaced. Error Name: Flash_UNPROTECT_FAIL Return Value: Description: This error return value indicates that block unprotect command unsuccessful. Solution: command again. fails second time then likely that device either locked will need replaced. (Part unlocked protected power-up with V_high).
25/27
AN1204 APPLICATION NOTE
Error Name: Flash_BANK_INVALID Return Value: Notes: This applies M59DRxxx series Flash only. Description: This error return value indicates that bank does exist. Error Name: Flash_PROTECT_FAIL Return Value: Description: This error return value indicates that block protect command unsuccessful. Solution: command again. fails second time then likely that device either locked will need replaced. (Part unlocked protected power-up with V_high). Error Name: Flash_OVERLAY_FAIL Return Value: Description: This error indicates that Overlay Block associated function failed. Error Name: Flash_OVERLAY_DISABLED Return Value: Description: This error informs user that OverlayBlockDisable command neccesary because Overlay Block already disabled. Error Name: Flash_OVERLAY_ENABLED Return Value: Description: This error informs user that OverlayBlockEnable command neccesary because Overlay Block already enabled.
26/27
AN1204 APPLICATION NOTE
have questions suggestion concerning matters raised this document please send them following electronic mail address:
ask.memory@st.com
(for general enquiries)
Please remember include your name, company, location, telephone number number.
Information furnished believed accurate reliable. However, STMicroelectronics assumes responsibility consequences such information infringement patents other rights third parties which result from use. license granted implication otherwise under patent patent rights STMicroelectronics. Specifications mentioned this publication subject change without notice. This publication supersedes replaces information previously supplied. STMicroelectronics products authorized critical components life support devices systems without express written approval STMicroelectronics. logo registered trademark STMicroelectronics other names property their respective owners 2000 STMicroelectronics Rights Reserved STMicroelectronics GROUP COMPANIES Australia Brazil China Finland France Germany Hong Kong India Italy Japan Malaysia Malta Morocco Singapore Spain Sweden Switzerland United Kingdom U.S.A. www.st.com
27/27

Other recent searches


QTS030100-001 - QTS030100-001   QTS030100-001 Datasheet
TLC32047C - TLC32047C   TLC32047C Datasheet
TLC32047I - TLC32047I   TLC32047I Datasheet
SXO-2200V - SXO-2200V   SXO-2200V Datasheet
SN74CB3Q3125 - SN74CB3Q3125   SN74CB3Q3125 Datasheet
QBH-816 - QBH-816   QBH-816 Datasheet
QBH-9-816 - QBH-9-816   QBH-9-816 Datasheet
PIC16F877 - PIC16F877   PIC16F877 Datasheet
CFAH1601L-TMI-ET - CFAH1601L-TMI-ET   CFAH1601L-TMI-ET Datasheet
BUF660 - BUF660   BUF660 Datasheet
BG16032A - BG16032A   BG16032A Datasheet
ST7920 - ST7920   ST7920 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive