Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

UART and receving more than it is expected.

X

Xenon02

Guest
Newbie level 1
Hello !

I've wanted to ask a bit how RX UART works like when I want to receive more than I want.
I've had a bluetooth HC-06 and tested it on STM32-NucleoL073RZ, the thing is that I've sent a command via HAL_UART_Transmit(), and the command is "AT\r\n", I've sent it and it sends back a message "OK" and I guess it adds at the end "\0" maybe. The thing is I have an RX buffor that is receive[50] and typed "HAL_UART_Receive(&huart2, (uint8_t *)receive, sizeof(receive)-1, HAL_MAX_DELAY)"

Size of receive is 50-1 so it is 49, so I want to receive 49 characters although it is only 2 characters.

Now it worked correctly I've received first 2 characters as O, and K, then the rest of characters are "\0". How does it work ? The bluetooth all the time sends "\0" character no matter what ?

I understood that RX waits for start byte from TX of bluetooth after getting all data it sends that RX is full and then the data is taken from RX and sent to the buffer.

Someone correct me if it's ok : normally it works that it should give an error and something happens to RX I guess.
Or perhaps it can fill those empty spaces with zero or null but how can RX fill itself when usually it waits all the time for the TX start bit. Can someone tell me ?
 
Hi,

Don´t post text we can not validate.
Show your whole code.
Show how you really tested it.

Klaus
 
use STM32 UART Idle interrupt + DMA,and if you have a logic analysis it can be very easy to cap and decode from uart data.
Thanks.
 
I agree with KlausST, show the complete code.
Now it worked correctly I've received first 2 characters as O, and K, then the rest of characters are "\0". How does it work ? The bluetooth all the time sends "\0" character no matter what ?
1. Presume the buffer is cleared at program start. If you see zero characters in buffer, they might have been there before.
2. What's the return code of HAL_UART_Receive()?
3. What's the value of huart2.RxXferCount after return from HAL_UART_Receive()?
4. Did you actually set timeout to HAL_MAX_DELAY? Why?
 
"I want to receive more than I want"

This is a runaway uncertain statement.

more than you expected?
more than you requested?
more than you got?

In full duplex, a protocol exists to request more, or an explicit range of data using handshaking with REQuest <> ACKnowledge or NAK negative acknowledge.
hence called REQ: {ACK:NAK} handshaking, followed by the data.

UARTs have status bits for overflow, data ready, parity error etc, and for high speed DMA is most efficient.

There is also software flow control (Xon/Xoff), and hardware flow control (RTS, CTS).

more info

 
Last edited:

LaTeX Commands Quick-Menu:

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top