cancel
Showing results for 
Search instead for 
Did you mean: 

USART problem

jaroslaw2399
Associate
Posted on November 10, 2011 at 10:21

Hi,

I wrote the code for the USART3 initialization and it does not work (cannot see anything on the scope while sending data). Can you tell me if I am doing something wrong?

//configure clock for USART

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);

//configure clock for GPIO

RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

//configure AF

GPIO_PinAFConfig(GPIOD,GPIO_Pin_8,GPIO_AF_USART3);

GPIO_PinAFConfig(GPIOD,GPIO_Pin_9,GPIO_AF_USART3);

//configure ports, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;

GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_Init(GPIOD, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9;

GPIO_Init(GPIOD, &GPIO_InitStructure);

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(USART3, &USART_InitStructure);

/* Enable USART */

//USART_Cmd(USART3, ENABLE);
2 REPLIES 2
Posted on November 10, 2011 at 22:08

GPIO_PinAFConfig(GPIOD,GPIO_PinSource8,GPIO_AF_USART3);

GPIO_PinAFConfig(GPIOD,GPIO_PinSource9,GPIO_AF_USART3);

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
mfilippa77
Associate
Posted on November 21, 2011 at 00:14

@clive1

Spent a couple of hours troubleshooting this... wish I found this post a couple of hours ago.