cancel
Showing results for 
Search instead for 
Did you mean: 

USART RTS is high after init

marko239955_stm1_st
Associate II
Posted on November 18, 2014 at 14:33

I have STM32RBT6. After initialisation of USART1, the RTS remains high. The code is as follows: 

/** USART1 GPIO Configuration  

  PA9   ------> USART1_TX

  PA10   ------> USART1_RX

  PA11   ------> USART1_CTS

  PA12   ------> USART1_RTS

  */

GPIO_InitTypeDef GPIO_InitStruct;

USART_InitTypeDef usartinit; 

NVIC_InitTypeDef NVIC_InitStructure;

  /*  System Clocks Configuration */

  /* USART1 clock enable */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);

  /* GPIOA clock enable */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

  /*Enable APB2 peripheral clock */

  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE);

/* Configure USART1 RTS and USART1 Tx as alternate function push-pull */

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_9 | GPIO_Pin_12;

GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_AF_PP;

GPIO_Init(GPIOA, &GPIO_InitStruct);

// Override RTS ToDo:  check for bug in RTS handling !!!!!!!!!!!!!!!!!!!!!!!!!

  GPIO_InitStruct.GPIO_Pin = GPIO_Pin_12;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_Out_PP;

GPIO_Init(GPIOA, &GPIO_InitStruct);

GPIO_ResetBits(GPIOA, GPIO_Pin_12);

/* Configure USART1 CTS and USART1 Rx as input floating */

GPIO_InitStruct.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_10;

GPIO_InitStruct.GPIO_Mode = GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOA, &GPIO_InitStruct);

  /* Configure USART1, 115200 baud, harware flow control, 1 stop bit, no parity */

usartinit.USART_BaudRate = 115200;

usartinit.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;

usartinit.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

usartinit.USART_Parity = USART_Parity_No;

usartinit.USART_StopBits = USART_StopBits_1;

usartinit.USART_WordLength = USART_WordLength_8b;

USART_Init(USART1, &usartinit); 

  USART_Cmd(USART1, ENABLE);

/* Enable USART1 IRQ */

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

  NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;

  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

  NVIC_Init(&NVIC_InitStructure);

USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); // enable IRQ on RX

NVIC_EnableIRQ(USART1_IRQn); // Enable IRQ for USART1 in NVIC 

I am using STM32F10x Standard Peripherals Library 3.5.1

What am I missing?

Regards,

Marko

#stm32-usart-rts-remains-high
2 REPLIES 2
Posted on November 18, 2014 at 18:21

What do you have attached to the pin?

In GPIO mode you should be able to drive up/down.

In AF mode, you might want to double check the errata, seem to recall one of the CTS/RTS grouping clashing with CAN, requiring CAN to be remapped elsewhere.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
marko239955_stm1_st
Associate II
Posted on November 19, 2014 at 00:31

Thank you. The issue is described in errata. CAN must be remapped to alternate location even when not used. 

http://www.st.com/st-web-ui/static/active/en/resource/technical/document/errata_sheet/CD00190234.pdf

Workaround from section 2.8.1:

When USART1_RTS is used, the CAN must be remapped to either another IO configuration 

when the CAN is used, or to the unused configuration (CAN_REMAP[1:0] set to “01�?) when 

the CAN is not used.

Regards,

Marko