2018-04-16 08:30 AM
I don't understand something, what's the point of TDR and RDR registers if during the Receive and Transmit functions they read/write into the DR register.
Moreover UART is normally full duplex but if we read/write into the same register we only can be half duplex at the most.
Could you explain me this point please, thanks.
#hal-uart #stm32f-uartSolved! Go to Solution.
2018-04-16 12:01 PM
Observe that TDR and RDR are two independent registers, Write DR goes to TDR, Read DR comes from RDR
You can't read the TDR, and you can't read the Transmit and Receiver Shift Register either because those are mechanics happening behind the scene into which you have no direct visibility.
2018-04-16 09:16 AM
Peripheral registers aren't memory, the read and write can go to entirely different internal functionality.
Think of it like a car painted two different colours down the center line, depending on which side you view the car from it will appear a different colour, but it doesn't change the make/model, and the guy on the driver side gets access to the steering wheel and pedals.
Many of the earlier STM32 families used USART->DR to talk to RDR and TDR depending if you were reading or writing. In newer models the registers are described separately. The mechanics of the holding registers and the shift registers inside the peripheral remain materially the same.
2018-04-16 10:08 AM
You should think of DR as the access point for the shift registers associated with TX or RX. Those shifter registers reflect the data transmitted over the TX or RX line. They are not directly accessible to user code, however.
Instead, you access them via the DR register: a read of DR reads the RX register and a write to DR writes to the TX register.
This gets more complex on some MCUs when a FIFO buffer is involved.
2018-04-16 11:42 AM
Ok but it's difficult to get a idea about it if their not memories, what could they be for exemple ?
But the fact that we use only one 'register' (DR) to write and read means that it isn't full duplex right ? If no, i really don't understand how it could be
:)
2018-04-16 11:53 AM
>>means that it isn't full duplex right ?
No
Like I said you need to stop using this 'memory' concept where it's one location and you read and write the same content.
You're talking to random logic, which is more like a meat grinder. The data is being acted on and processed, and might not come out of the same port or in the same form.
The data you put in the transmit/write side isn't going to appear in the receive/read side unless you wire the RX and TX pins together.
2018-04-16 11:59 AM
Note that this is standard behaviour in many (most? all?) microcontrollers: there is a single address in the address space; writing to it sends stuff to the transmitter, and reading from it retrieves stuff from the receiver.
2018-04-16 12:01 PM
Observe that TDR and RDR are two independent registers, Write DR goes to TDR, Read DR comes from RDR
You can't read the TDR, and you can't read the Transmit and Receiver Shift Register either because those are mechanics happening behind the scene into which you have no direct visibility.
2018-04-16 01:26 PM
Alright ! Thank you, that's very helpful