|
我使用的MCU为STM32F103VC,在使用FSMC访问外部的SRAM的时候,功能脚上没有输出信号? 在使用中为数据线和地址线复用的形式,所以外部加锁存器进行地址锁存,用NADV信号来控制锁存器的lock脚。3 l* b3 S! k3 R8 ~ 信号连接:0 w+ {- r8 O: Q5 b7 c' B NADV---->PB7 NOE----->PD4* j5 H, ?6 t* ]: ^ NWE----->PD5) i7 y, K. j0 o5 z. v6 B NE1----->PD7 NBL0---->PE0+ m/ n8 g( b7 M( u NBL1---->PE13 y& f" \0 m t# S3 X& g q/ m 我使用的为IAR5.0,使用STM32的库函数% |5 y7 _6 G1 r( ] / o4 V) @1 X' {/ u/ y2 p1 i" I: m 我的初始化如下: /* DMA1 and DMA2, FSMCclock enable */' ?) K) q5 |5 f. r" B8 j2 g$ ?$ E RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1 | RCC_AHBPeriph_DMA2|RCC_AHBPeriph_SRAM|RCC_AHBPeriph_FSMC, ENABLE);: H% C. L( u6 g+ s; k6 Z+ R1 p % ]+ D) K* p6 v4 y: S% Z$ k+ H) N K8 S void FSMC_SRAM_Init(void) { FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure; FSMC_NORSRAMTimingInitTypeDef p; GPIO_InitTypeDef GPIO_InitStructure; ; ~! m; k5 @2 `" d ( \1 J$ H/ [- M! W // RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE , ENABLE);& \* c+ E+ G% v4 J" ^/ T. C4 E ) @8 _. c$ k- B* h% ?2 J5 Y /*-- GPIO Configuration ------------------------------------------------------*/3 o( u) A& z$ }# \% k% X /* Set PD.00(D2), PD.01(D3), PD.08(D13), PD.09(D14), PD.10(D15),PD.11(A16), PD.14(D0), PD.15(D1) as alternate function push pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |) ?& }1 g- |) g5 D8 X _' }3 E GPIO_Pin_10 |GPIO_Pin_11 | GPIO_Pin_14 | GPIO_Pin_15;+ i( A l, Q4 d0 C1 a6 ?- j GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; n8 N% e6 _ H) U1 M6 m GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 |GPIO_Pin_15; GPIO_Init(GPIOE, &GPIO_InitStructure); /* PD.04(NOE), PD.05(NWE), PD.07(NE1) configuration */ 2 w! u* D) m/ P( P1 | GPIO_InitStructure.GPIO_Pin = GPIO_Pin_4 |GPIO_Pin_5|GPIO_Pin_7; GPIO_Init(GPIOD, &GPIO_InitStructure);) f6 _7 t# T8 U2 O : h/ E# m: t! j( _; G* s( P$ t /* NBL0, NBL1 configuration */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1; 7 \ p6 _$ g' y9 R GPIO_Init(GPIOE, &GPIO_InitStructure); ' }7 Y8 t/ T# `7 N1 y3 M& y /*NADV configuration */: W! W6 U- V4 o) i% v$ I; D' H GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7; GPIO_Init(GPIOB, &GPIO_InitStructure); 8 v: b! m( S% y9 s/ S, d8 b$ ]* o /*-- FSMC Configuration ------------------------------------------------------*/ p.FSMC_AddressSetupTime = 2; p.FSMC_AddressHoldTime = 2; p.FSMC_DataSetupTime = 3; p.FSMC_BusTurnAroundDuration = 2;3 q8 Z& s5 L7 e+ h2 e. _6 M p.FSMC_CLKDivision = 2; p.FSMC_DataLatency = 3; p.FSMC_AccessMode = FSMC_AccessMode_B; 7 [# o8 u b, d' X+ l FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1; 8 l. C t+ s1 o- t% s/ v! s FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Enable; FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_NOR;& E" W' e' ^* }/ b, j5 J FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_16b;! F+ m: k" R$ W" w FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_Low; FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable; FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState;, ?2 \7 E8 b- T$ g- | FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable; 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;* S- ^) ?& {6 Z4 g! y' v0 ? + K+ D2 u5 F0 {; p) N FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &p; FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &p; ) x, O. B( O j& M5 ~& H FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure); ) e# A+ Z6 t N7 @8 f /* Enable FSMC Bank1_SRAM Bank */* m: N( a/ U. O/ a9 F FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE); " B1 `% ~0 I$ _0 @ } 然后我调用FSMC_SRAM_WriteBuffer(),进行写操作。在FSMC章节中,对复用形式下,采用了模式B。 疑问:) V- F) J1 ~4 f: a 1、在使用中定义IO口为AF,但是手册中D0,D1为默认值,也需要定义为AF吗? 2、我的初始化是否出了问题,我现在用示波器观察IO口发现没有波形输出? FSMC 地址和数据复用 + Z2 h! Q9 [5 M z2 D( W 9 Z( Y: n( @! J( C7 D0 f# x3 V 请看STM32技术参考手册(第5版)的392页最下面 Bit 1 MUXEN: Address/data multiplexing enable bit. When this bit is set, the address and data values are multiplexed on the databus, valid only with NOR Flash memory:& Z& ^1 h: m, p 0: Address/Data nonmultiplexed2 z. t2 V) O2 a" e6 g 1: Address/Data multiplexed on databus (default after reset) 接法都对 原理图的问题 此为转帖 以便大家学习 |
微信公众号
手机版
RE:FSMC访问SRAM的问题