Hi there, I am now using stm32f103rc processor (before I used stm32f103rb to have some practices), I want to send a string such as "hello world" but I can't send it. The TC (transmission complete flag ) is not triggered. I am using Keil uvision 4 and I try to send the data using simulator.
I have a retarget file and my source code is below.
#include <stm32f10x.h> #include <stdio.h> int SER_PutChar (int c) { while (!(USART1-> SR & USART_SR_TXE)); USART1->DR = c & 0x01ff; return (c); } int SER_GetChar (void) { while(!(USART1->SR & USART_SR_RXNE)); return (USART1->DR & 0xff); } void Usart_init(void) { RCC->APB2ENR |= (1<<14); //clk enable USART1->BRR = (SystemCoreClock/115200L); // baud rate USART1->CR2 = 0x0000; // 1 stop bit USART1->CR1 &= 0xebff; // 8 bit data ,parity disable USART1->CR3 = 0x0000; // disable NTS,RTS USART1->CR1 |= USART_CR1_TE | USART_CR1_RE; // transmit,receive enable USART1->CR1 |= 0x2000; // usart enable } int main(void) { unsigned int a= 0; unsigned int b = 3; RCC->APB2ENR |= RCC_APB2ENR_IOPAEN; // enable clock for GPIOA GPIOA->CRH |= (0x0BUL << 4); // Tx (PA9) alt. out push-pull GPIOA->CRH |= (0x04UL << 8); // Rx (PA10) in floating Usart_init(); printf("Hello"); while(1); }
I have used this code to debug with stm32f103rb and it works. I am not sure my code is wrong or/and I miss some steps to configure stm32f103rc. Please help me with this. Thanks in advance.