2015-03-16 04:02 AM
Hi
Can anybody say me how to configure for USARt half duplex in stm32l15cb . I have configured as I configured for stm32f030(working USART half duplex) but it did not work what are the changes between stm32f030 and stm32l15cb2015-03-16 09:16 AM
@verbatim
===============================================================================
##### Half-duplex mode function #####
===============================================================================
[..] This subsection provides a set of functions allowing to manage the USART
Half-duplex communication.
[..] The USART can be configured to follow a single-wire half-duplex protocol
where the TX and RX lines are internally connected.
[..] USART Half duplex communication is possible through the following procedure:
(#) Program the Baud rate, Word length, Stop bits, Parity, Mode transmitter
or Mode receiver and hardware flow control values using the USART_Init()
function.
(#) Configures the USART address using the USART_SetAddress() function.
(#) Enable the USART using the USART_Cmd() function.
(#) Enable the half duplex mode using USART_HalfDuplexCmd() function.
-@- The RX pin is no longer used.
-@- In Half-duplex mode the following bits must be kept cleared:
(+@) LINEN and CLKEN bits in the USART_CR2 register.
(+@) SCEN and IREN bits in the USART_CR3 register.
@endverbatim
Assume there isn't an army of people to collate that for you, present a clean/clear/concise example of where you have the half-duplex code for the L1 now, and describe how it doesn't work. ie what you've tested, what you expected, and what you saw on a scope.
2015-03-27 06:44 AM
I have configure as u suggested but still toggling doesn't happen between transmit and receives.
I have done the configuration in the following away USART_InitStructure.USART_BaudRate = 9600; 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_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; USART_Init(USART1, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); USART_Cmd(USART1, ENABLE); USART_HalfDuplexCmd(USART1, ENABLE); USART1->CR2 &=0XB7FF; // bit 11 and bit 14 must be clear CLKEN and LINEN bit USART1->CR3 &=0XFFBD; // bit 1 and 5 clear IREN and SCEN /* Enable the USARTx Interrupt */ NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 11; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure); But still not working WHat wrong I am doing . I didn't understand set adress do I need to configure it ? I am having a two board half duplex communication2015-03-27 09:22 AM
But still not working what wrong I am doing.
You'll need to create some clean unit tests. It might not be a configuration issue, you might have to manage the transition back and forth. Or find some people with direct half-duplex, smart-card or RS485 type, implementations on the L1 platform. Pick a board others might have, like an L1-DISCO.2015-04-01 03:23 AM
2015-04-01 09:53 PM
Any idea
2015-11-11 06:41 AM
2015-11-11 01:07 PM
In half duplex you must wait for the final TX byte to shift out completely before turning around the line to receive. After the last byte is sent disable the TXE interrupt, but enable TC interrupt, not RXNE. After the TC interrupt occurs disable it and then enable RXNE. That extra gap in time allows the last byte to finish.
UARTs are buffered. Writing to TX does not mean the byte has arrived at the destination, only that it's queued to be sent. That's why the TC interrupt is necessary. Jack Peacock2015-11-13 08:44 AM
Thank you very much for your answer!
But I am receiving before transmitting and I am using Polling method! So, I poll and receive the data, even the last byte. After that, I switch to Transmitting. However, I am unable to transmit the data. Is it possible to do all this using polling method with the HAL drivers?