你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

基于STM32F103ZET6使用FSMC驱动TFT的学习 (三)

[复制链接]
EEFOCUS小白 发布时间:2015-4-1 10:11
a、首先是时间参数的配置,我们在初始化的时候设置的bank4,所以这里对应的也是bank4,本函数主要使用了两种类型的结构体对FSMC进行配置,第一种# s$ Y3 e$ D) F; [9 f3 ?6 g+ s
为 FSMC_NORSRAMInitTypeDef类型的结构体主要用于NOR FLASH的模式配置,包括存储器类型、数据宽度等。另一种的类型为FSMC_NORSRAMTimingInitTypeDef

4 Y/ Y- z* h& `, ]# `% u& V
首先是这个结构体FSMC_NORSRAMTimingInitTypeDef,找到他的定义:
成员变量有

) W/ y/ V% v0 v3 V3 y+ o
  • uint32_t  FSMC_AccessMode   
  • uint32_t  FSMC_AddressHoldTime   
  • uint32_t  FSMC_AddressSetupTime   
  • uint32_t  FSMC_BusTurnAroundDuration   
  • uint32_t  FSMC_CLKDivision   
  • uint32_t  FSMC_DataLatency   
  • uint32_t  FSMC_DataSetupTime   
    * y* G+ H0 I' L2 ]2 d$ K
uint32_t  FSMC_AccessMode uint32_t  FSMC_AddressHoldTime uint32_t  FSMC_AddressSetupTime uint32_t  FSMC_BusTurnAroundDuration uint32_t  FSMC_CLKDivision uint32_t  FSMC_DataLatency uint32_t  FSMC_DataSetupTime
& v3 g. g  N7 j5 N$ }
  U' H7 T5 \" h# D( |
