About STM32 PB3 PB4 How to set up a general Gpio configuration

Source: Internet
Author: User

For beginners, why not control the output when using PB3 and PB4.

The following is an analysis of this issue.

First, after the STM32F10X series MCU is reset, the PA13/14/15 & PB3/4 is configured as a JTAG feature by default. Sometimes in order to make full use of the resources of the MCU I/O port, these
The port is set to a normal I/O port. Here's how:
In Gpio_configuration (); Configure the GPIO ports used:


Gpio_pinremapconfig (gpio_remap_swj_disable, ENABLE);
//change the mapping of the specified pin gpio_remap_swj_disable SWJ completely disabled (jtag+ SW-DP)
Gpio_pinremapconfig (gpio_remap_swj_jtagdisable, ENABLE);
//change the mapping gpio_remap_swj_jtagdisable of the specified PIN, JTAG-DP Disable + SW-DP enable

  gpio_initstructure.gpio_pin = Gpio_pin_3 | Gpio_pin_4;
  gpio_initstructure.gpio_speed = Gpio_speed_50mhz;
  gpio_initstructure.gpio_mode = gpio_mode_out_pp;
  gpio_init (GPIOB, &gpio_initstructure);

  gpio_initstructure.gpio_pin = Gpio_pin_11 | Gpio_pin_12 | gpio_pin_13;
  gpio_initstructure.gpio_speed = Gpio_speed_50mhz;
  gpio_initstructure.gpio_mode = gpio_mode_out_pp;
  gpio_init (Gpioa, &gpio_initstructure);  

Note: Do not forget to turn on the rcc_configuration clock in Afio (),
  //afio Clock
rcc_apb2periphclockcmd (Rcc_apb2periph_afio, ENABLE);

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.