AnsweredAssumed Answered

USART (or Serial) trhough ST-Link/V2 for Nucleo STM32L152RE

Question asked by Janis on Dec 23, 2014
Latest reply on Dec 30, 2014 by Clive One

Can someone share example and/or point to useful resources to learn USART communication through ST-Link/v2 for ST Nucleo L152RE? I'm trying to learn stm32 basics using only C and Standard Peripheral Library.
The sample available on mbed.org for download works but is not particularity illuminating on the actual things happening behind the scenes.
Thank you!
Here is the most basic thing I have from tutorials for other boards

#include "stm32l1xx_usart.h"
  
void USART2_Configuration(void)
{
  USART_InitTypeDef USART_InitStructure;
  
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
     
  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(USART2, &USART_InitStructure);
  
  USART_Cmd(USART2, ENABLE);
}
  
int main(void)
{
     
    int time;
     
    USART2_Configuration();
     
    while (1)
    {
        USART_SendData(USART2, 2);
        for(time = 0; time < 100000; time++);
    }
}

Outcomes