Sending UART data at maximum speed without interrupts
Hi,
There something odd with the USART3 (the Virtual COM one). I can send characters, but there's some speed limit that I can't surpass.
I'm trying to loop a string as fast as possible, but I can't get the optimum speed, I'm having to use a delay (or a timer) to make the UART work.
From what I understood reading the datasheet, the procedure (without the use of interrupts), would be:
Set the TE bit, wait for TEACK to be set, put some data in the TDR, wait for TXE to be set, put another data in the TDR, repeat the last two steps n times, wait for the TC bit to be set, reset the TE bit.
Doing this I'm stuck in the TC polling. Removing this I'm getting AKUeoz in the terminal. These TXE and TC flags are not to be used to control the speed in which data is sent through the U(S)ART registers?
Also, while trapped forever in the TC loop, the memory view shows nothing in the TDR memory location...
MCU is STM32F767ZI
AREA STRINGS, DATA, READONLY
String DCB "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxz",0
(...)
LDR R5,=String
(...)
LDR R0,=USART3_CR1 ;Enable USART3 transmission (sends idle frame)
LDR R1,[R0]
ORR R1,#USART3_TE
STR R1,[R0]
TEACK ;Wait for idle minimum time
LDR R0,=USART_ISR
LDR R1,[R0]
AND R1,#USART3_TEACK
BEQ TEACK
MOV R9,#10
LOOP_STRING ;Transmit char and update address
LDR R0,=USART_TDR
LDR R1,[R5],#1
STR R1,[R0]
TXE ;Wait for TX buffer being empty
LDR R0,=USART_ISR
LDR R1,[R0]
AND R1,#USART3_TXE
BEQ TXE
SUBS R9,R9,#1
BNE LOOP_STRING
TC ;Wait for transmission to complete
LDR R0,=USART_ISR
LDR R1,[R0]
AND R1,#USART3_TC
BEQ TC
LDR R0,=USART3_CR1 ;Disable USART3 transmission
LDR R1,[R0]
AND R1,#~USART3_TE
STR R1,[R0]