The relation __stm32 between STM32 and re-image of pin

Source: Internet
Author: User

The memory has recently fallen exponentially, and the things that were previously understood have been forgotten, so write them down to avoid having to review the data again next time.

Here is about stm32f10x, and STM32F0XX series or some differences, F0 's next time to write ....

To sum up: reuse is a PIN has several functions, 1. Do ordinary IO input and output 2. Other peripherals input and output (such as I2C,TIM,SPI, etc.), this is reuse.

Remapping is to redefine the PIN function to other pins, such as PA9 is the USART1-TX default PIN, but now PA9 is used for it, which can remap usart1-tx to PB6, of course, this mapping is not random want to map to which foot on which foot, The inside of the chip is fixed and can only be mapped to a fixed place.

Okay, here's the idea.

The default function of PA8 after MCU reset is normal IO pin, I want to set it as TIM1 pwm-ch1 multiplexing output

The steps are: 1, the TIM1 initialization good, set into a PWM output, so that the timer. 2, the PA8 pin set to the multiplex push-pull output. This allows you to use PWM, which is the usage of multiplexing.

        Gpio_initstructure.gpio_pin = Gpio_pin_8;
	Gpio_initstructure.gpio_mode = gpio_mode_af_pp;
	Gpio_initstructure.gpio_speed = Gpio_speed_50mhz;

	Gpio_init (Gpioa, &gpio_initstructure);

	Rcc_apb2periphclockcmd (rcc_apb2periph_tim1,enable);	
	/*timer Time Base Set Peripheral clock frequency * * Tim_timebasestructure.tim_period = 240;	
	Tim_timebasestructure.tim_prescaler = 0;
	Tim_timebasestructure.tim_clockdivision = TIM_CKD_DIV1;
	Tim_timebasestructure.tim_countermode = tim_countermode_up;
	Tim_timebasestructure.tim_repetitioncounter = 0;

	Tim_timebaseinit (TIM1, &tim_timebasestructure);
	Tim_ocinitstructure.tim_ocmode = TIM_OCMODE_PWM1;
	tim_ocinitstructure.tim_ocpolarity = Tim_ocpolarity_high;
	tim_ocinitstructure.tim_ocnpolarity = Tim_ocnpolarity_high;
	Tim_ocinitstructure.tim_outputstate = tim_outputstate_enable;
	Tim_ocinitstructure.tim_outputnstate = tim_outputnstate_enable;
	Tim_ocinitstructure.tim_ocidlestate = Tim_ocidlestate_set;
	Tim_ocinitstructure.tim_ocnidlestate = Tim_ocidlestate_reset;Tim_ocinitstructure.tim_pulse = 10; 

	Tim_oc1init (TIM1, &tim_ocinitstructure); 

	Tim_oc1preloadconfig (TIM1, tim_ocpreload_enable);
	
	Tim_arrpreloadconfig (tim1,enable);
Tim_cmd (tim1,enable);  
Well, if I PA8 already used the other. You want to remap it,,,

According to the above figure, only two map partial maps and full mappings if the partial mappings change is the bkin,ch1n,ch2n,ch3n these feet, so you should select a full map to TIM1 pwm-ch1 remapping to PE9 this foot

Gpio_pinremapconfig (gpio_fullremap_tim1,enable);
I do not understand whether you have such a doubt, this will not change the other pins, I would not want to change the other only to change one pin, the result of other pins are also remapping away ....
Regarding this question, my understanding is: For example above picture, if said even CH2 CH3 CH4 also used in the words before that then can not be able to be mapped together to go, also said Ch2=pe11 Ch3=pe13 CH4 The =pe14 can not only only do the mapping one to come over only
That would have no effect if only CH1 were used. PE11 PE13 PE14 as normal IO without having to open the multiplexing function of these pins.


The above is a personal understanding, the wrong place also hope that ...


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.