surendran_raj
Junior Member level 1

I tried to make Single-wire half-duplex communication in UART using the STM32F103C8 controller. in single-wire half-duplex communication, a TX pin is used for transmitting and receiving the data. I had configured the pins and register with the help of a datasheet(reference manual for STM32F103C8). so I tried to transmit the data from one bluepill board(STM32F103C8) and to receive the data in another bluepill board(STM32F103C8). But I can't able to transmit and receive data. I have enclosed my code. Can anyone help me to solve it? I have used the register for the code.
Communication: USART3
Pins: PB10-TX, PB11-RX
STM32 reference manual
here is my code
Communication: USART3
Pins: PB10-TX, PB11-RX
STM32 reference manual
here is my code
Code:
#include<stm32f10x.h>
char receive;
void USART3_init(void)
{
RCC->APB1ENR |= RCC_APB1ENR_USART3EN ;
USART3->BRR = 0x0EA6; //0x1D4C //0x0EA6
USART3->CR3 |= USART_CR3_HDSEL;
USART3->CR1 |= USART_CR1_RE | USART_CR1_RXNEIE;
USART3->CR1 |= USART_CR1_TE | USART_CR1_TXEIE;
USART3->CR1 |= USART_CR1_TCIE;
USART3->CR1 |= USART_CR1_UE;
NVIC_EnableIRQ(USART3_IRQn);
}
int main()
{
RCC->APB2ENR |= RCC_APB2ENR_IOPBEN | RCC_APB2ENR_AFIOEN;
GPIOB->CRH = 0x00000F00;
USART3_init();
while(1)
{
}
}
void USART3_IRQHandler(void)
{
USART3->DR = data;
while((USART3->SR & USART_SR_TC) !=USART_SR_TC);
USART3->SR &= ~USART_SR_TC;
}