📄 64m_pse.c
字号:
/*****************************************************************************
*
* File Name : 64M_PSE.c
* Program Suspend/Resume operation for 64Mbit Flash Memory
* Version : 0.10.10
* CPU : SH7709A
* Compiler : SHC V.5.1.00
* Author : F.Saeki
*
* The information described here may contain technical inaccuracies or
* typographical errors. Renesas technology Corporation and Renesas Solutions
* and Oyo Electric Corporation assume no responsibility for any damage,
* liability, or other loss rising from these inaccuracies or errors.
*
* Copyright (c) 2003
* Renesas Technology Coporation and Renesas Solutions Corporation
* and Oyo Electric Corporation All Rights Reserved
*
* ---------------------------------------------------------------------------
* This sample program provides C code for using the Renesas
* 64Mbit(4Mb x16) NOR type Flash Memory and MCP(Multi Chip Package).
* The following typical devices are supported in this file.
* M5M29KB/T641AVP
* M6MGB/T641S4TP
* M6MGB/T641S8AKT
* M6MGB/T647M17AKT
* M6MGB/T647M34CKT
* M6MGB/T64BS4AWG
* M6MGB/T64BS8AWG
* M6MGB/T64BM17AWG
* M6MGB/T64BM34CWG
*
*
* The following function commands are available in this file.
* FmProgSuspendResume() Program Suspend/Resume operation
*
* ---------------------------------------------------------------------------
* Version History: Ver. 0.10.00 '03/03/07 First release
* Ver. 0.10.10 '03/08/22 Change of a product type name
* Change of a comment(NOR type)
******************************************************************************/
#define TRUE 1
#define FALSE 0
int ProgStop; /* Request of Suspend Program */
unsigned short TestData;
/******************************************************************************
* FmProgSuspendResume() Program Suspend/Resume operation
* ---------------------------------------------------------------------------
* Declaration int FmProgSuspendResume(unsigned short *pProgStart,
* unsigned short *pProgStop,
* unsigned short *pDataStart)
* ---------------------------------------------------------------------------
* Description This function is a sample program in the case of reading data
* from the same bank during program.
* In this sample program, when an ProgStop flag is set to TRUE
* during erase function, function is interrupted and it waits to
* set an ProgStop flag to FALSE.
* If an ProgStop flag is set to FALSE, it will consider that
* read the data in other tasks was completed, and function will
* be resumed.
* Please initialize the ProgStop flag by FALSE.
* ---------------------------------------------------------------------------
* Parameter unsigned short *pProgStart; Program start address
* unsigned short *pProgStop; Program stop address
* unsigned short *pDataStart; Program data start address
* ---------------------------------------------------------------------------
* Return Value int Errflg;
* TRUE : Program normal stop
* FALSE: Program abnormal stop
* ---------------------------------------------------------------------------
* No Related Function
* ---------------------------------------------------------------------------
* Version Ver. 0.10.00 '03/03/07 First release
*******************************************************************************/
int FmProgSuspendResume(unsigned short *pProgStart, unsigned short *pProgStop,
unsigned short *pDataStart)
{
int Errflg = TRUE; /* Error Flag */
unsigned short *pProgStatus; /* Program Start Address */
int DataNum; /* Data Counter for Data Output Loop */
/*==== Loop until the Stop Address of the Program ====*/
while(pProgStart <= pProgStop && Errflg == TRUE){
pProgStatus = pProgStart;
*pProgStart = 0x41; /* Output of Page Program Command */
/***** 128-words Data Output *****/
for(DataNum = 0;DataNum < 128;DataNum++){
*pProgStart = *pDataStart; /* Output of Program Data */
pProgStart++; /* Flash Memory Pointer+1 */
pDataStart++; /* Data Pointer to be transmitted+1 */
}
/***** Status Polling *****/
while((*pProgStatus & 0x80) != 0x80) { /* Status Data Confirmation */
if( ProgStop == TRUE) {
/***** Suspend Program *****/
if ((*pProgStatus & 0xC0) == 0x00) {
*pProgStatus = 0xB0; /* Output of Suspend Command */
/*==== Suspend Status Polling ====*/
while((*pProgStatus & 0x40) != 0x40);/* Status Data Confirmation */
}else{
Errflg = FALSE; /* Set of Error Flag */
break;
}
*pProgStatus = 0xFF; /* Output of Read Array Command */
/***** Waiting for Data Reference *****/
while( ProgStop == TRUE);
/***** Resume Program *****/
*pProgStatus = 0x70; /* Read Status Register */
if ((*pProgStatus & 0xC0) == 0xC0) { /* Suspend Continue丠 */
*pProgStatus = 0xD0; /* Output of Resume Command */
}else{
Errflg = FALSE; /* Set of Error Flag */
break;
}
}
}
if ((*pProgStatus & 0x38) != 0x00) { /* Check of Error */
Errflg = FALSE; /* Set of Error Flag */
*pProgStatus = 0x50; /* Clear Status */
}
}
*pProgStatus = 0xFF; /* Output of Raed Array Command */
return Errflg;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -