Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[ARM] STM32-UART-single-wire-half-duplex-communication

Status
Not open for further replies.

surendran_raj

Junior Member level 2
Joined
Aug 8, 2022
Messages
23
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
235
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
USART3.PNG

USART3_1.PNG


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;

}
 

Hi,

Variable "receive" is never used.

I don't dive deeply into uncommented code.

Klaus
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top