UART send command to one device and receive in another

Any bugs you encounter with Flowcode should be discussed here.
Post Reply
flowcode-developer
Posts: 37
http://meble-kuchenne.info.pl
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Flowcode v10 UART send command to one device and receive in another

Post by flowcode-developer »

Hi,
I am new here. Using the AVR chipset. I was wondering why this could does not work the way I want it to? The objective is to send a command from AVR2560 to a device then receive the info from that device and send to the PC. I added my code below.
Attachments
Inspectra_macro.fcfx
(13.39 KiB) Downloaded 310 times

mnfisher
Valued Contributor
Posts: 1454
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 135 times
Been thanked: 708 times

Re: UART send command to one device and receive in another

Post by mnfisher »

You need to look at using a receive interrupt to get the message.
It is rarely successful to use receive string - timing is not on your side.

Martin

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: UART send command to one device and receive in another

Post by flowcode-developer »

I tried interrupts and I do not understand them for UART. I do not understand why I need to make a macro for the interrupt. I made a macro where I put in the receivestring. I must be doing something wrong.

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 501 times
Been thanked: 686 times

Re: UART send command to one device and receive in another

Post by BenR »

Hello,

Here is a slightly reworked version of your program.

In this we initialise the two UARTs and then output a string every 3 seconds to UART 1.

For UART 2 we have enabled an interrupt to catch any incoming data and this data is then fed into the Circular Buffer component. This allows you to check for what has been received as part of your main loop and ensures you don't miss any data (assuming there is still room in the buffer).
Inspectra_macro.fcfx
(15.58 KiB) Downloaded 339 times
Hope this helps.

flowcode-developer
Posts: 37
Joined: Thu Feb 02, 2023 9:32 pm
Has thanked: 19 times
Been thanked: 3 times

Re: UART send command to one device and receive in another

Post by flowcode-developer »

Found an explanation of interrupts that helped my understanding of them.

https://www.youtube.com/watch?v=pOsyUyLcqHU

Post Reply