There are many USART1 programs, take a look at the USART2 program. Pay attention to the red part, 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, 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 SRAM of the punctual atomic development board, and the development environment is IAR5.30.
void USART2_IniTIalise (u32 bound)
{
GPIO_InitTypeDef GPIO_InitStructure; // I / O¿ ú3 & oTIlde; ê¼ »ˉ½á11ìå
NVIC_InitTypeDef NVIC_InitStructure; // ÖD¶Ã3 & oTIlde; ê¼ »ˉ½á11ìå
USART_InitTypeDef USART_InitStructure; // ′ ®¿ ú3 & oTIlde; ê¼ »ˉ½á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Î »êy¾Y¸ñê½
USART_InitStructure.USART_StopBits = USART_StopBits_1; // ò »¸öà £ Ö1λ
USART_InitStructure.USART_Parity = USART_Parity_No; // ÎTÆæżD £ ÑéÎ »
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // Yá ÷ ¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx "USART_Mode_Tx; // êÕ · ï¿ Ã„ ï¿¡ ê½
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 function of this program 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 follows, here you need to map the port, the mapping register is controlled by AFIO, it is connected to the APB2 clock area, so the red code below must have, the blue code The port is initialized.
void USART2_Initialise (u32 bound)
{
GPIO_InitTypeDef GPIO_InitStructure; // I / O¿ ú3õê¼ »ˉ½á11ìå
NVIC_InitTypeDef NVIC_InitStructure; // ÖD¶Ã3õê¼ »ˉ½á11ìå
USART_InitTypeDef USART_InitStructure; // ′ ®¿ ú3õê¼ »ˉ½á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Î »êy¾Y¸ñê½
USART_InitStructure.USART_StopBits = USART_StopBits_1; // ò »¸öà £ Ö1λ
USART_InitStructure.USART_Parity = USART_Parity_No; // ÎTÆæżD £ ÑéÎ »
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // ¾Yá ÷ ¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // êÕ · ï¿ Ã„ ï¿¡ ê½
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 function of this program 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 follows, here you need to map the port, the mapping register is controlled by AFIO, it is connected to the APB2 clock area, so the red code below must have, the blue code The port is initialized.
void USART2_Initialise (u32 bound)
{
GPIO_InitTypeDef GPIO_InitStructure; // I / O¿ ú3õê¼ »ˉ½á11ìå
NVIC_InitTypeDef NVIC_InitStructure; // ÖD¶Ã3õê¼ »ˉ½á11ìå
USART_InitTypeDef USART_InitStructure; // ′ ®¿ ú3õê¼ »ˉ½á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Î »êy¾Y¸ñê½
USART_InitStructure.USART_StopBits = USART_StopBits_1; // ò »¸öà £ Ö1λ
USART_InitStructure.USART_Parity = USART_Parity_No; // ÎTÆæżD £ ÑéÎ »
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; // ¾Yá ÷ ¿ ØÖÆ
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; // êÕ · ï¿ Ã„ ï¿¡ ê½
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));
}
}
What`s your impression for Intel I3 Laptop? You can take i3 Laptop Deals as the entry level of Gaming Laptop . There are different parameters standards,like 14 Inch Laptop I3 11th Generation, 14inch 256GB Intel I5 11th Generation Laptop, 14.1 inch Intel i7 11th Generation Laptop, 15.6 inch I3 10th Generation Laptop,15 inch Intel I5 10th Generation Laptop, 15inch Intel i7 11th Generation Laptop, etc. That`s some of Top 10 Gaming Laptops. To operating OS, more than 80% clients choose windows 10, home or pro option; nowadays windows 11 is new arrival, you can choose as your demand. Rich slots meet your different potential application scenarios, home, office, public places, academic situations, etc.
Dual storage channels, support HDD and SSD. Your customers can update in future according potential demands.
Of course, other type, like yoga notebook, 2 In 1 Laptop , Android Tablet, Custom All In One PC , 14 inch Student Laptop, i7 16gb ram 4gb graphics laptop, etc. available here also. Just call us and get right details quickly.
Intel I3 Laptop,Laptop I3 11th Generation,i3 10th Generation Laptop,i3 Laptop Deals,Laptop Intel Core I3 Gen 11
Henan Shuyi Electronics Co., Ltd. , https://www.shuyioemelectronics.com