Forum: Mikrocontroller und Digitale Elektronik fsmc am stm32f4


von Bastian M. (integer)


Angehängte Dateien:

Lesenswert?

Guten Abend,

ich habe schon seit längerer Zeit ein Problem mit dem FSMC des 
STM32F4-Discovery Boards. Ich möchte ein Wiz830mj (Breakoutboard zu 
einem W5300 von Wiznet) über den FSMC zugreifen.

Hier schon mal mein Code so weit:
1
// GPIO Init-Structure
2
  GPIO_InitTypeDef gpioInitStruct;
3
4
  // Enable GPIO D and E clocks
5
  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD | RCC_AHB1Periph_GPIOE, ENABLE);
6
7
  //Create GPIO D InitStructure for used pins
8
  gpioInitStruct.GPIO_Mode =    GPIO_Mode_AF;
9
  gpioInitStruct.GPIO_Speed =    GPIO_Speed_100MHz;
10
  gpioInitStruct.GPIO_OType =   GPIO_OType_PP;
11
  gpioInitStruct.GPIO_PuPd =    GPIO_PuPd_UP;
12
  gpioInitStruct.GPIO_Pin =    GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_4 | GPIO_Pin_5 | 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;
13
  // Initialize Pins
14
  GPIO_Init(GPIOD, &gpioInitStruct);
15
16
  // Configure GPIO D pins as FSMC alternate functions
17
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource0, GPIO_AF_FSMC);
18
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource1, GPIO_AF_FSMC);
19
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource4, GPIO_AF_FSMC);
20
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource5, GPIO_AF_FSMC);
21
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource7, GPIO_AF_FSMC);
22
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource8, GPIO_AF_FSMC);
23
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource9, GPIO_AF_FSMC);
24
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource10, GPIO_AF_FSMC);
25
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource11, GPIO_AF_FSMC);
26
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource12, GPIO_AF_FSMC);
27
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource13, GPIO_AF_FSMC);
28
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource14, GPIO_AF_FSMC);
29
  GPIO_PinAFConfig(GPIOD, GPIO_PinSource15, GPIO_AF_FSMC);
30
31
32
  // Create GPIO E InitStructure for used pins
33
  gpioInitStruct.GPIO_Pin =    GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | 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;
34
  // Initialize pins
35
  GPIO_Init(GPIOE, &gpioInitStruct);
36
37
  //Configure GPIO E pins as FSMC alternate function
38
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource3, GPIO_AF_FSMC);
39
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource4, GPIO_AF_FSMC);
40
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource5, GPIO_AF_FSMC);
41
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource6, GPIO_AF_FSMC);
42
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource7, GPIO_AF_FSMC);
43
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource8, GPIO_AF_FSMC);
44
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource9, GPIO_AF_FSMC);
45
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource10, GPIO_AF_FSMC);
46
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource11, GPIO_AF_FSMC);
47
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource12, GPIO_AF_FSMC);
48
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource13, GPIO_AF_FSMC);
49
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource14, GPIO_AF_FSMC);
50
  GPIO_PinAFConfig(GPIOE, GPIO_PinSource15, GPIO_AF_FSMC);
51
52
FSMC_NORSRAMInitTypeDef FSMC_NORSRAMInitStructure;
53
  FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructureRead;
54
  FSMC_NORSRAMTimingInitTypeDef FSMC_NORSRAMTimingInitStructureWrite;
55
56
  // Enable FSMC Clock
57
  RCC_AHB3PeriphClockCmd(RCC_AHB3Periph_FSMC, ENABLE);
58
59
  // Define Read timing parameters
60
  FSMC_NORSRAMTimingInitStructureRead.FSMC_AddressSetupTime = 0;
61
  FSMC_NORSRAMTimingInitStructureRead.FSMC_AddressHoldTime = 7;
62
  FSMC_NORSRAMTimingInitStructureRead.FSMC_DataSetupTime = 4;
63
  FSMC_NORSRAMTimingInitStructureRead.FSMC_BusTurnAroundDuration = 3;
64
  FSMC_NORSRAMTimingInitStructureRead.FSMC_CLKDivision = 2;
65
  FSMC_NORSRAMTimingInitStructureRead.FSMC_DataLatency = 1;
