/var/www/restricted/ssh/stm32/www/stm32circle/ STM CircleOS forum / USART2

Username:     
Password:     
             

Forum

# 1   2009-05-21 07:28:44 USART2

pitu82
Member
Registered: 2009-03-07
Posts: 14

USART2

Hi,
I am some how been unable to configure the USART2 peripheral. Here is the code

#include "ut2.h"
#include "stm32f10x_usart.h"
#include "stm32f10x_conf.h"
#include "stm32f10x_lib.h"
#include "circle_api.h"
#include "stm32f10x_map.h"



void InitUSART(void)
{

  GPIO_InitTypeDef GPIO_InitStructure;
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, DISABLE);
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);


  /* Configure USART2 Tx (PA.2) as alternate function push-pull */
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
  GPIO_Init(GPIOA, &GPIO_InitStructure);

/* Enable USART2 clocks */




   
  /* USART2 configuration ------------------------------------------------------*/
  /* USART2 configured as follow:
        - BaudRate = 9600 baud 
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
        - USART Clock disabled
        - USART CPOL: Clock is active low
        - USART CPHA: Data is captured on the second edge
        - USART LastBit: The clock pulse of the last data bit is not output to
                         the SCLK pin
  */
  USART_InitTypeDef USART_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_Tx;
 
  USART_Init(USART2, &USART_InitStructure);

  /* Enable the USART2 */
  USART_Cmd(USART2, ENABLE); 

}

I get the error USART2 undeclared first use in the function . Can anyone help me please?

Offline

 

# 2   2009-05-21 10:52:53 USART2

Saulis
Member
From: Lithuania
Registered: 2009-04-09
Posts: 34

Re: USART2

it has simple solution, check stm32f10x_conf.h in projrct directory and uncomment lines uart and uart2.

Offline

 

# 3   2009-05-21 12:39:11 USART2

pitu82
Member
Registered: 2009-03-07
Posts: 14

Re: USART2

thanks mate

Offline

 

Board footer