Can not run UART

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Sergejs
Posts: 143
http://meble-kuchenne.info.pl
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Can not run UART

Post by Sergejs »

Hello,

Why I can not use UART? I can send data but can not receive it. Can you help?
RadioDataNano.fcfx
(11.07 KiB) Downloaded 116 times

mnfisher
Valued Contributor
Posts: 956
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 104 times
Been thanked: 509 times

Re: Can not run UART

Post by mnfisher »

You'll need to use an interrupt to catch the data - ReceiveString needs to have the right timing (and probably impossible without using an interrupt handler)
There are several examples dotted around - try viewtopic.php?f=5&t=1788&hilit=uart%5D for an example from Ben.

Martin

Sergejs
Posts: 143
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Re: Can not run UART

Post by Sergejs »

mnfisher wrote:
Mon Jan 15, 2024 7:55 pm
You'll need to use an interrupt

Martin
But if I will use Flow control (total 4 wires will be), so in this case will be same?

Sergejs
Posts: 143
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Re: Can not run UART

Post by Sergejs »

How about IC MAX232? Should I put it in both MCU for good result?

Sergejs
Posts: 143
Joined: Tue Oct 19, 2021 9:31 am
Has thanked: 73 times
Been thanked: 5 times

Re: Can not run UART

Post by Sergejs »

By the way. In Arduino it works fine. Can any explain, why?
aproject0.jpg
aproject0.jpg (86.79 KiB) Viewed 836 times

chipfryer27
Valued Contributor
Posts: 1149
Joined: Thu Dec 03, 2020 10:57 am
Has thanked: 285 times
Been thanked: 412 times

Re: Can not run UART

Post by chipfryer27 »

Hi

The MAX232 is only a driver/receiver chip that enables a microcontroller to handle the voltages typically used in RS232. Take a look at the datasheet, particularly the pinouts for usage. It does not provide any "intelligence".

https://www.ti.com/lit/ds/symlink/max23 ... co.uk%252F

Four-wire flowcontrol is only used to inform the "far end", which could be a modem interface, that the receiver is able and ready to receive data and is irrelevant to your issue.

As Martin said in a previous post you need to use interrupts.

It looks like you have used an Arduino sketch found here https://docs.arduino.cc/tutorials/commu ... alExample/ and near the beginning of the code example it warns that not all pins of the intended chip can be used as not all pins support interrupt on change (IOC)

"Note:
Not all pins on the Mega and Mega 2560 support change interrupts"

So you see even your Arduino sketch is using interrupts to receive data, whereas you are not and are relying on luck that there will be data to receive at the exact time you look.

If you add the RS232 component, then right click it and select "help" you will be taken to the WiKi page for the component and there you will find a good explanation of the component, how to use it and also examples.

This link to the WiKi will explain interrupts

https://www.flowcode.co.uk/wiki/index.p ... Interrupts

Regards

Post Reply