66
  FSMC_NORSRAMTimingInitStructureRead.FSMC_AccessMode = FSMC_AccessMode_A;
67
68
  // Define Write timing parameters
69
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_AddressSetupTime = 0;
70
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_AddressHoldTime = 6;
71
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_DataSetupTime = 1;
72
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_BusTurnAroundDuration = 3;
73
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_CLKDivision = 2;
74
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_DataLatency = 2;
75
  FSMC_NORSRAMTimingInitStructureWrite.FSMC_AccessMode = FSMC_AccessMode_A;
76
77
  // Define protocol type
78
  FSMC_NORSRAMInitStructure.FSMC_Bank = FSMC_Bank1_NORSRAM1;
79
  FSMC_NORSRAMInitStructure.FSMC_DataAddressMux = FSMC_DataAddressMux_Disable;
80
  FSMC_NORSRAMInitStructure.FSMC_MemoryType = FSMC_MemoryType_SRAM;
81
  FSMC_NORSRAMInitStructure.FSMC_MemoryDataWidth = FSMC_MemoryDataWidth_8b;
82
  FSMC_NORSRAMInitStructure.FSMC_BurstAccessMode = FSMC_BurstAccessMode_Disable;
83
  FSMC_NORSRAMInitStructure.FSMC_AsynchronousWait = FSMC_AsynchronousWait_Disable;
84
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalPolarity = FSMC_WaitSignalPolarity_High; // Don't care
85
  FSMC_NORSRAMInitStructure.FSMC_WrapMode = FSMC_WrapMode_Disable;
86
  FSMC_NORSRAMInitStructure.FSMC_WaitSignalActive = FSMC_WaitSignalActive_BeforeWaitState; // Don't care
87
  FSMC_NORSRAMInitStructure.FSMC_WriteOperation = FSMC_WriteOperation_Enable;
88
  FSMC_NORSRAMInitStructure.FSMC_WaitSignal = FSMC_WaitSignal_Disable;
89
  FSMC_NORSRAMInitStructure.FSMC_ExtendedMode = FSMC_ExtendedMode_Enable;
90
  FSMC_NORSRAMInitStructure.FSMC_WriteBurst = FSMC_WriteBurst_Disable;
91
  FSMC_NORSRAMInitStructure.FSMC_ReadWriteTimingStruct = &FSMC_NORSRAMTimingInitStructureRead;
92
  FSMC_NORSRAMInitStructure.FSMC_WriteTimingStruct = &FSMC_NORSRAMTimingInitStructureWrite;
93
94
  // Initialize FSMC for read and write
95
  FSMC_NORSRAMInit(&FSMC_NORSRAMInitStructure);
96
97
  // Enable FSMC
98
  FSMC_NORSRAMCmd(FSMC_Bank1_NORSRAM1, ENABLE);

so weit so gut... Figure 404 im ReferenceManual auf Seite 1320 verstehe 
ich so, dass der Speicherbereich für meinen W5300 jetzt bei 0x600000000 
anfangen müsste. Ist das so weit richtig?

Wenn ja, habe ich das Problem, dass ich auf diesen Speicherbereich auch 
im Debugger nicht zugreifen kann. Wenn ich im Memory-Window von Eclipse 
den Bereich auslesen will, bekomm ich nur die Fehlermeldung "Unable to 
load memory from the specified adress: 0x600000000".

Kann mir hier jemand auf die Sprünge helfen? Ist die Adresse falsch, auf 
die ich zugreifen will, oder stimmt etwas mit meiner FSMC-Konfiguration 
nicht?

Vielen Dank schonmal für die Hilfe im Voraus,
Bastian

von M. N. (Gast)


Lesenswert?

Dein Board kenne ich nicht und bei den vielen CMSIS Aufrufen bekommt man 
einen Knoten im Hals.
Hier findest Du eine Initialisierung, die funktioniert. 
Beitrag "TFT-direct-drive, WQVGA-TFT an STM32F4"
Ggf. müssen die Zugriffsart und -zeiten angepaßt werden.

von Bastian M. (integer)


Lesenswert?

Danke für die Info,

ich hab's einfach nach dem Example von STM gemacht...
werd mir gleich mal den Link anschauen

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.