cancel
Showing results for 
Search instead for 
Did you mean: 

I want to write a Code in Usart such that If It received "HELLO" It should transmit "HOW ARE YOU " in return . Can anyone help me

Zchou.1
Associate II
 
10 REPLIES 10

You want to write the code, or you want someone else too?

On what part? Using SPL, HAL or registers?

Probably want to use the HAL_UART_Receive_IT() one character at a time, build a buffer or state machine to recognize the request. Dispatch response using HAL_UART_Transmit_IT() perhaps from a buffer or queuing scheme.

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

I am using STM32 F4 board .

Using USART2

DMA

using HAL libraries.

And using TTL port to send and receive data .

Now I want to write a code In which I send HELLO in the rx and get HOW ARE YOU in return with tx .

I'd probably avoid DMA on the receive side, doesn't bring much in the way of efficiency, and does make things more complicated.

For DMA transmit, you might want to use a scatter-gather list to keep track of the data in-flight to ensure the buffer content isn't changed or reused.

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

You tell me the steps And I will follow I am a beginner and cant understand some of terms you are speaking about

Can you write a small framework that initializes the USART2, the clocks, the pins, and outputs a character in a loop?

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

CubeF4 contains UART examples, you may want to start there.

JW

Nikita91
Lead II

for a complete beginner you are ambitious.

First make an application that receives 1 character and copies it on transmission (echo). The rest will be easy.

yes I have done that As HELLO WORD comes on RX and also get Transmitted .

If I send hello world I get Hello world back

Yes