There are many USART1 programs. Look at the USART2 program. Pay attention to the red part, we must first enable the clock of the relevant port.
Because USART2 can be mapped to different ports, port mapping is required.
Combine your own development board and set the correct mapping port. (The punctual atom is PA03PA02.)
The default USART2 of STM32F103ZE is PA03PA02. If the mapping is configured, the USART2 port is PD05PD06.
The program is debugged in the punctual atomic development board SRAM, development environment IAR5.30.
Void USART2_IniTIalise( u32 bound )
{
GPIO_InitTypeDef GPIO_InitStructure;//I/O¿ Ú3&oTIlde;ê1â„4»ˉ1â„2á11ìå
NVIC_InitTypeDef NVIC_InitStructure;//ÖD¶Ã3&oTIlde;ê1â„4»ˉ1â„2á11ìå
USART_InitTypeDef USART_InitStructure;//′®¿ Ú3&oTIlde;ê1â„4»ˉ1â„2á11ìå
/* Enable the USART2 Pins Software Remapping */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* Configure USART2 Rx (PA.03) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART2 Tx (PA.02) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Enable the USART2 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_InitStructure.USART_BaudRate = bound; //ò»°ãéèÖÃÎa9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö3¤Îa8λêy3â„4Y ̧ñê1â„2
USART_InitStructure.USART_StopBits = USART_StopBits_1; //ò» ̧öãÖ1λ
USART_InitStructure.USART_Parity = USART_Parity_No; //ÃŽTÆæÅ1â„4D £Ñéλ
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//Yá÷¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx " USART_Mode_Tx;//êÕ·¢Ä£ê1â„2
USART_Init(USART2, &USART_InitStructure);
USART_ITConfig (USART2, USART_IT_RXNE, ENABLE);
//USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
/* Enable USART2 */
USART_Cmd(USART2, ENABLE);
}
Void USART2_IRQHandler(void)
{
If(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == SET)
{
USART_SendData(USART2, USART_ReceiveData(USART2));
}
}
The program function is to return the data you sent to the serial port.
If your USART2 is connected to the PD port, you need to modify the program as below. Here you need the port mapping. The mapping register is controlled by AFIO. It is connected to the APB2 clock area, so the following red code must exist. The blue code must be The port is initialized.
Void USART2_Initialise( u32 bound )
{
GPIO_InitTypeDef GPIO_InitStructure;//I/O¿ Ú3õê1â„4»ˉ1â„2á11ìå
NVIC_InitTypeDef NVIC_InitStructure;//ÖD¶Ã3õê1â„4»ˉ1â„2á11ìå
USART_InitTypeDef USART_InitStructure;//′®¿ Ú3õê1â„4»ˉ1â„2á11ìå
/* Enable the USART2 Pins Software Remapping */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
/* Configure USART2 Rx (PD.06) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOD, & GPIO_InitStructure);
/* Configure USART2 Tx (PD.05) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, & GPIO_InitStructure);
/* Enable the USART2 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_InitStructure.USART_BaudRate = bound;//ò»°ãéèÖÃÎa9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö3¤Îa8λêy3â„4Y ̧ñê1â„2
USART_InitStructure.USART_StopBits = USART_StopBits_1;//ò» ̧öãÖ1λ
USART_InitStructure.USART_Parity = USART_Parity_No;//ÃŽTÆæÅ1â„4D £Ñéλ
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//3â„4Yá÷¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;//êÕ·¢Ä£ê1â„2
USART_Init(USART2, &USART_InitStructure);
USART_ITConfig (USART2, USART_IT_RXNE, ENABLE);
//USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
/* Enable USART2 */
USART_Cmd(USART2, ENABLE);
}
Void USART2_IRQHandler(void)
{
If(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == SET)
{
USART_SendData(USART2, USART_ReceiveData(USART2));
}
}
The program function is to return the data you sent to the serial port.
If your USART2 is connected to the PD port, you need to modify the program as below. Here you need the port mapping. The mapping register is controlled by AFIO. It is connected to the APB2 clock area, so the following red code must exist. The blue code must be The port is initialized.
Void USART2_Initialise( u32 bound )
{
GPIO_InitTypeDef GPIO_InitStructure;//I/O¿ Ú3õê1â„4»ˉ1â„2á11ìå
NVIC_InitTypeDef NVIC_InitStructure;//ÖD¶Ã3õê1â„4»ˉ1â„2á11ìå
USART_InitTypeDef USART_InitStructure;//′®¿ Ú3õê1â„4»ˉ1â„2á11ìå
/* Enable the USART2 Pins Software Remapping */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2,ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
GPIO_PinRemapConfig(GPIO_Remap_USART2, ENABLE);
/* Configure USART2 Rx (PD.06) as input floating */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOD, & GPIO_InitStructure);
/* Configure USART2 Tx (PD.05) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOD, & GPIO_InitStructure);
/* Enable the USART2 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 3;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
USART_InitStructure.USART_BaudRate = bound;//ò»°ãéèÖÃÎa9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b;//×Ö3¤Îa8λêy3â„4Y ̧ñê1â„2
USART_InitStructure.USART_StopBits = USART_StopBits_1;//ò» ̧öãÖ1λ
USART_InitStructure.USART_Parity = USART_Parity_No;//ÃŽTÆæÅ1â„4D £Ñéλ
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;//3â„4Yá÷¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //êÕ·¢Ä£ê1â„2
USART_Init(USART2, &USART_InitStructure);
USART_ITConfig (USART2, USART_IT_RXNE, ENABLE);
//USART_ITConfig(USART2, USART_IT_TXE, ENABLE);
/* Enable USART2 */
USART_Cmd(USART2, ENABLE);
}
Void USART2_IRQHandler(void)
{
If(USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == SET)
{
USART_SendData(USART2, USART_ReceiveData(USART2));
}
}
600Mbps Wireless-wifi Repeater
About this item
1. Ideal for boosting existing network to hard-to reach area, delivering fast and stable wireless connection, transfer rate up to 600Mbps
2. Repeater/AP modes for extending wifi or create wifi hotspot, watch video on line, play games, online shopping without interference
3. Activate passion for your life, mobile devices at full signal, wall mounted design flexible to place and 7 steps to finish setup
4. Designed with mobility and portability, little gadget with great value, One-touch wireless security encryption with WPS button
5. Ethernet port allows the Extender to function as a wireless adapter to connect wired devices, Compatible with 802.11n/g/b devices
2 Working Modes:(Select
based on your needs)
Repeater Mode
Plug WiFi Booster into your power
socket, easily expand your existing WiFi coverage to signal dead zones
Access Point Mode
Connect your router signal with
Ethernet Cable, cover a wired network to a wireless access point.
600Mbps Wireless-Wifi Repeater,Wifi Amplifier,Wireless Extender,Wifi Booster For Home
Shenzhen Jinziming Electronic Technology Co.,LTD , https://www.powerchargerusb.com