Page 1 of 1

Can not run UART

Posted: Mon Jan 15, 2024 7:29 pm
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 884 times

Re: Can not run UART

Posted: Mon Jan 15, 2024 7:55 pm
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

Re: Can not run UART

Posted: Mon Jan 15, 2024 10:58 pm
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?

Re: Can not run UART

Posted: Mon Jan 15, 2024 11:03 pm
by Sergejs
How about IC MAX232? Should I put it in both MCU for good result?

Re: Can not run UART

Posted: Sat Jan 20, 2024 2:28 am
by Sergejs
By the way. In Arduino it works fine. Can any explain, why?
aproject0.jpg
aproject0.jpg (86.79 KiB) Viewed 4408 times

Re: Can not run UART

Posted: Sat Jan 20, 2024 8:31 am
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