keil - Serial communication problem on stm32f103c8 (Proteus) - Stack Overflow

admin2025-05-01  0

i'm learning stm32f103 programming and i tried using the USART1. this is my code but when i test it on proteus it doesn't show anything. i've checked and it seems to not shift the data at all. i use keil as IDE and compiler. I dont know if is it the code or proteus itself.

#include <stm32f10x.h>
int main(void)
{
    RCC->APB2ENR |= (RCC_APB2ENR_IOPAEN | RCC_APB2ENR_USART1EN);
    GPIOA->ODR |= (1<<10); //pull-up resistor
    GPIOA->CRH = 0x444448B4;
    USART1->BRR = 72000000UL/9600;
    USART1->CR1 = USART_CR1_TE | USART_CR1_UE;
    while(!(USART1->SR & USART_SR_TXE));
    USART1->DR = 'H';
    while(1);
}

i tried using "stm32f10x_usart.h" library but it didn't make any difference

in proteus I connect the RX pin of virtual terminal to PA9 and TX pin to PA10

转载请注明原文地址:http://anycun.com/QandA/1746113610a91857.html