AnsweredAssumed Answered

Uart output not coming as desired

Question asked by GOPALAKRISHNAN THANASEKARAN on May 28, 2018
Latest reply on May 28, 2018 by Clive Two.Zero

Hi,  am using STM32F103C8T6, I wrote code with keil for uart1 for the tx pin PA9 and rx pin PA10, am just sending a character repeatedly, but I didn't receive the character what I am sending, I am using CP2102 device between my controller and my PC. I will show my code, and my output , so kindly suggest me the solution.

 

#include <stm32f10x.h>

void SendChar (unsigned char ch);

static __IO uint32_t TimingDelay;

void Delay_Us(uint32_t nTime);

void Delay_Ms(uint32_t ms);

void SysTick_Handler(void);

void DelayInit(void);

void main()
{
int i=0;
SystemInit();
DelayInit();

RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; 
GPIOA->CRH = (0x0AUL << 4); 
GPIOA->CRH |= (0x04UL << 8); 
RCC->APB2ENR |= RCC_APB2ENR_USART1EN;
USART1->BRR = 8000000L/9600L; 
USART1->CR1 |= (USART_CR1_RE | USART_CR1_TE); 
USART1->CR1 |= USART_CR1_UE;

while(1)
{
SendChar('A');
Delay_Ms(250);
}

}

void SendChar (unsigned char ch) {
while (!(USART1->SR & USART_SR_TXE));
USART1->DR = ch ;

}

 

 

void Delay_Us(uint32_t nTime){

TimingDelay = nTime;

while(TimingDelay != 0);

}

void Delay_Ms(uint32_t ms)
{
while (ms--)
{
Delay_Us(1000);
}
}

void SysTick_Handler(void){

if (TimingDelay != 0x00)

TimingDelay --;

}

void DelayInit(void)
{
// Update SystemCoreClock value
SystemCoreClockUpdate();
// Configure the SysTick timer to overflow every 1 us
SysTick_Config(SystemCoreClock / 1000000);

 

OUTPUT:
}

Outcomes