AnsweredAssumed Answered

USART problem

Question asked by xawt on Nov 10, 2011
Latest reply on Nov 21, 2011 by mariano
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);

Outcomes