FSMC_AccessMode:Specifies the asynchronous access mode,用于同步模式,它的取值有以下几种,参考手册上面显示:模式A —— SRAM/PSRAM(CRAM) OE翻转,所以这里我们选择的是模式A
( _: P5 l7 B- \  `5 {2 `$ y. u- p
#define
FSMC_AccessMode_A   ((uint32_t)0x00000000)
#define
FSMC_AccessMode_B   ((uint32_t)0x10000000)
#define
FSMC_AccessMode_C   ((uint32_t)0x20000000)
#define
FSMC_AccessMode_D   ((uint32_t)0x30000000
+ j5 U8 [% ?5 Q, F% W3 U

! U. `8 q# F$ n  a6 h
FSMC_AddressHoldTime:Defines the number of HCLK cycles to configure the duration of the address hold time. This parameter can be a value between 0 and 0xF.地址保持的时钟周期!
FSMC_AddressSetupTime:Defines the number of HCLK cycles to configure the duration of the address setup time. This parameter can be a value between 0 and 0xF. 明显是地址建立飞时间周期
FSMC_BusTurnAroundDuration:Defines the number of HCLK cycles to configure the duration of the bus turnaround. This parameter can be a value between 0 and 0xF.这个应该是指总线翻转周期么,不是很了解
FSMC_CLKDivision:Defines the period of CLK clock output signal, expressed in number of HCLK cycles. This parameter can be a value between 1 and 0xF0 T! q4 t! S& D( t
明显是指HCLK的分频系数
8 w3 i9 ~% ~5 J8 Y
FSMC_DataLatency:Defines the number of memory clock cycles to issue to the memory before getting the first data. The value of this parameter depends on the memory type as shown below:
. q3 _7 y2 Z# U% h- f
0 [' t5 l" e/ C! t( Q0 Z
  • It must be set to 0 in case of a CRAM
  • It is don't care in asynchronous NOR, SRAM or ROM accesses
  • It may assume a value between 0 and 0xF in NOR Flash memories with synchronous burst mode enable 1 Z5 v( w& L6 I1 Y3 B' T6 z6 Z
:数据延迟时间注意了,这个可是有限制的,在我们控制LCD的时候倒是不用管它,应该是可以设为0的
1 n9 D9 ?4 \* u5 D# `
FSMC_DataSetupTime:这个相应的就是数据的建立时间了4 Q  V9 t- S  A! U
通过对比,发现上述配置是可行的,不过大家也可以按照要求更改。理论上,在速度要求不是很高的场合,大一点是没有关系的,但是下限得注意,具体是多少,我也走不知道,等以后再说吧!
然后就是看这个结构体了FSMC_NORSRAMInitStructure,成员如下:

5 f% Z- T/ n3 |  h0 e' \( q) C+ M2 `* A6 K+ _) v9 `
似乎有些复杂,同时也说明了它的功能强大吧!
FSMC_AsynchronousWait:Enables or disables wait signal during asynchronous transfers, valid only with asynchronous Flash memories,明显就是使能等待同步信号否?
FSMC_Bank:这个应该是bank的选择吧,明显取值有以下几种:
+ z, m# E4 Y/ Z% l8 H6 b7 J
#define
FSMC_Bank1_NORSRAM1   ((uint32_t)0x00000000)
#define
FSMC_Bank1_NORSRAM2   ((uint32_t)0x00000002)
#define
FSMC_Bank1_NORSRAM3   ((uint32_t)0x00000004)
#define
FSMC_Bank1_NORSRAM4   ((uint32_t)0x00000006)
% T6 l4 Q' t) f, X" @/ o/ q* C" M: G
FSMC_BurstAccessMode:Enables or disables the burst access mode for Flash memory, valid only with synchronous burst Flash memories.这个什么呢?不懂继续看吧!
FSMC_DataAddressMux:Specifies whether the address and data values are multiplexed on the databus or not,数据地址引脚是否复用,明显这里我们不需要!!
FSMC_ExtendedMode:Enables or disables the extended mode.,外扩模式否?应该是不用的
FSMC_MemoryDataWidth:位宽,我使用的是16位的TFT,所以应该是16,看看取值7 x, r- f7 m" `3 T* T$ N1 C
果然:
#define
FSMC_MemoryDataWidth_16b   ((uint32_t)0x00000010)
#define
FSMC_MemoryDataWidth_8b   ((uint32_t)0x00000000)
FSMC_MemoryType:Specifies the type of external memory attached to the corresponding memory bank.意思应该是当我们外扩存储器的时候,分配哪一个bank吧,看取值。应该是0-3吧!看结果似乎有些问题,它是指外扩的存储器类型
#define
FSMC_MemoryType_NOR   ((uint32_t)0x00000008)
#define
FSMC_MemoryType_PSRAM   ((uint32_t)0x00000004)
#define
FSMC_MemoryType_SRAM   ((uint32_t)0x00000000

4 _4 {4 |: Y. a  G8 ~4 u, L
FSMC_WaitSignal:Enables or disables the wait-state insertion via wait signal等待信号,等待状态与否
FSMC_WaitSignalPolarity:Specifies the wait signal polarity, valid only when accessing the Flash memory in burst mode,是指奇偶校验信号么?但是这个只需在flash的burst模式里面设置。
FSMC_WrapMode:Enables or disables the Wrapped burst access mode for Flash memory翻转模式?
FSMC_WriteBurst :Enables or disables the write burst operation写操作的
FSMC_WriteOperation:Enables or disables the write operation in the selected bank by the FSMC
FSMC_WriteTimingStruct
: k  U& H! m  G/ J9 A0 ~FSMC_ReadWriteTimingStruct还有两个这样的结构体! Timing Parameters for write and read access if the ExtendedMode is not used  ,当我们没有使用外扩模式的时候需要配置,显然这里需要配置的!; L8 z8 H: a* ~8 g7 K) {4 V7 l4 I
这两个结构体就是上面分析了的。所以我们只要执行这个语句,就能完成FSMC的配置了
0 i$ U% T- P) @9 fFSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);  
0 m- p4 T( @' T  _  l1 G
7 c( O- c7 E1 O6 j+ y
至此分析完毕!7 E" e7 T9 V" _$ P% O
然后就是简单的初始化TFT了' P! p4 j; x' r2 X, I
个人觉得有几点需要注意的地方,也总结一下!6 y2 h9 R# _% p8 L/ b+ q/ B. P
关于使用16位宽的时候的地址的问题!: \2 I' m/ _; r9 S% W6 N
用的第17位,插16位的线- \. T/ u2 z5 x/ l2 L
假如我们这样访问
*(volatile unsigned short int *)(0x60020000)=val

6 h$ \  `# b8 h7 q) v6 d6 W
这时候该地址的bit17位为1,因为我们使用16位宽模式,先看下面一张图
) z- X: e& W; I( I
2 y8 d6 \1 L/ B- B7 r
赞 收藏 评论2 发布时间:2015-4-1 10:11

举报

2个回答
stary666 回答时间:2015-4-1 11:06:23
没有简化的代码吗?
为什么是EEFOCUS小白 回答时间:2015-4-3 12:15:35
没有哦   

所属标签

相似技术帖

官网相关资源

关于
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
意法半导体官网
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
官方最新发布
人形机器人运动控制、感知与智能配电
半导体创新技术与应用方向
EE架构与软件定义汽车
12V/48V 汽车智能配电(SPD)
区域控制单元(ZCU)与分区架构
关注我们
st-img 微信公众号
st-img 手机版