Why do we need to set speed for GPIO output pins in STM32?

The STM32F4 Reference Manual on page 278 says that:

The data present on the I/O pin are sampled into the input data register every AHB1 clock cycle.

Then why do we need to set speed to the pins while it is specified?.

  • \$\begingroup\$ Welcome to EE.SE. \$\endgroup\$ – Sparky256 Oct 14 '18 at 22:30
  • 3
    \$\begingroup\$ Hello Amin! Please see this related question. \$\endgroup\$ – bitsmack Oct 15 '18 at 1:09

STM32F4-Refrence Manual in page 278 says that "The data present on the I/O pin are sampled into the input data register every AHB1 clock cycle"

This text is referring to input pins, not outputs.

The output speed register only affects pins which are configured as outputs. It controls the slew rate (drive strength) used for the output. Using an excessively high speed may cause ringing and EMI on outputs, so it is important to use the minimum speed required for your application.

  • \$\begingroup\$ Inputs as well. It is guaranteed that the change of the input pin by the external world will propagate as quiche as the bus speed. \$\endgroup\$ – P__J__ Oct 15 '18 at 1:01
  • 4
    \$\begingroup\$ @P__J__ I'm confused what you're trying to say here. The GPIO speed settings affect slew rate, not clock rate. They do not have any effect on GPIOs which are not configured as outputs. \$\endgroup\$ – duskwuff Oct 15 '18 at 2:31

Most any very fast CPU or MPU have bus or GPIO pin speeds that require 10 ohm to 27 ohm resistors in series at the endpoint of the trace to prevent ringing and adjacent trace cross talk. If your GPIO data or IO control is erratic then maybe you have to slow down AHB1 rate or insert those resistors I mentioned.

If pin is an input then resistor is at the pin. If the pin is an output then resistors is at the device pin being driven. Dampening or impedance matching resistors might allow you to keep current AHB1 speed. If you still have data corruption then you MUST slow down the AHB1 rate or insert a few nops or wait-states to throttle back the IO speed

  • 2
    \$\begingroup\$ Pretty sure that anything that can be accomplished by changing the bus clock can also be done by inserting wait states... so stating "you MUST slow down the AHB1" isn't accurate. \$\endgroup\$ – Ben Voigt Oct 15 '18 at 3:54
  • \$\begingroup\$ @Benvoight. I added that to my answer. \$\endgroup\$ – Sparky256 Oct 15 '18 at 13:21
  • \$\begingroup\$ That whole line of thought is mistaken. It has nothing to do with the bus speed, but rather with the driver slew rate. And the speed settings the question refers to are slew rate control bits of those drivers, not external resistors. \$\endgroup\$ – Chris Stratton Oct 15 '18 at 14:51
  • \$\begingroup\$ @ChrisStratton. Ok, so I missed the OP's point, but series resistors are still use on every motherboard with very fast bus speeds, sometimes at both ends. Even with slew rate control the resistors dampen ringing and to some degree act as impedance matching devices so optimum speed without corruption is possible. \$\endgroup\$ – Sparky256 Oct 15 '18 at 18:44

Also, you need to set the speed for GPIO output pins each time you set one up or you are going to be using a default value or a previous value. For example, if you set it dead slow for a pin driving an LED, and then neglect to set it at all for a pin driving a high-speed bus, you will not be happy with the result.

  • \$\begingroup\$ Hi Colin, and welcome to the site. The answer form is reserved for actual answers which address the core of the question. What you have posted is really a tangential comment, which is not an appropriate use of the answer form, and that is why someone else has downvoted your posting. It would probably be best deleted. \$\endgroup\$ – Chris Stratton Nov 26 '18 at 15:49
  • \$\begingroup\$ It seems you similarly misused the answer form to amend you own question here yesterday. Stack exchange sites have very strict rules, so please take time to really read and understand them - misuse of the site is not well received here. \$\endgroup\$ – Chris Stratton Nov 26 '18 at 15:51
  • \$\begingroup\$ OK but the question was "Why do we need to set speed for GPIO output pins in STM32?" I think I gave one good reson why. \$\endgroup\$ – Colin C Nov 26 '18 at 16:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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