cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F105RC UART problem

andycc.wei9
Associate
Posted on October 03, 2015 at 04:20

Hi, I'm currently working with STM32F105RC chip and trying to use UART4 (PC10 and PC11), which connects to a USB to UART module to a computer. The problem is, I'm not getting any readings from PC using hyperterminal.

/******** Declare USART�?GPIO structure ********/
GPIO_InitTypeDef GPIO_InitStructure;
USART_InitTypeDef USART_InitStructure;
/******** Activate GPIOC�?UART4 RCC clock ********/
//RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC|RCC_APB2Periph_USART1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); //clock a PORTC
RCC_APB2PeriphClockCmd(RCC_APB1Periph_UART4, ENABLE); //clock alla UART4!
/******** Setup PC10 for Tx ********/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_10;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure); // Initialize PC10
/******** Setup PC11 for Rx ********/
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_Init(GPIOC, &GPIO_InitStructure); // Initialize PC11
/******** USART parameter ********/
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(UART4, &USART_InitStructure); // Initialize UART4
USART_Cmd(UART4, ENABLE); // Activate USART4
USART_SendData(UART4, 'a'); // Send data

#stm32f105rc #uart
0 REPLIES 0