| Electronic Components Datasheet Search |
|
AN4088 Datasheet(PDF) 47 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN4088 Datasheet(HTML) 47 Page - STMicroelectronics |
|
47 / 71 page ![]() DocID023072 Rev 3 47/71 AN4088 Firmware migration using the library 70 functions for different device packages; for example, the USART2_RX pin can be mapped on PA3 or PA15 pin. 4. Configuration procedure: – Connect the pin to the desired peripherals' Alternate Function (AF) using GPIO_PinAFConfig() function – Use GPIO_Init() function to configure the I/O pin: - Configure the desired pin in alternate function mode using GPIO_InitStructure->GPIO_Mode = GPIO_Mode_AF; - Select the type, pull-up/pull-down and output speed via GPIO_PuPd, GPIO_OType and GPIO_Speed members The example below shows how to remap USART2 Tx/Rx I/Os on PD5/PD6 pins in STM32F1 series: /* Enable APB2 interface clock for GPIOD and AFIO (AFIO peripheral is used to configure the I/Os software remapping) */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE); /* Enable USART2 I/Os software remapping [(USART2_Tx,USART2_Rx):(PD5,PD6)] */ GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE); /* Configure USART2_Tx as alternate function push-pull */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOD, &GPIO_InitStructure); /* Configure USART2_Rx as input floating */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; GPIO_Init(GPIOD, &GPIO_InitStructure); In STM32F0 series, you have to update this code as follows: /* Enable GPIOA's AHB interface clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE); /* Select USART2 I/Os mapping on PA14/15 pins [(USART2_TX,USART2_RX):(PA.14,PA.15)] */ /* Connect PA14 to USART2_Tx */ GPIO_PinAFConfig(GPIOA, GPIO_PinSource14, GPIO_AF_2); /* Connect PA15 to USART2_Rx*/ GPIO_PinAFConfig(GPIOA, GPIO_PinSource15, GPIO_AF_2); /* Configure USART2_Tx and USART2_Rx as alternate function */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; |
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |