cancel
Showing results for 
Search instead for 
Did you mean: 

UART block transfer issues

Pablo Martin
Associate
Posted on April 17, 2017 at 19:27

Hi all,

I am having some issues using the UART of an STM32F446RE (in a Nucleo board). I am pretty much a newbie so this might come as a very basic question.

All I intend to do is to transfer data from SRAM to an external PC using UART. I am using CubeMX to generate the initialization code and am using Embedded Workbench.

The problem seems to be that I am unable to write in the Data Register of the UART. While debugging I can see the control registers for the UART are configured as I would expect, but the bits TC and TXE seem to be always set in the Status Register.

I tried to clear these by software; I can clear the TC bit but it sets back automatically when I attempt to write data in the data register. I cannot clear the TXE. According to the reference manual, this should be cleared automatically when writing data to the Data register, but this doesn't seem to be happening. Nothing actually seems to be happening when writing data to the DR.

Also worth of mention, I connected an oscilloscope (I dont have a logic analyser) to the Tx line to see if there is actually something is happening that cannot be seen in the registers during debugging, but that's not the case... all I see is the pull-up voltage..

Am I missing something?

Thank you very much in advance.

Pablo

#stm32f446re #uart #nucleo-f446re
3 REPLIES 3
S.Ma
Principal
Posted on April 17, 2017 at 20:21

Start from a UART example for the nucleo or discovery board, and adjust the code for the right GPIO pins and alternate functions for it. Try to use the UART in polling (non interrupt) mode if it is to send out data from RAM to PC.

In the debugger window, you can stop time and manually hack the registers to see if you can push a byte out and visible to the oscilloscope. I suppose you are using the UART connected to STLink which converts it as a virtual com port to the PC to be seen on Teraterm like app.

Posted on April 17, 2017 at 21:53

On the timeline of you putting data into the USART->DR the data will have already left the holding buffer and be prompting you for more data before you and the debugger can see what's going on, ie TXE asserting again.

Looking at the USART registers in the debugger is also invasive, reading USART->DR to show you what's in there will clear RXNE in USART->SR. I would avoid this level of direct inspection.

Try something along the lines of

while(1)

{

while(!(USART1->SR & USART_FLAG_TXE));

USART1->DR = 0x55;

}
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
howard n2wx
Senior
Posted on April 18, 2017 at 18:07

Is the USART periph clock enabled in the RCC?  I'm always forgetting that.