Should USARTx->BRR have to re-calculate ?
Hi,
Now I'm trying to implement UART function as the below,
But the problem is keep showing in RS232 Tool.
I'm just referring fully reference posting such as
https://community.st.com/thread/19577?commentID=48791#comment
There's no miss match. But I don't know what is the problem and how to resolve this.
Could you please any advice to resolve this problem?
I guess one thing is there's noUSARTx->BRR declaration.
Is this possible way to happen the problem??
USART_InitTypeDef USART_InitStructure; int putcharx(int ch)
{ while (USART_GetFlagStatus(USART1, USART_FLAG_TXE) == RESET); USART_SendData(USART1, (uint8_t)ch); return ch; } int main(void) { RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
//UART////////////////////////////////////////////////////////////////////////
/*-------------------------- GPIO Configuration ----------------------------*/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_10; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOA, &GPIO_InitStructure);/* Connect USART pins to AF */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource9, GPIO_AF_USART1); // USART1_TX GPIO_PinAFConfig(GPIOA, GPIO_PinSource10, GPIO_AF_USART1); // USART1_RXUSART_InitStructure.USART_BaudRate = 9600;
USART_InitStructure.USART_WordLength = USART_WordLength_8b; USART_InitStructure.USART_StopBits = USART_StopBits_1; USART_InitStructure.USART_Parity = USART_Parity_No; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART1, &USART_InitStructure);
USART_Cmd(USART1, ENABLE);
/////////////////////////////////////////////////////////////////////////////////
while (1) { USART_SendData(USART1, 0x49); // Send 'I' //TEST 2}
In case TEST 1 and TEST2 have the same output result as the below image.
What am I supposed to do to resolve this problem?
should I have to calculate about
USARTx->BRR
? Note: this post was migrated and contained many threaded conversations, some content may be missing.