AnsweredAssumed Answered

UART receiving data fail issue

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

HI.

I'm trying to test with simple UART as the below code,

I connect with RS232's TXD to GPIO_Pin_10 and RS232's RXD to GPIO_Pin_9.

There is no problem RS232 kit, but I can't receive data correctly from kit.

I always receive data '00'. I don't know what am I supposed to resolve this problem.

 

 

GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;

 

 

int main(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE );

 

 

//UART 
//TX
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
//RX
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_Init(GPIOA, &GPIO_InitStructure);

 

// UART Port
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,'c');

}
}

 

 

I can receive the '00' data , when I push the reset button in stm32F429 kit.

 

 

Would you please let me know what am I missing ?

Outcomes