AnsweredAssumed Answered

USART RTS is high after init

Question asked by pavlin.marko.001 on Nov 18, 2014
Latest reply on Nov 19, 2014 by pavlin.marko.001
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

Outcomes