The relationship between STM32 and re-mapping in discipline

Source: Internet
Author: User
Tags mapr

Excerpt from: http://blog.csdn.net/lincheng15/article/details/51789093

To summarize: Multiplexing is a pin with several functions, 1. Do normal IO input and output 2. Input and output of other peripherals (such as I2C,TIM,SPI, etc.), this is reuse.

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

The default function of PA8 after MCU reset is normal IO pin, I want to set it to TIM1 pwm-ch1 multiplexing output, for example, by setting the tim_remap[1:0] register, there are three mappings (no remapping) (partial remapping) (full remap).

  

  

1 voidTim1_pwm_init (U16 arr,u16 PSC)2 {                              3     //4rcc->apb2enr|=1<< One;//Open TIM1 timer5gpioa->crh&=0xfffffff0;//Clear PA86gpioa->crh|=0x0000000b;//Set PA8 to the maximum 50MHZ multiplexing push-out output mode7     8tim1->arr=arr;//Set counter auto reload value9tim1->psc=psc;//Prescaler settingsTen    Onetim1->ccmr1|=7<<4;//CH1 PWM2 Mode Atim1->ccmr1|=1<<3;//CH1 Pre-load enable -tim1->ccer|=1<<0;//OC1 output Enable -tim1->bdtr|=1<< the;//Moe main output enable the  -tim1->cr1=0x0080;//Arpe Enable -tim1->cr1|=0x01;//Enable timer 1 -}

So if I PA8 have been used for other. If you want to remap it, see

1 //tim1_ch1 PWM multiplexed remap Output2 voidTim1_pwm_init (U16 arr,u16 PSC)3 {                              4rcc->apb2enr|=1<< One;//TIM1 Clock Enable5rcc->apb2enr|=1<<6;//turn on the PE clock (turn on the clock for the pin that you want to remap)6rcc->apb2enr|=1<<0;//turn on the Afio clock7 8gpioe->crh&=0xffffff0f;//PE9 Clear, to be re-mapped pin9gpioe->crh|=0X000000B0;//PE9 set to multiplexed push-out output Max 50MHZTenafio->mapr&=0xffffff3f;//tim1_remap Port Cleanup Oneafio->mapr|=0x000000c0;//Tim1_remap Port multiplexing remapping feature on A      -tim1->arr=arr;//Reload Value -tim1->psc=psc;//Prescaler Value the    -tim1->ccmr1|=7<<4;//CH1 PWM2 Mode -tim1->ccmr1|=1<<3;//CH1 Pre-load enable -tim1->ccer|=1<<0;//OC1 output Enable +tim1->bdtr|=1<< the;//Moe main output enable -  +tim1->cr1=0x0080;//Arpe Enable Atim1->cr1|=0x01;//Enable timer 1 at}

According to only two mappings partial mappings and full mappings if a partial mapping changes the bkin,ch1n,ch2n,ch3n of these feet, you should choose the full mapping to remap the TIM1 pwm-ch1 to the PE9 foot.

On this issue, my understanding is: for example, if said even CH2 CH3 CH4 also used before, then there is no way will be re-mapped away, also said Ch2=pe11 ch3=pe13 CH4 =pe14 No way only to map a come on
That if only uses the CH1 words, that will not have the influence PE11 PE13 PE14 still as normal IO use does not have these several pins the multiplex function to open can be

The relationship between STM32 and re-mapping in discipline

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.