2
\$\begingroup\$

I am using FSMC(Flexible static memory controller) function of STM32:reference manual.On page 494 of referencec manual, the data bus should be bidirectional. It is reasonable but i have no idea how to realise it in STM32 because it has only two modes: input and output mode(on page 166). After refering to examples from ST, i know that the data port should be considered as ouput push-pull mode as shown below,

/*data line configuration*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_8 | GPIO_Pin_9 |
                            GPIO_Pin_10 | GPIO_Pin_14 | GPIO_Pin_15;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);

So,can anyboy tell me how can STM32 realise bidirectional port using output push-pull mode?

\$\endgroup\$
1
\$\begingroup\$

Have a look at Section 9.1.4 on page 157:

9.1.4 Alternate functions (AF)

It is necessary to program the Port Bit Configuration Register before using a default alternate function.

  • For alternate function inputs, the port must be configured in Input mode (floating, pullup or pull-down) and the input pin must be driven externally.

Note: It is also possible to emulate the AFI input pin by software by programming the GPIO controller. In this case, the port should be configured in Alternate Function Output mode. And obviously, the corresponding port should not be driven externally as it will be driven by the software using the GPIO controller.

  • For alternate function outputs, the port must be configured in Alternate Function Output mode (Push-Pull or Open-Drain).

  • For bidirectional Alternate Functions, the port bit must be configured in Alternate Function Output mode (Push-Pull or Open-Drain). In this case the input driver is configured in input floating mode

If you configure a port bit as Alternate Function Output, this disconnects the output register and connects the pin to the output signal of an on-chip peripheral.

If software configures a GPIO pin as Alternate Function Output, but peripheral is not activated, its output is not specified.

If a pin or a bus is supposed to be bidirectional for an Alternate Function, configure it as an Alternate Function in Output mode and the input configuration happens automatically.

If the pin is supposed to be an input for an Alternate Function, configure it in Input Mode.

If the pin is supposed to be an output for an Alternate Function, configure it in Output mode.

When you're using a pin as GPIO, you have to choose between Input mode or Output mode.

\$\endgroup\$
  • \$\begingroup\$ thanks a lot, i should read reference manual more carefuly. \$\endgroup\$ – oilpig Jun 11 '13 at 14:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.