AnsweredAssumed Answered

Should USARTx->BRR have to re-calculate ?

Question asked by Carter Lee on Sep 11, 2017
Latest reply on Sep 12, 2017 by Carter Lee

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/message/48791?commentID=48791#comment-48791 

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 no USARTx->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_RX

 

USART_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?

 

 

 

Outcomes