UART receive problem

A forums to allow bugs and problems with Flowcode v7 to be reported and resolved.

Moderator: Benj

Post Reply
howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

UART receive problem

Post by howard123 »

Hello all

I am having a problem with a serial receive that I hope you could help me with.

I send a number to an instrument and receive data from it using channel 2 UART on a 18F46K22 using 9600 baud. One character is sent and one is received. Most often the return character is incorrect with a value of 255 or sometimes another incorrect value. The time taken for the instrument to respond it 13mS and I have set the receive timeout to 25mS. I have measured on the chip, using a logic analyser, that the timing and framing are correct and that the received byte is always the correct value. This runs within a timer interrupt and so I guess there is nothing being called to do between sending and receiving.
Capture.JPG
Capture.JPG (173.89 KiB) Viewed 3278 times
I changed to this scheme after first using a receive interrupt scheme and that too delivered similar unreliable UART reads.

Channel 1 UART does a similar bidirectional communication without a problem.


Thanks
Howard

kersing
Valued Contributor
Valued Contributor
Posts: 2045
Joined: Wed Aug 27, 2008 10:31 pm
Location: Netherlands
Has thanked: 553 times
Been thanked: 1081 times
Contact:

Re: UART receive problem

Post by kersing »

As you haven't posted your flowcard there is not much to go on. We can't look at controller settings, component settings etc. We can't see what component you are using (RS232 or UART CAL) We just see a few icons...
“Integrity is doing the right thing, even when no one is watching.”

― C.S. Lewis

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: UART receive problem

Post by howard123 »

Hi

Thank you for your interest in this.

I have attached a reduced but still UART 2 RS232 dis-functioning version of the project.

I have made a Labview simulation of the instrument and so the timing is not as previously described. To compensate, I have set the UART timeout to 50ms for this test.

The instrument is sent the number 10 and correctly replies with the number 73 as sampled at the PIC chip and shown on the logic analyser..
call 10 ans 73.JPG
call 10 ans 73.JPG (25.39 KiB) Viewed 3259 times

Here is the location of the code tested..
flowcode segment.JPG
flowcode segment.JPG (94.81 KiB) Viewed 3259 times

The UART output is either the correct value (73) or value X or 255. I can not clearly define what the causal relationship is between these 3 outputs. The value X is the same as the value the UART should be delivering from a previous call. Could this be a UART hardware buffer issue?

Thank you
Attachments
Main D42 reduced test 01.fcfx
(239.19 KiB) Downloaded 181 times

howard123
Posts: 75
Joined: Thu May 24, 2012 1:15 pm
Location: Cape Town
Has thanked: 30 times
Been thanked: 28 times
Contact:

Re: UART receive problem

Post by howard123 »

Turns out this was a bad solder joint on the SMD receive pin of my device. Sometimes when it made a contact it would work well and when open would cause a timeout (255)

Sorry if I misled anyone
Howard

Post Reply