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 M59DR0


Datasheet Thumbnail

  

Download PDF



Top Searches for this datasheet



Software Drivers M59DR008 M59DR032 Flash Memories
INTRODUCTION This application note provides library source code M59DR008 M59DR032 Flash Memories. Four parts covered, M59DR008E, M59DR008F, M59DR032A M59DR032B; they will referred generically M59DRxxx. Listings source code found this document. source code also available file form from internet site http://www.st.com from your STMicroelectronics distributor. c1201_16.c c1201_16.h files contain libraries accessing M59DRxxx Flash Memory. Also included this application note overview programming model M59DRxxx. 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 M59DR008 M59DR032 datasheet. refers datasheet throughout necessary have copy order follow some explanations. software accompanying documentation been fully tested target platform. small size applied target hardware. M59DRxxx PROGRAMMING MODEL M59DR008 Mbit (512Kb x16) Flash Memory; M59DR032 Mbit (2Mb 16). They electrically erased programmed through special coded command sequences most standard microprocessor buses. device broken down into different blocks varying sizes. Main Blocks 32Kb size, whereas Parameter Blocks size. Each block erased individually. blocks grouped into banks; each bank independant from other that programmed while other being read. blocks bank erased same time using command.
INTRODUCTION M59DRxxx PROGRAMMING MODEL WRITING CODE M59DRxxx LIBRARY FUNCTIONS PROVIDED PORTING DRIVERS TARGET SYSTEM LIMITATIONS SOFTWARE CONCLUSION c1201_16.h LISTING c1201_16.c LISTING
March 2001
1/33
AN1201 APPLICATION NOTE
M59DRxxx smart voltage device. differs from first generation devices which require supply program erase. M59DRxxx therefore easier since hardware does need cater special signal levels. voltages needed erase device generated charge pumps inside device. M59DRxxx optionally supplied with 12V; this allows double-word program command used halves programming time device. Included device Program/Erase Controller. With first generation Flash Memory devices software manually program words before erasing using special programming sequences. Program/Erase Controller M59DRxxx allows simpler programming model used, taking care necessary steps required erase program memory. This improved reliability that excess 100,000 program/erase cycles guaranteed block device. Operations Commands Most functionality M59DRxxx available standard operations: read write. Read operations retrieve data status information from device. Write operations interpreted device commands, which modify data stored behaviour device. Only certain special sequences write operations recognized commands M59DRxxx. various commands recognized M59DRxxx listed Commands Table datasheet grouped follows: Read/Reset Auto Select Erase Program Erase Suspend Read/Reset command returns M59DRxxx reset state where behaves ROM. this state, read operation outputs onto data data stored specified address device. Auto Select command places device Auto Select mode, which allows user read Electronic Signature Block Protection Status device. Electronic Signature (Manufacturer Device Codes) Block Protection Status accessed reading different addresses whilst Auto Select mode. Erase commands used bits every memory location selected blocks (Block Erase command) bank (Bank Erase command). data previously stored erased blocks will lost. Erase commands take longer execute than other commands, because entire blocks erased time. Program command used modify data stored specified address device. Note that programming cannot change bits from '1'. 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, Each Program command requires write operations issue. M59DRxxx supports double word programming when 12V. Using this feature words programmed same time, halving programming time. Flash Programmers with long cycles Unlock Bypass command improve programming times. After issuing Unlock Bypass command, Program commands only require write operations DoubleWord Program commands only require write operations. Using Unlock Bypass will thus save some time when large number addresses need programmed time.
2/33
AN1201 APPLICATION NOTE
Issuing Erase Suspend command during Block Erase operation will temporarily place M59DRxxx Erase Suspend mode. this mode blocks being erased read programmed reset state device. This allows user access information stored device immediately rather than waiting until Block Erase operation completes, typically M59DRxxx. Block Erase operation resumed when device receives Erase Resume command. Status Register While M59DRxxx programming erasing, read from device will output Status Register Program/Erase Controller. This provides valuable information about current Program Erase command. Status Register bits described Status Register Bits Table M59DRxxx datasheet. Their main determine when programming erasing complete whether successful not. Completion Program Erase operation determined either from polling (Status Register DQ7) from toggle (Status Register DQ6), following Data Polling Flow Chart Figure Data Toggle Flow Chart Figure datasheet. library routines described this application note Data Toggle Flow Chart. However, function based Data Polling Flow Chart also provided illustration. Programming erasing errors indicated error (Status Register DQ5) becoming before command completed. failure occurs, command will complete read operations will continue output Status Register bits until Read/Reset command issued device. Detailed Example Commands Table M59DRxxx datasheet describes sequences write operations that will recognized Program/Erase Controller valid commands. example programming address 03E2h requires user write following sequence *(unsigned *(unsigned *(unsigned *(unsigned int*)(0x0555) int*)(0x02AA) int*)(0x0555) int*)(0x03E2) 0x00AA; 0x0055; 0x00A0; 0x9465;
This example assumes that address 0000h M59DRxxx 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 error occurred. will toggle while programming on-going. will complement data being programmed. There only possible outcomes this programming command: success failure. Success will indicated toggle longer toggling being constant programmed value example) polling also being programmed value example). Failure will indicated error becoming while toggle still toggles polling remains complement ('1' example) data being programmed. Note that failure device itself extremely unlikely. command fails will normally because user attempting change programming. only possible change erasing. WRITING CODE M59DRXXX low-level functions (drivers) described this application note have been provided simplify process developing application code STMicroelectronics Flash Memories (M59DRxxx). This enables users concentrate writing high level functions required their particular applications. 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.
3/33
AN1201 APPLICATION NOTE
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 M59DRxxx. 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 M59DRxxx 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 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 Block Protection Status device. FlashBlockErase() used erase more blocks device. Multiple blocks will erased simultaneously reduce overall erase time. multiple blocks erased, function checks which bank first block erase member that none blocks specified outside that bank. also checks protected blocks hence does erase blocks they protected across banks. FlashBankErase() used erase bank device time. Before erasing bank, this function checks that none blocks within that bank protected. FlashBlockUnprotect() used unprotect block device. checks that block unprotect valid un-protects block. block then tested ensure that command successful. this function called block already un-protected user warned that function effect. FlashBlockProtect() used protect block device. checks that block protect valid protects block. block then tested ensure that command successful. this function called block already protected user warned that function effect. FlashBlockLock() used lock block device. Once block locked protection status cannot changed until Hardware Reset Power-up.
4/33
AN1201 APPLICATION NOTE
FlashProgram() used program data arrays into Flash. Only previously erased words programmed reliably. function will program data words array fall inside protected block. functions provided software library rely user implementing hardware specific operations well suitable timing function. This done writing three functions follows: FlashRead() must written read value from Flash. FlashWrite() must written write value Flash. FlashPause() must written provide timer with microsecond resolution. This used wait while Flash recovers from some conditions. 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.D7 device D8.D15 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. 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 FlashRead( unsigned *Addr); unsigned 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 following: Define USE_M59DR008E, USE_M59DR008F, USE_M59DR032A USE_M59DR032B depending which part fitted fitted. source file provided defines USE_M59DR008E example. Write FlashRead(), FlashWrite() FlashPause() functions appropriate Target Hardware. Search through code comments disable/enable interrupts appropriate points. 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 M59DRxxx. erased then only data should read. Next read Manufacturer Device codes check they
5/33
AN1201 APPLICATION NOTE
correct. these functions work then likely that functions will work they should tested thoroughly. programmer needs take extra care when device accessed during interrupt service routine. Three situations exist which must considered: When device Read mode interrupts freely read from device. Interrupts which access device used during Program, Autoselect Chip Erase functions. During time critical section Block Erase function interrupts permitted. interrupt during this time cause time-out result some blocks being erased correctly. programmer should also take care when Reset applied during Program Erase operations. Flash will left indeterminate state data could lost. does provide standard library function disabling interrupts. Furthermore different applications have different tolerances when interrupts disabled. Therefore protection from misuse interrupts could incorporated into library source code. strongly recommended that user disables interrupts where comments placed source code. this possible then user should erase block time. LIMITATIONS SOFTWARE software provided does implement full M59DRxxx's functionality. left user implement Erase Suspend Unlock Bypass commands device. Standby mode hardware feature device cannot controlled through software. 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 M59DRxxx single voltage Flash Memories ideal products embedded other computer systems, able easily interfaced microprocessors driven with simple software drivers written language. REVISION HISTORY
Date March 2001 Version First Issue Revision Details
6/33
AN1201 APPLICATION NOTE
/**** c1201_16.h Header File c1201_16.c Filename: c1201_16.h Description: Header file c1201_16.c. 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 with FlashBankErase(command) #define BANK_A #define BANK_B with FlashAutoSelect(command) #define FLASH_READ_MANUFACTURER (-2) #define FLASH_READ_DEVICE_CODE (-1) Error Conditions return values. file explanations help #define FLASH_BLOCK_PROTECTED (0x01) #define FLASH_BLOCK_UNPROTECTED (0x00) #define FLASH_BLOCK_LOCKED (0x02) mask #define FLASH_BLOCK_NOT_ERASED (0xFF) #define FLASH_BLOCK_ERASE_FAILURE (0xFE) #define FLASH_BLOCK_ERASED (0xFD) #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define #define FLASH_SUCCESS FLASH_POLL_FAIL FLASH_TOO_MANY_BLOCKS FLASH_MPU_TOO_SLOW FLASH_BLOCK_INVALID FLASH_PROGRAM_FAIL FLASH_OFFSET_OUT_OF_RANGE FLASH_WRONG_TYPE FLASH_BLOCK_FAILED_ERASE FLASH_UNPROTECTED FLASH_PROTECTED FLASH_ERASE_FAIL FLASH_TOGGLE_FAIL FLASH_UNPROTECT_FAIL FLASH_BANK_INVALID FLASH_PROTECT_FAIL FLASH_LOCK_FAIL FLASH_LOCKED (-1) (-2) (-3) (-4) (-5) (-6) (-7) (-8) (-9) (-10) (-11) (-14) (-15) (-16) (-17) (-18) (-19) (-20)
7/33
AN1201 APPLICATION NOTE
Prototypes extern extern extern extern extern extern extern extern extern extern unsigned FlashRead( unsigned long ulOff void FlashReadReset( void FlashAutoSelect( iFunc FlashBlockErase( unsigned char ucNumBlocks, unsigned char ucBlock[]); FlashBankErase( unsigned char Bank FlashBlockUnprotect( unsigned char ucBlock FlashBlockProtect( unsigned char ucBlock FlashBlockLock( unsigned char ucBlock FlashProgram( unsigned long ulOff, size_t NumWords, void *Array char *FlashErrorStr( iErrNum
8/33
AN1201 APPLICATION NOTE
/**** c1201_16.c Filename: c1201_16.c Description: Library routines M59DR008 M59DR032 Flash parts Revision: Date: Author: 1.01 05/02/2001 Watts, 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 Date Comments
20/09/2000 Fully tested using M59DR008E/F target platform. 05/02/2001 Added Flash Block Lock retested.
This source file provides library code using M59DR008 M59DR032 devices. following devices supported code: M59DR008E M59DR008F M59DR032A M59DR032B following functions available this library: FlashReadReset() FlashAutoSelect() FlashBlockErase() FlashBankErase() FlashBlockUnprotect() FlashBlockProtect() FlashProgram() FlashErrorStr() reset flash normal memory access information about device erase more blocks erase whole bank unprotect block protect block program word array 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 word flash FlashRead() reading word from flash FlashPause() timing short pauses micro seconds) list error conditions given code.
9/33
AN1201 APPLICATION NOTE
There timeouts implemented loops code. each point where infinite loop implemented comment TimeOut! been placed. user implement these avoid code hanging instead timing out. Since does include method disabling interrupts keep timecritical sections code from being disabled. user wish disable interrupt during parts code avoid FLASH_MPU_TOO_SLOW error from occuring interrupt occurs wrong time. Where interrupt should disabled re-enabled there DSI! ENI! comment. 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 "c1201_16.h" #define USE_M59DR008E Constants #define COUNTS_PER_MICROSECOND (200) #define MANUFACTURER_ST (0x0020) Manufacturer code #define BASE_ADDR ((volatile unsigned int*)0x0000) BASE_ADDR base address flash, functions FlashRead() FlashWrite(). Some applications which require more complicated FlashRead() FlashWrite() BASE_ADDR #define ANY_ADDR (0x0000L) address offset within Flash Memory will #ifdef USE_M59DR008E #define EXPECTED_DEVICE (0x00A2) Device code M59DR008E #define FLASH_SIZE (0x80000L) 512K #endif #ifdef USE_M59DR008F #define EXPECTED_DEVICE (0x00A3) Device code M59DR008F #define FLASH_SIZE (0x80000L) 512K #endif #ifdef USE_M59DR032A #define EXPECTED_DEVICE (0x00A0) Device code M59DR032A #define FLASH_SIZE (0x200000L) 2048K #endif #ifdef USE_M59DR032B #define EXPECTED_DEVICE (0x00A1) Device code M59DR032B #define FLASH_SIZE (0x200000L) 2048K #endif #ifdef USE_M59DR008E Header file with global prototypes
10/33
AN1201 APPLICATION NOTE
Block organisation Boot Block device static const unsigned long BlockOffset[] 0x00000L, Start offset block 0x08000L, Start offset block 0x10000L, Start offset block 0x18000L, Start offset block 0x20000L, Start offset block 0x28000L, Start offset block 0x30000L, Start offset block 0x38000L, Start offset block 0x40000L, Start offset block 0x48000L, Start offset block 0x50000L, Start offset block 0x58000L, Start offset block 0x60000L, Start offset block 0x68000L, Start offset block 0x70000L, Start offset block 0x78000L, Start offset block 0x79000L, Start offset block 0x7A000L, Start offset block 0x7B000L, Start offset block 0x7C000L, Start offset block 0x7D000L, Start offset block 0x7E000L, Start offset block 0x7F000L Start offset block Bank organisation Boot Block device static const char BankFirstBlock[] First Block BANK First Block BANK static const char BankLastBlock[] Last Block BANK Last Block BANK #endif USE_M59DR008E #ifdef USE_M59DR008F Block organisation Bottom Boot Block device static const unsigned long BlockOffset[] 0x00000L, Start offset block 0x01000L, Start offset block 0x02000L, Start offset block 0x03000L, Start offset block 0x04000L, Start offset block 0x05000L, Start offset block 0x06000L, Start offset block 0x07000L, Start offset block 0x08000L, Start offset block 0x10000L, Start offset block 0x18000L, Start offset block 0x20000L, Start offset block
11/33
AN1201 APPLICATION NOTE
0x28000L, 0x30000L, 0x38000L, 0x40000L, 0x48000L, 0x50000L, 0x58000L, 0x60000L, 0x68000L, 0x70000L, 0x78000L Bank organisation Bottom Boot Block device static const char BankFirstBlock[] First Block BANK First Block BANK static const char BankLastBlock[] Last Block BANK Last Block BANK #endif USE_M59DR008F #ifdef USE_M59DR032A Block organisation Boot Block device static const unsigned long BlockOffset[] 0x000000L, Start offset block 0x008000L, Start offset block 0x010000L, Start offset block 0x018000L, Start offset block 0x020000L, Start offset block 0x028000L, Start offset block 0x030000L, Start offset block 0x038000L, Start offset block 0x040000L, Start offset block 0x048000L, Start offset block 0x050000L, Start offset block 0x058000L, Start offset block 0x060000L, Start offset block 0x068000L, Start offset block 0x070000L, Start offset block 0x078000L, Start offset block 0x080000L, Start offset block 0x088000L, Start offset block 0x090000L, Start offset block 0x098000L, Start offset block 0x0A0000L, Start offset block 0x0A8000L, Start offset block 0x0B0000L, Start offset block 0x0B8000L, Start offset block 0x0C0000L, Start offset block 0x0C8000L, Start offset block 0x0D0000L, Start offset block Start Start Start Start Start Start Start Start Start Start Start offset offset offset offset offset offset offset offset offset offset offset block block block block block block block block block block block
12/33
AN1201 APPLICATION NOTE
0x0D8000L, 0x0E0000L, 0x0E8000L, 0x0F0000L, 0x0F8000L, 0x100000L, 0x108000L, 0x110000L, 0x118000L, 0x120000L, 0x128000L, 0x130000L, 0x138000L, 0x140000L, 0x148000L, 0x150000L, 0x158000L, 0x160000L, 0x168000L, 0x170000L, 0x178000L, 0x180000L, 0x188000L, 0x190000L, 0x198000L, 0x1A0000L, 0x1A8000L, 0x1B0000L, 0x1B8000L, 0x1C0000L, 0x1C8000L, 0x1D0000L, 0x1D8000L, 0x1E0000L, 0x1E8000L, 0x1F0000L, 0x1F8000L, 0x1F9000L, 0x1FA000L, 0x1FB000L, 0x1FC000L, 0x1FD000L, 0x1FE000L, 0x1FF000L Bank organisation Boot Block device static const char BankFirstBlock[] First Block BANK First Block BANK static const char BankLastBlock[] Last Block BANK Last Block BANK Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start Start 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 offset offset offset offset offset offset offset offset offset offset offset offset 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 block block block block block block block block block block block block block block block block block block block block block block block block block block block block
13/33
AN1201 APPLICATION NOTE
#endif USE_M59DR032A #ifdef USE_M59DR032B Block organisation Bottom Boot Block device static const unsigned long BlockOffset[] 0x000000L, Start offset block 0x001000L, Start offset block 0x002000L, Start offset block 0x003000L, Start offset block 0x004000L, Start offset block 0x005000L, Start offset block 0x006000L, Start offset block 0x007000L, Start offset block 0x008000L, Start offset block 0x010000L, Start offset block 0x018000L, Start offset block 0x020000L, Start offset block 0x028000L, Start offset block 0x030000L, Start offset block 0x038000L, Start offset block 0x040000L, Start offset block 0x048000L, Start offset block 0x050000L, Start offset block 0x058000L, Start offset block 0x060000L, Start offset block 0x068000L, Start offset block 0x070000L, Start offset block 0x078000L, Start offset block 0x080000L, Start offset block 0x088000L, Start offset block 0x090000L, Start offset block 0x098000L, Start offset block 0x0A0000L, Start offset block 0x0A8000L, Start offset block 0x0B0000L Start offset block 0x0B8000L, Start offset block 0x0C0000L, Start offset block 0x0C8000L, Start offset block 0x0D0000L, Start offset block 0x0D8000L, Start offset block 0x0E0000L, Start offset block 0x0E8000L, Start offset block 0x0F0000L, Start offset block 0x0F8000L, Start offset block 0x100000L, Start offset block 0x108000L, Start offset block 0x110000L, Start offset block 0x118000L, Start offset block 0x120000L, Start offset block 0x128000L, Start offset block 0x130000L, Start offset block 0x138000L, Start offset block 0x140000L, Start offset block 0x148000L, Start offset block 0x150000L, Start offset block 0x158000L, Start offset block 0x160000L, Start offset block
14/33
AN1201 APPLICATION NOTE
0x168000L, 0x170000L, 0x178000L, 0x180000L, 0x188000L, 0x190000L, 0x198000L, 0x1A0000L, 0x1A8000L, 0x1B0000L, 0x1B8000L, 0x1C0000L, 0x1C8000L, 0x1D0000L, 0x1D8000L, 0x1E0000L, 0x1E8000L, 0x1F0000L, 0x1F8000L Bank organisation Bottom Boot Block device static const char BankFirstBlock[] First Block BANK First Block BANK static const char BankLastBlock[] Last Block BANK Last Block BANK #endif USE_M59DR032B #define NUM_BLOCKS #define NUM_BANKS Static Prototypes following functions only needed this module. static unsigned FlashWrite( unsigned long ulOff, unsigned uVal static void FlashPause( unsigned uMicroSeconds static FlashDataToggle( unsigned long ulOff function FlashDataPoll() declared below used this library provided illustration Data Polling Flow Chart #define ILLUSTRATION_ONLY #ifndef ILLUSTRATION_ONLY static FlashDataPoll( unsigned long ulOff, unsigned uVal #endif !ILLUSTRATION_ONLY Start Start Start 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 offset offset offset block block block block block block block block block block block block block block block block block block block
15/33
AN1201 APPLICATION NOTE
Function: unsigned FlashWrite( Arguments: ulOff word offset uVal value written Returns: uVal Description: This function used microprocessor systems macro flash routines. example: unsigned long ulOff, unsigned uVal) flash write write word flash. many used instead, increasing speed
#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 word offset flash Step return uVal static unsigned FlashWrite( unsigned long ulOff, unsigned uVal Step1, Write uVal word offset flash return return BASE_ADDR[ulOff] uVal; Function: unsigned FlashRead( unsigned long ulOff Arguments: ulOff word offset into flash read from Returns: unsigned word offset Description: This function used read word from flash. many microprocessor systems macro used instead, increasing speed flash routines. example: #define FlashRead( ulOff BASE_ADDR[ulOff] function used here instead allow user expand necessary. Pseudo Code: Step Return value word offset ulOff unsigned FlashRead( unsigned long ulOff Step Return value word offset ulOff return BASE_ADDR[ulOff]; Function: void FlashPause( unsigned uMicroSeconds Arguments: uMicroSeconds length pause microseconds Returns: none Description: This routine returns after uMicroSeconds have elapsed. used several parts code generate pause required correct operation flash part. routine here works counting. user already have more suitable routine timing which used. Pseudo Code: Step Compute count size pause. Step Count required size.
16/33
AN1201 APPLICATION NOTE
static void FlashPause( unsigned uMicroSeconds volatile unsigned long ulCountSize; Step Compute count size ulCountSize (unsigned long)uMicroSeconds COUNTS_PER_MICROSECOND; Step Count required size while( ulCountSize Test finished ulCountSize-; count down Function: void FlashReadReset( void Arguments: none Return Value: none Description: This function places flash Read mode described Data Sheet. this mode flash read normal memory. other functions leave flash Read mode this strictly necessary. provided completeness. Note: wait 10us required command called during program erase instruction. This included here guarantee correct operation. functions this library call this function they suspect error during programming erasing that 10us pause included. Otherwise they single instruction technique increased speed. Pseudo Code: Step write command sequence (see Commands Table Data Sheet) Step wait 10us void FlashReadReset( void Step write command sequence FlashWrite( 0x0555L, 0x00AA Cycle FlashWrite( 0x02AAL, 0x0055 Cycle FlashWrite( 0x0555L, 0x00F0 Cycle Step wait 10us FlashPause( Function: FlashAutoSelect( iFunc Arguments: iFunc should either Read Signature values block number. header file defines values reading Signature. Note: first block Block Return Value: When iFunc function returns FLASH_BLOCK_PROTECTED (01h) block protected FLASH_BLOCK_UNPROTECTED (00h) unprotected. Auto Select command Data Sheet further information. When iFunc FLASH_READ_MANUFACTURER (-2) function returns manufacturer's code. Manufacturer code 0020h. When iFunc FLASH_READ_DEVICE_CODE (-1) function returns Device Code. device codes parts are: M59DR008E 00A2h
17/33
AN1201 APPLICATION NOTE
M59DR008F M59DR032A M59DR032B 00A3h 00A0h 00A1h
When iFunc invalid function returns FLASH_BLOCK_INVALID (-5) Description: This function used read electronic signature device, manufacturer code protection level block. Pseudo Code: Step Send Auto Select command device Step Read required function from device. Step Return device Read mode. FlashAutoSelect( iFunc iRetVal; Holds return value Step Send Auto Select FlashWrite( 0x0555L, 0x00AA FlashWrite( 0x02AAL, 0x0055 FlashWrite( 0x0555L, 0x0090 command Cycle Cycle Cycle
Step Read required function iFunc FLASH_READ_MANUFACTURER iRetVal (int) FlashRead( 0x0000L else iFunc FLASH_READ_DEVICE_CODE iRetVal (int) FlashRead( 0x0001L else (iFunc (iFunc NUM_BLOCKS) iRetVal FlashRead( BlockOffset[iFunc] 0x0002L else iRetVal FLASH_BLOCK_INVALID; Step Return Read mode FlashWrite(ANY_ADDR,0x00F0); return iRetVal; Function: FlashBlockErase( unsigned char ucNumBlocks, unsigned char ucBlock[] Arguments: ucNumBlocks holds number blocks array ucBlock ucBlock array containing blocks erased. Return Value: function returns following conditions: FLASH_SUCCESS (-1) FLASH_TOO_MANY_BLOCKS (-3) FLASH_MPU_TOO_SLOW (-4) FLASH_WRONG_TYPE (-8) FLASH_ERASE_FAIL (-14) Number first block found which protected, invalid, outside particular bank. user's array, ucBlock[] used report errors specified blocks. time-out occurs because slow then blocks ucBlocks which erased overwritten with FLASH_BLOCK_NOT_ERASED (FFh) function returns FLASH_MPU_TOO_SLOW.
18/33
AN1201 APPLICATION NOTE
error occurs during erasing blocks function returns FLASH_ERASE_FAIL. both errors occur then function will ucBlock array FLASH_BLOCK_NOT_ERASED unerased blocks. will return FLASH_ERASE_FAIL even though FLASH_MPU_TOO_SLOW also occurred. Description: This function erases ucNumBlocks flash. blocks listed order long they within same bank. function does return until blocks erased. blocks protected,invalid different banks none blocks will erased. During Erase Cycle Data Toggle Flow Chart Data Sheet followed. polling bit, DQ7, used. Pseudo Code: Step Check correct flash type. Step Check protected invalid blocks. Step Discover which bank first block erase then ensure that other blocks listed array also within that bank. Step Write Block Erase command. Step Check time-out blocks. Step Wait timer set. Step Follow Data Toggle Flow Chart until Program/Erase Controller completed. Step Return Read mode error occurred). FlashBlockErase( unsigned char ucNumBlocks, unsigned char ucBlock[] unsigned char ucCurBlock; Range Variable track current block unsigned char ucCurBank;/* Range Variable track current bank iRetVal FLASH_SUCCESS; Holds return value: optimistic initially! unsigned uFirstRead, uSecondRead; used check toggle Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Check protected invalid blocks. ucNumBlocks NUM_BLOCKS Check specified blocks NUM_BLOCKS return FLASH_TOO_MANY_BLOCKS; for( ucCurBlock ucCurBlock ucNumBlocks; ucCurBlock++ FlashAutoSelect find protected invalid blocks FLASH_BLOCK_UNPROTECTED return (int)ucBlock[ucCurBlock]; Return protected/invalid blocks Step Find which bank first block array member for( ucCurBank ucCurBank NUM_BANKS; ucCurBank++ (ucBlock[0] BankFirstBlock[ucCurBank]) (ucBlock[0] BankLastBlock[ucCurBank]) break; ucCurBank current bank block Check that other blocks within bank ucCurBank for( ucCurBlock ucCurBlock ucNumBlocks; ucCurBlock++ (ucBlock[ucCurBlock] BankFirstBlock[ucCurBank]) (ucBlock[ucCurBlock] BankLastBlock[ucCurBank])
19/33
AN1201 APPLICATION NOTE
return ucBlock[ucCurBlock]; Return invalid blocks that across banks Step Write Block Erase command FlashWrite( 0x0555L, 0x00AA FlashWrite( 0x02AAL, 0x0055 FlashWrite( 0x0555L, 0x0080 FlashWrite( 0x0555L, 0x00AA FlashWrite( 0x02AAL, 0x0055 DSI!: Time critical section. Additional blocks must added every 100us*/ for( ucCurBlock ucCurBlock ucNumBlocks; ucCurBlock++ FlashWrite( 0x0030 Check Erase Timeout Period set?) (FlashRead( BlockOffset[ucBlock[0]] 0x0008) 0x0008 break; Cannot more blocks timeout ENI! Step Check time-out blocks timeout occurred then check current block erasing status register, toggle implies block erasing ucCurBlock ucNumBlocks uFirstRead FlashRead( 0x0004; uSecondRead FlashRead( 0x0004; uFirstRead uSecondRead ucCurBlock++; Point next block ucCurBlock ucNumBlocks Indicate that some blocks have been timed erase list iRetVal FLASH_MPU_TOO_SLOW; specify other blocks being erased while( ucCurBlock ucNumBlocks ucBlock[ucCurBlock++] FLASH_BLOCK_NOT_ERASED; Step Wait Erase Timer (DQ3) while( TimeOut!: some reason, hardware fails then this loop exit. timer function implement timeout from loop. FlashRead( BlockOffset[ucBlock[0]] 0x0008 0x0008 break; Break when device starts erase cycle Step Follow Data Toggle Flow Chart until Program/Erase Controller completes FlashDataToggle( BlockOffset[ucBlock[0]] FLASH_SUCCESS iRetVal FLASH_ERASE_FAIL;
20/33
AN1201 APPLICATION NOTE
Step Return Read mode error occurred) FlashReadReset(); return iRetVal; Function: FlashBankErase( unsigned char ucBank Arguments: ucBank Bank Bank Return Value: function returns following conditions: FLASH_SUCCESS (-1) FLASH_WRONG_TYPE (-8) FLASH_ERASE_FAIL (-14) FLASH_BANK_INVALID (-17) first block bank found protected will cause funtion fail returning block number that failed. Description: function used erase whole bank flash chip. Each Bank erased turn. function only returns when Bank been erased error been detected. Pseudo Code: Step Check correct flash type Step Check that bank value ucBank invalid Step Check protect blocks bank Step Write bank erase sequence Step Data Toggle check completetion Step Return Fail Data Toggle fails Step Read P/EC failed Step Return success FlashBankErase( unsigned char ucBank unsigned char ucCurBlock; Variable checking protected blocks Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; Step Check that bank value greater than NUM_BANKS ucBank NUM_BANKS return FLASH_BANK_INVALID; Step Check protected blocks that bank for( ucCurBlock BankFirstBlock[ucBank]; ucCurBlock BankLastBlock[ucBank]; ucCurBlock++ FlashAutoSelect find protected invalid blocks FlashAutoSelect( ucCurBlock FLASH_BLOCK_UNPROTECTED return (int)ucCurBlock; Return protected/invalid blocks Step Write command sequence erase bank FlashWrite( 0x0555, 0x00AA FlashWrite( 0x02AA, 0x0055 FlashWrite( 0x0555, 0x0080 FlashWrite( 0x0555, 0x00AA FlashWrite( 0x02AA, 0x0055
21/33
AN1201 APPLICATION NOTE
FlashWrite( BankFirstBlock[ucBank], 0x0010 Step Follow Data Toggle Flow Chart until Program/Erase Controller completes FlashDataToggle( BankFirstBlock[ucBank] FLASH_SUCCESS Step Return Read mode error occurred) FlashReadReset(); return FLASH_ERASE_FAIL; Step Pass return FLASH_SUCCESS; Function: FlashBlockUnprotect(unsigned char ucBlock) Arguments: ucBlock holds block number unprotect Return Value: function returns following conditons: FLASH_WRONG_TYPE (-8) FLASH_SUCCESS (-1) FLASH_UNPROTECT_FAIL (-16) FLASH_UNPROTECTED (-10) FLASH_BLOCK_INVALID (-5) Description: This function unprotects block selected ucBlock only that particular block protected valid. block unprotect command then written then checked ensure that successful. Pseudo Code: Step Check correct flash type Step Check block number ucBlock valid. Step Check block really needs unprotecting already unprotected. Step Unprotect block. Step Test Unprotection successful. Step Read reset Data Toggle Flow Chart failed. FlashBlockUnprotect(unsigned char ucBlock) iRetVal; Store result Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; iRetVal FlashAutoSelect( ucBlock Step iRetVal FLASH_BLOCK_INVALID return iRetVal; Step else iRetVal FLASH_BLOCK_UNPROTECTED return FLASH_UNPROTECTED; else Step Unprotect block FlashWrite( 0x0555, 0x00AA
22/33
AN1201 APPLICATION NOTE
FlashWrite( 0x02AA, 0x0055 FlashWrite( 0x0555, 0x0060 FlashWrite( BlockOffset[ucBlock], 0x00D0 Step test that worked FlashAutoSelect( ucBlock FLASH_BLOCK_UNPROTECTED return FLASH_SUCCESS; else Step Read reset failure FlashReadReset(); return FLASH_UNPROTECT_FAIL; Function: FlashBlockProtect(unsigned char ucBlock) Arguments: ucBlock holds block number protect Return Value: function returns following conditons: FLASH_SUCCESS (-1) FLASH_PROTECT_FAIL (-18) FLASH_PROTECTED (-11) FLASH_WRONG_TYPE (-8) FLASH_BLOCK_INVALID (-5) Description: This function protects block selected ucBlock only that particular block unprotected valid. block protect command then written checked ensure that successful. Pseudo Code: Step Check correct flash type Step Check block number ucBlock valid Step Check block really needs protecting already protected. Step Protect block. Step Test Protection successful. Step Read reset Data Toggle Flow Chart failed. FlashBlockProtect(unsigned char ucBlock) iRetVal; Store result Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; iRetVal FlashAutoSelect( ucBlock Step iRetVal FLASH_BLOCK_INVALID return iRetVal; Step else iRetVal FLASH_BLOCK_PROTECTED return FLASH_PROTECTED; else Step Protect block
23/33
AN1201 APPLICATION NOTE
FlashWrite( FlashWrite( FlashWrite( FlashWrite( 0x0555, 0x00AA 0x02AA, 0x0055 0x0555, 0x0060 BlockOffset[ucBlock], 0x0001
Step test that worked FlashAutoSelect( ucBlock FLASH_BLOCK_PROTECTED return FLASH_SUCCESS; else Step Read reset failure FlashReadReset(); return FLASH_UNPROTECT_FAIL; Function: FlashBlockLock(unsigned char ucBlock) Arguments: ucBlock holds block number lock Return Value: function returns following conditons: FLASH_SUCCESS (-1) FLASH_LOCK_FAIL (-19) FLASH_LOCKED (-20) FLASH_WRONG_TYPE (-8) FLASH_BLOCK_INVALID (-5) Description: This function locks block selected ucBlock only that particular block valid. block lock command then written checked ensure that successful. Pseudo Code: Step Check correct flash type Step Check block number ucBlock valid Step Check block really needs locking already locked. Step Lock block. Step Test Lock successful. Step Read reset Data Toggle Flow Chart failed. FlashBlockLock(unsigned char ucBlock) iRetVal; Store result Step Check correct flash type !(FlashAutoSelect( FLASH_READ_MANUFACTURER MANUFACTURER_ST) !(FlashAutoSelect( FLASH_READ_DEVICE_CODE EXPECTED_DEVICE return FLASH_WRONG_TYPE; iRetVal FlashAutoSelect( ucBlock Step iRetVal FLASH_BLOCK_INVALID return iRetVal; Step iRetVal FLASH_BLOCK_LOCKED return FLASH_LOCKED; else Step Lock block
24/33
AN1201 APPLICATION NOTE
FlashWrite( FlashWrite( FlashWrite( FlashWrite( 0x0555, 0x00AA 0x02AA, 0x0055 0x0555, 0x0060 BlockOffset[ucBlock], 0x002F
Step test that worked FlashAutoSelect( ucBlock FLASH_BLOCK_LOCKED return FLASH_SUCCESS; else Step Read reset failure FlashReadReset(); return FLASH_LOCK_FAIL; Function: FlashProgram( unsigned long ulOff, size_t NumWords, void *Array Arguments: ulOff word offset into flash programmed NumWords holds number words array. Array pointer array programmed. Return Value: function returns following conditions: FLASH_SUCCESS (-1) FLASH_PROGRAM_FAIL (-6) FLASH_OFFSET_OUT_OF_RANGE (-7) FLASH_WRONG_TYPE (-8) Number first protected invalid block success function returns FLASH_SUCCESS (-1). function returns FLASH_PROGRAM_FAIL (-6) programming failure occurs. address range programmed exceeds address range Flash Device function returns FLASH_OFFSET_OUT_OF_RANGE (-7) nothing programmed. wrong type flash detected then FLASH_WRONG_TYPE (-8) returned nothing programmed. part address range programmed falls within protected block, function returns number first protected block encountered nothing programmed. Description: This function used program array into flash. does erase flash first fail block(s) erased first. Pseudo Code: Step Check correct flash type. Step Check offset range valid. Step Check that block(s) programmed protected. Step While there more programmed. Step Check changes from `1'. Step Program next word. Step Follow data Toggle Flow Chart until Program/Erase Controller completed. Step Return Read mode error occurred). Step Update pointers. FlashProgram( unsigned long ulOff, size_t NumWords, void *Array unsigned *uArrayPointer; unsigned access array unsigned long ulLastOff; Holds last offset programmed
25/33
AN1201 APPLICATION NOTE
unsigned char ucCurBlock; Range Variable track current block
Step Check correct flash 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-1; ulLastOff FLASH_SIZE return FLASH_OFFSET_OUT_OF_RANGE; Step Check that block(s) programmed protected for( ucCurBlock ucCurBlock NUM_BLOCKS; ucCurBlock++ address range programmed ends before this block BlockOffset[ucCurBlock] ulLastOff break; then done Else address range starts beyond this block else (ucCurBlock (NUM_BLOCKS-1)) (ulOff BlockOffset[ucCurBlock+1]) continue; then skip this block Otherwise this block unprotected else FLASH_BLOCK_UNPROTECTED return (int)ucCurBlock; Return first protected block Step While there more programmed uArrayPointer (unsigned *)Array; while( ulOff ulLastOff Step Check changes from ~FlashRead( ulOff *uArrayPointer Indicate failure possible change using Program command. This must done using Erase command return FLASH_PROGRAM_FAIL; Step Program next word FlashWrite( 0x0555L, 0x00AA cycle FlashWrite( 0x02AAL, 0x0055 cycle FlashWrite( 0x0555L, 0x00A0 Program command FlashWrite( ulOff, *uArrayPointer Program value Step Follow Data Toggle Flow Chart until Program/Erase Controller completed Data Toggle Flow Chart Data Sheet FlashDataToggle( ulOff FLASH_TOGGLE_FAIL Step Return Read mode error occurred) FlashReadReset(); return FLASH_PROGRAM_FAIL; Step Update pointers ulOff++; uArrayPointer++; return FLASH_SUCCESS;
26/33
AN1201 APPLICATION NOTE
Function: static FlashDataToggle( void Arguments: ulOff should hold valid offset reading Status Register. This address offset must within bank which current erase program operation taking place. Return Value: function returns FLASH_SUCCESS Program/Erase Controller successful FLASH_TOGGLE_FAIL there problem. Description: function used monitor Program/Erase Controller during erase program operations. returns when Program/Erase Controller completed. M59DR008 Data Sheet M59DR032 Data Sheet, Data Toggle Flow Chart shows operation function. Pseudo Code: Step Read (into word). Step Read (into another word). Step toggle between reads then return FLASH_SUCCESS Step Else zero then operation complete, goto Step Else (DQ5 read again. Step toggle between last reads then return FLASH_SUCCESS. Step Else return FLASH_TOGGLE_FAIL. static FlashDataToggle( unsigned long ulOff unsigned hold values read from address offset ulOff while( TimeOut!: some reason, hardware fails then this loop exit. timer function implement timeout from loop. Step Read (into word) FlashRead( ulOff Read from Flash (any address) Step Read (into another word) FlashRead( ulOff Read from Flash (any address) Step toggle between reads then return FLASH_SUCCESS (u1&0x0040) (u2&0x0040) Toggle return FLASH_SUCCESS; Step Else zero then operation complete (u2&0x0020) 0x0000 continue; Step Else (DQ5 read again FlashRead( ulOff Read from Flash (any address) Step toggle between last reads then return FLASH_SUCCESS (u2&0x0040) (u1&0x0040) Toggle return FLASH_SUCCESS; Step Else return FLASH_TOGGLE_FAIL else Toggle here means fail return FLASH_TOGGLE_FAIL;
27/33
AN1201 APPLICATION NOTE
while loop #ifndef ILLUSTRATION_ONLY Function: static FlashDataPoll( unsigned long ulOff, unsigned uVal Arguments: ulOff should hold valid offset polled. programming this will offset word being programmed. erasing this offset block(s)/bank being erased. uVal should hold value being programmed. value should used when erasing. Return Value: function returns FLASH_SUCCESS Program/Erase Controller successful FLASH_POLL_FAIL there problem. Description: function used monitor Program/Erase Controller during erase program operations. returns when Program/Erase Controller completed. M59DR008 Data Sheet M59DR032 Data Sheet, Data Polling Flow Chart shows operation function. Note: This library does Data Polling Flow Chart assess correct operation Program/Erase Controller, uses Data Toggle Flow Chart instead. FlashDataPoll() function only provided here illustration Data Polling Flow Chart Data Sheet. code uses function FlashDataToggle() instead. Pseudo Code: Step Read (into word). Step same uVal(bit then return FLASH_SUCCESS. Step Else zero then operation complete, goto Step Else (DQ5 Read DQ7. Step same uVal(bit then return FLASH_SUCCESS. Step Else return FLASH_POLL_FAIL. static FlashDataPoll( unsigned long ulOff, unsigned uVal unsigned holds value read from valid address while( TimeOut!: some reason, hardware fails then this loop exit. timer function implement timeout from loop. Step Read (into word) FlashRead( ulOff Read DQ5, valid addr Step same Value(bit then return FLASH_SUCCESS (u&0x0080) (uVal&0x0080) DATA return FLASH_SUCCESS; Step Else zero then operation complete (u&0x0020) 0x0000 continue; Step Else (DQ5 FlashRead( ulOff Read valid addr
Step same uVal(bit then return FLASH_SUCCESS (u&0x0080) (uVal&0x0080) DATA return FLASH_SUCCESS;
28/33
AN1201 APPLICATION NOTE
Step Else return FLASH_POLL_FAIL else DATA here means fail return FLASH_POLL_FAIL; while loop #endif !ILLUSTRATION_ONLY 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", "Flash Wrong Type", "Flash Block Failed Erase", "Flash Unprotected", "Flash Protected", "Flash function supported", "Flash Invalid", "Flash Erase Fail", "Flash Toggle Flow Chart Failure", "Flash Unprotect Failed", "Flash Bank Invalid", "Flash Protect Failed", "Flash Lock Failed", "Flash Locked" 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:
29/33
AN1201 APPLICATION NOTE
Description: This value indicates that flash command executed correctly. Error Name: FLASH_POLL_FAIL Notes: Data Polling Flow Chart, which applies series Flash only, used this library. function FlashDataPoll() only provided illustration Data Polling Flow Chart. 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 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. Error Name: FLASH_MPU_TOO_SLOW 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 need changed. Error Name: FLASH_OFFSET_OUT_OF_RANGE Return Value: Description: address offset given range device.
30/33
AN1201 APPLICATION NOTE
Solution: Check that 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: Sadly flash needs replacing. Return Name: FLASH_UNPROTECTED Return Value: Description: user requested unprotect flash that already unprotected. This just warning user that their operation make changes necessary. Return Name: FLASH_PROTECTED Return Value: Description: user requested protect flash that already protected. This just warning user that their operation make changes necessary. Return Name: FLASH_FUNCTION_NOT_SUPPORTED Notes: This condition should occur when using this library. 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: This condition should occur when using this library. 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 block, many blocks bank 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
31/33
AN1201 APPLICATION NOTE
Return Value: Notes: This applies series Flash only. 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: Notes: This applies M59DRxxx series Flash only. 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). 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: Notes: This applies M59DRxxx series Flash only. 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_LOCK_FAIL Return Value: Notes: This applies M59DRxxx series Flash only. Description: This error return value indicates that Lock particular block could set. Error Name: FLASH_LOCKED Return Value: Notes: This applies M59DRxxx series Flash only. Description: This error return value indicates that block already locked when attempt lock made.
32/33
AN1201 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. 2001 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
33/33

Other recent searches


W77E468 - W77E468   W77E468 Datasheet
SFAF1001G - SFAF1001G   SFAF1001G Datasheet
SFAF1008G - SFAF1008G   SFAF1008G Datasheet
PL-2525 - PL-2525   PL-2525 Datasheet
MPC5500 - MPC5500   MPC5500 Datasheet
LXT970A - LXT970A   LXT970A Datasheet
HMC831LP6CE - HMC831LP6CE   HMC831LP6CE Datasheet
DFN2018-6 - DFN2018-6   DFN2018-6 Datasheet

 

Privacy Policy | Disclaimer
© 2012 Datasheet Archive