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

Username:     
Password:     
             

Forum

# 1   2012-05-01 17:42:16 USART2 Flow Contorl

j74155
New member
Registered: 2012-05-01
Posts: 1

USART2 Flow Contorl

Working with STM32L151 chip and trying to get comm port flow control working.  I am sure that it somehting that I am not setting up correctly.
Below is how I have configured the USART and GPIO lines:
void    UsartStm32L_Setup ( uint8_t channelNum, uint32_t baudRate )
{
    USART_InitTypeDef   USART_InitStructure;
    USART_CHAN_DEF * usartChanCntrl = (USART_CHAN_DEF *) & UsartChannelCntrl [ channelNum ];
   
    UsartStm32L_ConfigRCC ( channelNum );                

    UsartStm32L_ConfigIOPins ( channelNum );   
   
    // Baud rate
    USART_InitStructure.USART_BaudRate = baudRate;  // Faster part (new)
    // Data bits = 8
    USART_InitStructure.USART_WordLength = USART_WordLength_8b;
    // Stop bits = 1
    USART_InitStructure.USART_StopBits = USART_StopBits_1;
    // Parity = None
    USART_InitStructure.USART_Parity = USART_Parity_No;

    if ( channelNum == USART_CHANNEL_2 )    // hjvtest hjv test
    {    // hjvtest hjv test
        USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS;    // hjvtest hjv test
    }    // hjvtest hjv test
    else    // hjvtest hjv test
    {    // hjvtest hjv test
    // HW Flow Control = None
    USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
    }    // hjvtest hjv test

    // RX + TX
    USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;

    // Set USART parms:
    USART_Init ( usartChanCntrl->chanName, & USART_InitStructure );

    UsartStm32L_NVIC_Init ( channelNum );
   
    // Enable Receive interrupt:
    USART_ITConfig ( usartChanCntrl->chanName, USART_IT_RXNE, ENABLE );
   
    USART_ClearITPendingBit ( usartChanCntrl->chanName, USART_IT_RXNE );

    // Note: TXE IRQ will be enabled later in runtime code as needed...

    // Enable USART (make active now)
    USART_Cmd ( usartChanCntrl->chanName, ENABLE );
}
/*******************************************************************************
void    CommPort_SetupCtsRtsLine ( void )
{
    GPIO_InitTypeDef GPIO_InitStructure;

    // Enable GPIO Periph bus clock.
    RCC_AHBPeriphClockCmd ( RCC_AHBPeriph_GPIOA, ENABLE );

    /* Configure USART2 RTS and USART2 Tx as alternate function push-pull */
    GPIO_InitStructure.GPIO_Pin = COMM_PORT_RTS_PIN_NAME | USART2_TXD_PIN_NAME;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
    GPIO_Init(USART2_PORT_NAME, &GPIO_InitStructure);

    /* Configure USART2 CTS and USART2 Rx as input floating */
    GPIO_InitStructure.GPIO_Pin = COMM_PORT_CTS_PIN_NAME | USART2_RXD_PIN_NAME;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
    GPIO_Init(USART2_PORT_NAME, &GPIO_InitStructure);
}
/************************************************************************/

I hope that someone can tell me what I am doing wrong or what more that I need to do?

Offline

 

Board footer