cancel
Showing results for 
Search instead for 
Did you mean: 

USART2 (RTS-Pin)

jrupprecht9
Associate
Posted on December 16, 2008 at 06:51

USART2 (RTS-Pin)

1 REPLY 1
jrupprecht9
Associate
Posted on May 17, 2011 at 12:56

Hello,

in the first, sorry for my bad english.

I have make a Board wit h the STM32F103R8 and will use the

PA01 as a Input-Pin (Switch) and use the USART2 as 2-Wire about Handshake.

We use the IAR EWARM 5.2 and hthe STM-Lib 2.0

My SW-Application is running without the usart-function. When i include the usart-function is the PA01 fix on high.

my start-function:

Init the GPIOs with GPIO-Clock (PA01 as IN_FLOATING

Init the USART2 with USART-Clock and the GPIO´s TxD und RxD

void Misc_Config(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

// IO-Vorbereitung

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN;

GPIO_Init(GPIOA, &GPIO_InitStructure);

GPIO_Init(GPIOB, &GPIO_InitStructure);

GPIO_Init(GPIOC, &GPIO_InitStructure);

GPIO_Init(GPIOD, &GPIO_InitStructure);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, DISABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |

RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_AFIO, ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

...

// DI_TAST1

GPIO_InitStructure.GPIO_Pin = DI_TAST1;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

GPIO_Init(DI_TAST1_PORT, &GPIO_InitStructure);

// DI_TAST2

GPIO_InitStructure.GPIO_Pin = DI_TAST2;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz;

GPIO_Init(DI_TAST2_PORT, &GPIO_InitStructure);

}

void USART_Config(void)

{

GPIO_InitTypeDef GPIO_InitStructure;

USART_InitTypeDef USART_InitStructure;

// USART init

// USART Deinit

RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);

USART_DeInit(USART2);

GPIO_PinRemapConfig(GPIO_Remap_USART2,DISABLE);

// Initialisiere Portpins

// DO_RS232_TXD

#if DO_RS232_TXD_FUNC == ALTERNATE

GPIO_InitStructure.GPIO_Pin = DO_RS232_TXD;

GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init (DO_RS232_TXD_PORT, &GPIO_InitStructure);

#endif

// DI_RS232_RXD

#if DI_RS232_RXD_FUNC == ALTERNATE

GPIO_InitStructure.GPIO_Pin = DI_RS232_RXD;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init (DI_RS232_RXD_PORT, &GPIO_InitStructure);

#endif

USART_InitStructure.USART_BaudRate = 115200;

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;

// Configure the USART2

USART_Init(USART2, &USART_InitStructure);

// Enable the USART2

USART_Cmd(USART2, ENABLE);

} /* USART_Config */

in Main

// Init clock system

RCC_Configuration();

// NVIC configuration

NVIC_Configuration();

// Config Miscellaneous

Misc_Config();

// Config I2C-Bus

I2C_Config();

// Config USART2

USART_Config();

// External Interrupt Lines

EXTI_Configuration();

// Config AD-Converter

ADC_Config();

When i run the USART-Config goes the PA01 fix to high.

The transmit is ok.

Thanks for the help

best regards

Jörg