cancel
Showing results for 
Search instead for 
Did you mean: 

USART Issue with STM32F100RB

Myasu.1
Senior

I want to do serial communication between my PC and STM32F100RB.

the connection is as follows.

[STM32F100RB] -----[USBtoSERIAL transfer Module] --------------[PC]

PB10(Rx) <----------> TXD           USB <----------> USB

PB11(Tx) <----------> RXD

​Currently, the transmission from PC to STM32F100RB is working, but the transmission from STM32F100RB to PC is not. Therefore, I don't think there is any possibility that USBtoSERIAL transfefr Module is broken.

The source code is shown below.

int main(void){
 
…
 
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE);
 
  USART_InitStructure.USART_BaudRate = 115200;
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;
  USART_InitStructure.USART_StopBits = USART_StopBits_1;
  USART_InitStructure.USART_Parity = USART_Parity_No;
  USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
  USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
 
  USART_Init(USART3, &USART_InitStructure);
  USART_Cmd(USART3, ENABLE);
 
  while (1)
  {
      USART_SendData(USART3, 0x0001);
  }
}

I use the function USART_* in the following folder, which is provided by default in TrueStudio.

STM32F10x_StdPeriph_Driver

The following are the values of the registers that I checked on TrueStudio. They seem to be set correctly.

However, I am concerned that the value I want to send does not seem to be written in the DR register.

0693W00000FCG8FQAX.png

Could you please confirm ?

11 REPLIES 11

1. You can send data in main if you want, but if you do, you'll need to disable the interrupt otherwise it will be stuck in the ISR forever. It's unclear what you're trying to accomplish in the while loop.

2. TXE means the register used to send out data is empty and can accept data. Received data will trigger the RXNE flag.

If you want to know the details, the reference manual has all of this information.

If you feel a post has answered your question, please click "Accept as Solution".

If you want concurrent operation for receive/transmit, and across multiple UART, it is probably advisable to use interrupts and buffering.

The peripheral is flexible, you can use polled, interrupt or DMA methods, you get to chose the strategy/implementation.

With simple demos using polling in the main() loop is a quick way to prove things are working and to get an understanding how the peripheral behaves.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..