AnsweredAssumed Answered

stm32f2xx USART RTS/CTS

Question asked by ice111 on Jun 28, 2013
Latest reply on Sep 11, 2015 by bigden.gary
May I know how can I configure my STM32F205 microcontroler for USART RTS/CTS???

I could not find any resource on the net, and my codes are below but it doesnt work:

anyone can help me to configure the CTS/RTS UART configuration thanks!!!

           // Enable GPIO clock
            RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOA, ENABLE);
    // Enable USART2 clock
    RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
 
            GPIO_InitTypeDef GPIO_InitStructure;
             
            // Connect USART pins to AF7               
            GPIO_PinAFConfig(GPIOA, GPIO_PinSource0, GPIO_AF_USART2);
            GPIO_PinAFConfig(GPIOA, GPIO_PinSource1, GPIO_AF_USART2);
            GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_USART2);
            GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_USART2);               
 
            // Configure USART Tx and Rx as alternate function push-pull
            GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
            GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
            GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
            GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3;        //USART Tx
            GPIO_Init(GPIOA, &GPIO_InitStructure);    
 
            //GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_0;      
            //GPIO_Init(GPIOA, &GPIO_InitStructure);
            //GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;      
            GPIO_Init(GPIOA, &GPIO_InitStructure);  
             
            GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;      
            GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
            GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
            GPIO_Init(GPIOA, &GPIO_InitStructure);   
 
            // UART2
    NVIC_InitTypeDef NVIC_InitStructure;
     
    // Enable the USARTz Interrupt
    NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0x4;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
 
    USART_InitTypeDef USART_InitStructure;
    USART_StructInit(&USART_InitStructure);
USART_InitStructure.USART_BaudRate = baudrate;
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_RTS_CTS;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
USART_Init(USART2, &USART_InitStructure);
 
   /* Enable USART2 Receive interrupts */
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
 
/* Enable the USART2 */
USART_Cmd(USART2, ENABLE);

Outcomes