STM32使用fsmc控制NOR flash 例程(2)
- UID
- 1029342
- 性别
- 男
|
STM32使用fsmc控制NOR flash 例程(2)
二、程序分析 /*-- FSMC Configuration ----------------------------------------------------*/
p.FSMC_AddressSetupTime = 0x05; /*ADDSET 地址建立时间*/
p.FSMC_AddressHoldTime = 0x00; /*ADDHOLD 地址保持时间*/
p.FSMC_DataSetupTime = 0x07; /*DATAST 数据建立时间*/
p.FSMC_BusTurnAroundDuration = 0x00; /*BUSTURN 总线返转时间*/
p.FSMC_CLKDivision = 0x00; /*CLKDIV 时钟分频*/
p.FSMC_DataLatency = 0x00; /*DATLAT 数据保持时间*/
p.FSMC_AccessMode = FSMC_AccessMode_B; /*访问模式*/
/*NOR/SRAM的存储块,共4个选项*/
FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM2;
/*是否选择地址和数据复用数据线*/
FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
/*连接到相应存储块的外部存储器类型*/
FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;
/*存储器数据总线宽度*/
FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;
/*使能或关闭同步NOR闪存存储器的突发访问模式设置是否使用迸发访问模式(应该就是连续读写模式吧)*/
FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
/*设置WAIT信号的有效电平*/
FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low;
/*设置是否使用环回模式*/
FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
/*设置WAIT信号有效时机*/
FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;
/*设定是否使能写操作*/
FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
/*设定是否使用WAIT信号*/
FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
/*使能或关闭扩展模式,扩展模式用于访问具有不同读写操作时序的存储器,设定是否使用单独的写时序*/
FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Disable;
/*设定是否使用异步等待信号*/
FSMC_NORSRAMInitStructure.FSMC_AsyncWait = FSMC_AsyncWait_Disable;
/*设定是否使用迸发写模式*/
FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
/*设定读写时序*/
FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; //
FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; //
FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); //
/* Enable FSMC Bank1_NOR Bank */
FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM2, ENABLE); //
}
三、例程:STM32读写外NOR FLASH 存储器 39VF1601
1. fsmc_nor..c
/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name : fsmc_nor.c
* Author : MCD Application Team
* Version : V2.0.1
* Date : 06/13/2008
* Description : This file provides a set of functions needed to drive the
* M29W128FL, M29W128GL and S29GL128P NOR memories mounted
* on STM3210E-EVAL board.
********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/
/* Includes ------------------------------------------------------------------*/
#include "fsmc_nor.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define Bank1_NOR2_ADDR ((u32)0x64000000)
/* Delay definition */
#define BlockErase_Timeout ((u32)0x00A00000)
#define ChipErase_Timeout ((u32)0x30000000)
#define Program_Timeout ((u32)0x00001400)
/* Private macro -------------------------------------------------------------*/
#define ADDR_SHIFT(A) (Bank1_NOR2_ADDR + (2 * (A)))
#define NOR_WRITE(Address, Data) (*(vu16 *)(Address) = (Data))
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/
/*******************************************************************************
* Function Name : FSMC_NOR_Init
* Description : Configures the FSMC and GPIOs to interface with the NOR memory.
* This function must be called before any write/read operation
* on the NOR.
* Input : None
* Output : None
* Return : None
*******************************************************************************/ |
|
|
|
|
|