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.
UART send command to one device and receive in another
-
- Posts: 37
- http://meble-kuchenne.info.pl
- Joined: Thu Feb 02, 2023 9:32 pm
- Has thanked: 19 times
- Been thanked: 3 times
UART send command to one device and receive in another
- Attachments
-
- Inspectra_macro.fcfx
- (13.39 KiB) Downloaded 310 times
-
- Valued Contributor
- Posts: 1453
- Joined: Wed Dec 09, 2020 9:37 pm
- Has thanked: 135 times
- Been thanked: 707 times
Re: UART send command to one device and receive in another
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
It is rarely successful to use receive string - timing is not on your side.
Martin
-
- 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
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.
-
- 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
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).
Hope this helps.
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).
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
- 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
Found an explanation of interrupts that helped my understanding of them.
https://www.youtube.com/watch?v=pOsyUyLcqHU
https://www.youtube.com/watch?v=pOsyUyLcqHU