cancel
Showing results for 
Search instead for 
Did you mean: 

USART Hardware Handshaking

mvi
Associate II
Posted on May 02, 2008 at 18:37

USART Hardware Handshaking

4 REPLIES 4
mvi
Associate II
Posted on May 17, 2011 at 12:34

Hello!

Can someone tell me whether I should take care of any special events on the ISR when the Hardware Handshaking (RTS/CTS) is enabled on a USART?

Or is this automatically done by the hardware, and the data sending or receiving automatically stalled so that an interrupt is not set off?

Code:

if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) {

USART_ClearITPendingBit(USART3, USART_IT_RXNE);

}

if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET) {

USART_ClearITPendingBit(USART3, USART_IT_TXE);

}

-Mad D

mvi
Associate II
Posted on May 17, 2011 at 12:34

Hi again!

I checked the USART example1, looks like its automatically taken care of... Am I correct?

mvi
Associate II
Posted on May 17, 2011 at 12:34

Hello yet again!

As I have mentioned. Im trying to get the USART working with the CTS/RTS signals for flow control.

I have managed to get the receiption working with no extra coding needed than when using it without the CTS/RTS signals. But the TX doesnt seem to be working right.

1) I have verified that the ISR for TX is called.

2) I checked the RX and TX pins, and RX is high where as TX is low.

3) The RTS/CTS pins are both low.

Code:

<BR>void USART_Config_Default(void) { <BR> // USART3 default configuration <BR> /* USART3 configured as follow: <BR> - BaudRate = 115200 baud <BR> - Word Length = 8 Bits <BR> - One Stop Bit <BR> - No parity <BR> - Hardware flow control enabled (RTS and CTS signals) <BR> - Receive and transmit enabled <BR> - USART Clock disabled <BR> - USART CPOL: Clock is active low <BR> - USART CPHA: Data is captured on the second edge <BR> - USART LastBit: The clock pulse of the last data bit is not output to the SCLK pin <BR> */ <BR> USART_InitStructure.USART_BaudRate = 115200; <BR> USART_InitStructure.USART_WordLength = USART_WordLength_8b; <BR> USART_InitStructure.USART_StopBits = USART_StopBits_1; <BR> USART_InitStructure.USART_Parity = USART_Parity_No; <BR> USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_RTS_CTS; <BR> USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; <BR> USART_InitStructure.USART_Clock = USART_Clock_Disable; <BR> USART_InitStructure.USART_CPOL = USART_CPOL_Low; <BR> USART_InitStructure.USART_CPHA = USART_CPHA_2Edge; <BR> USART_InitStructure.USART_LastBit = USART_LastBit_Disable; <BR> <BR> /* Configure the USART3 */ <BR> USART_Init(USART3, &USART_InitStructure); <BR> <BR> /* Enable the USART Receive interrupt: this interrupt is generated when the USART3 receive data register is not empty */ <BR> USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); <BR> <BR> /* Enable USART3 */ <BR> USART_Cmd(USART3, ENABLE); <BR>} <BR> <BR>void USART3_IRQHandler(void) { <BR> // Transmit Data Register Empty. New data can be copied for transmission. <BR> if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET) { <BR> if (!GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_7)) { <BR> GPIO_SetBits(GPIOA, GPIO_Pin_7); <BR> } <BR> else { <BR> GPIO_ResetBits(GPIOA, GPIO_Pin_7); <BR> } <BR> <BR> if (bTXReadCount < bTXWriteCount) { <BR> if (!GPIO_ReadInputDataBit(GPIOB, GPIO_Pin_13)) { <BR> // Write one byte to the transmit data register. <BR> USART_SendData(USART3, bTXBuffer[bTXReadCount++]); <BR> } <BR> } <BR> else { <BR> // Disable the USART3 Transmit interrupt. <BR> USART_ITConfig(USART3, USART_IT_TXE, DISABLE); <BR> // Reset the indexes. <BR> bTXReadCount = 0; <BR> bTXWriteCount = 0; <BR> // Enable USB endpoint for receiption. <BR> SetEPRxValid(ENDP3); <BR> } <BR> <BR> // Clear the USART3 transmit interrupt. <BR> USART_ClearITPendingBit(USART3, USART_IT_TXE); <BR> } <BR>} <BR>

Any suggestions?

-Mad D

[ This message was edited by: mvi on 02-05-2008 21:52 ]

[ This message was edited by: mvi on 02-05-2008 21:58 ]

mvi
Associate II
Posted on May 17, 2011 at 12:34

Fixed it!

The Rx and Tx init was flipped!!! So Tx was a input acting like pin at high impedance! 🙂