cancel
Showing results for 
Search instead for 
Did you mean: 

help with usart peripheral.

saccrue
Associate II
Posted on June 25, 2013 at 02:53

Hello,

I am having some difficulties getting my uart code to work. Can someone please tell me what I am missing? I must have spent too much time looking at it and am missing something very obvious because I have written uart code before. The strange thing is it works inone project but not the other. Is there something else that could be causing a problem that may not besetupsomewhere? Here is my code...

GPIO_InitTypeDef GPIO_InitStructure; 

RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE); 
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE); 
GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE); 
// Configure USART3 Tx (PC.10)as alternate function push-pull 
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); 
/* Configure USART3 Rx PC.11 as input floating */ 
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11; 
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 
GPIO_Init(GPIOC, &GPIO_InitStructure); 
USART_InitTypeDef USART_InitStructure; 
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE); 
/* USART configured as follow: 
- BaudRate = 115200 baud 
- Word Length = 8 Bits 
- One Stop Bit 
- No parity 
- Hardware flow control disabled (RTS and CTS signals) 
- Receive and transmit enabled 
*/ 
USART_InitStructure.USART_BaudRate = 115200; 
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(USART3, &USART_InitStructure); 
USART_Cmd(USART3, ENABLE);

2 REPLIES 2
Posted on June 25, 2013 at 02:58

On the F1 series parts the ReMap will require the AFIO peripheral being clocked.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
saccrue
Associate II
Posted on June 25, 2013 at 04:17

Thank you clive1.