Page 1 of 1

Problem speed RS232 in RX

Posted: Wed Oct 24, 2018 6:39 pm
by xelites
Good evening all pipol, I have a problem with the attached program. Can you understand or bend what happens? I have to receive the following command from the serial line &Y10 or &Y20 etc. &Y I put them as char to define the address while the other two are as string and I need to read the data to be converted into voltage etc. Everything works but I only read &Y1 or &Y2 all the second byte of the string are lost I think for the various conversion delays! if I send the 0 on the serial link and dial the command. Is there any quick routine to do what I need?
Thanks, I'm waiting :roll:

Re: Problem speed RS232 in RX

Posted: Wed Oct 24, 2018 7:57 pm
by medelec35
Hi xelites,
Is there a specific reason for not using UART RX interrupt?
They are way better than timer interrupts or tight loops.

Re: Problem speed RS232 in RX

Posted: Wed Oct 24, 2018 9:09 pm
by xelites
Thanks Modelec, do you have any small examples to see how to use it in the right way? thanks again good night

Re: Problem speed RS232 in RX

Posted: Wed Oct 24, 2018 9:45 pm
by medelec35
There will be numerous examples.
Latest example that also works with simulation can be found here
Note the RX interrupt is the only interrupt that currently does not simulate.
You will of course need to modify flowchart for your requirement.
After modification, if still not working then I will see if I can help you further.

Re: Problem speed RS232 in RX

Posted: Thu Oct 25, 2018 10:44 am
by xelites
hello, I tried but nothing to do ... even simplifying the instructions I receive the first two characters ascii & Y every now and then the string data that comes together &Y99, if I send &Y wait and then send the string data 99 then it works fine but I have to divide the controls and this complicates my life on the WMI HMI display that does not have so many possibilities ... if you have any idea I try.
Thank you

Re: Problem speed RS232 in RX

Posted: Fri Oct 26, 2018 11:51 am
by Benj
Hello,

If you are doing a lot of processing in the rxinterrupt macro then this could be why you are missing data.

I would suggest you use the RXinterrupt to add the incoming byte to a circular buffer and then process the buffer as part of your main loop. This leaves the interrupt free to fire and keep receiving bytes as they come in.

There are some examples here, specifically example 2.3 should be applicable.
https://www.matrixtsl.com/wiki/index.ph ... f2ad670a8a

If you're still having problems then please post your latest Flowchart so we can see what you're doing and what might be going wrong.

Re: Problem speed RS232 in RX

Posted: Sat Nov 03, 2018 3:43 pm
by xelites
Ok thx Benj now i try .. if i have the problem write you