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

surendran_raj

Junior Member level 1
Junior Member level 1
Joined
Aug 8, 2022
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
172
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;

}
 

KlausST

Super Moderator
Staff member
Advanced Member level 7
Joined
Apr 17, 2014
Messages
23,261
Helped
4,741
Reputation
9,503
Reaction score
5,126
Trophy points
1,393
Activity points
154,093
Hi,

Variable "receive" is never used.

I don't dive deeply into uncommented code.

Klaus
 

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top