Remapping and multiplexing

Source: Internet
Author: User

Now let's talk about the port remapping of the STM32 microcontroller, as it is an example of itself. Here is an example of the remapping of the USART1:

Because I want a TFT_LCD screen of the main control board, taking into account the FSMC I chose the STM32F103VCT6 model of the CPU, accidentally connected to the serial port USART1. Because in the tuning process only found wrong, there is no way, can only be resolved by port remapping. But it didn't work. Port remapping , only the name, not the body, so. Oh... Can only be seen from the beginning.

There are many I/O ports on the STM32, there are many built-in external assumptions i2c,adc,isp,usart and so on, in order to save the pinout, these built-in peripherals are basically shared with the I/O port, that is, the I/O pin multiplexing function. But one of the special features of STM32 is that many of the I/O pins that are multiplexed with the built-in peripherals can be derived from different I/O pins through the remapping function, that is, the pin of the multiplexing function can be changed by the program. Read here that you should understand some of the concepts of port remapping. The principle of the thing is not elaborate, You can read the manual or online search, this is still a lot of information. Let's talk about my debugging experience.

Do not know what is the reason for PCB mapping when the serial port to USART1, at that time also did not care, and so I put the Usart test program to burn in the hardware simulation, the serial port is garbled, I felt strange at that time. Check the program several times is to check the problem, think it is hardware problems, But suddenly thought of the STM has the function of multiplexing, thought will be here ghost? So find a datasheet, the truth

Three red boxes at the intersection. STM32F103VCT6 The USART1 of this CPU is PB6/PB7 but the default function after power-on initialization is not USART1. So you want to use the serial port function. Must be re-mapped with ports:

As you know, STM32 SCM each function module has its own clock system, so want to call the STM32 MCU function module must first configure the corresponding clock, and then to operate the corresponding function module. Port remapping is also the same.

The remap steps are:

1. Open the I/O port pin clock after the remap clock and the Usart remap,

Rcc_apb2periphclockcmd (Rcc_apb2periph_gpiob | rcc_apb2periph_afio,enable);

The 2.i/o kouzhong map is turned on.

Gpio_pinremapconfig (gpio_remap_usart1,enable);

3. Prepare the remap pin, where only the remap I/O is configured, the original does not need to be configured.

                              gpio_initstructure.gpio_pin = GPIO_Pin_6 ;
                              gpio_initstructure.gpio_mode = GPIO_Mode _AF_PP;
                              gpio_initstructure.gpio_speed = GPIO_ Speed_50mhz;
                              gpio_init (GPIOB, &GPIO_ Initstructure);


                               gpio_initstructure.gpio_pin = GPIO _pin_7;
                               gpio_initstructure.gpio_mode = gpio_mode_in_floating;
                                gpio_init (GPIOB,&GPIO_ Initstructure);

Only need these three steps, the serial port can be used normally, simple? But I struggled for the most part of the hour to fix, a lot of things are easy to say it is difficult to do, I hope that I will progress. Don't above his business, well I'm heading in that direction.



Finally, summarize:

Simply said STM32 IO has 3 functions one is the default one is the re-use of one is the remapping function (this is actually a reuse)

If configured for reuse, the 2nd feature will be used if it is configured for reuse and the corresponding remap is configured then the 3rd feature will be used

Usually the multiplexing + remapping of a single port is a lot more than two. This is the time to see what device you can make (which one is enabled)

Open multiplexing + Enable device + whether or not remap can determine which function this IO port uses

Category: STM32, STM32 good text to the top of my collection of the article Jeakon
Follow-3
Fans-7 + plus attention10(Please comment on the article) «Previous: How to use Android MediaPlayer simple Introduction
» Next: Stm32 Use of external interrupts (with instances) posted @2012-10-04 09:19 Jeakon Read (8071) Comments (0) Edit Collection

Remapping and multiplexing

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.