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.
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
UART receive problem
Moderator: Benj
-
- 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
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
― C.S. Lewis
-
- 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
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..
Here is the location of the code tested..
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
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..
Here is the location of the code tested..
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
-
- 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
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
Sorry if I misled anyone
Howard