AnsweredAssumed Answered


Question asked by daou.hisham on Oct 24, 2014
Latest reply on Oct 24, 2014 by daou.hisham
I am new to the ARM development coming from a background of 8051, PIC and some AVR.
With my first new test I managed to make input and output work, also I have manage to direct EXTI on input pins.
Now I am trying the USART on the STEVAL-IDB002V1 and so far I am hitting a dead end. No matter how many codes I have tried something is not write and the USART does not work. I might have been missing something, maybe someone here can direct me to it.
I have connectec the STEVAL to an FTDI chip and I am trying to read the data from my pc, so far it is not working at all. The pins from the STEVAL J1.15 J1.17
Here is my full code, thanks for any help.
#include "stm32l1xx.h"
#include "stm32l1xx_conf.h"
void InitializeUSART()
    USART_InitTypeDef usartConfig;
    RCC_APB2PeriphClockCmd(RCC_APB1Periph_USART2 |
                           RCC_AHBPeriph_GPIOA , ENABLE);
    usartConfig.USART_BaudRate = 9600;
    usartConfig.USART_WordLength = USART_WordLength_8b;
    usartConfig.USART_StopBits = USART_StopBits_1;
    usartConfig.USART_Parity = USART_Parity_No;
    usartConfig.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
    usartConfig.USART_HardwareFlowControl =
    USART_Init(USART2, &usartConfig);
    GPIO_InitTypeDef gpioConfig;
    //PA2 = USART2.TX => Alternative Function Output
    gpioConfig.GPIO_Mode = GPIO_Mode_AF;
    gpioConfig.GPIO_Pin = GPIO_Pin_2;
    gpioConfig.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_Init(GPIOA, &gpioConfig);
    //PA3 = USART2.RX => Input
    gpioConfig.GPIO_Mode = GPIO_Mode_AF;
    gpioConfig.GPIO_Pin = GPIO_Pin_3;
    GPIO_Init(GPIOA, &gpioConfig);
unsigned char USART_ReadByteSync(USART_TypeDef *USARTx)
    while ((USARTx->SR & USART_SR_RXNE) == 0)
    return (unsigned char)USART_ReceiveData(USARTx);
int main()
    for (;;)
         USART_SendData(USART2, 0x56);
     USART2->DR = (0x56 & (uint16_t)0x01FF);
   //  unsigned char byte = USART_ReadByteSync(USART2);