PIC18F57Q84 UART Error

For general Flowcode discussion that does not belong in the other sections.
Post Reply
seokgi
Posts: 238
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 8 times
Been thanked: 8 times

Flowcode v11 PIC18F57Q84 UART Error

Post by seokgi »

Hello.

I am trying to proceed with a project using the PIC18F57Q84. I had trouble because it wouldn't compile. After receiving advice on how to switch compilers, it now compiles successfully. However, UART communication is not working. When I checked with an oscilloscope, the waveform phase was reversed in the output.

Please tell me how to fix this.

Thank you.

LeighM
Valued Contributor
Posts: 558
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 104 times
Been thanked: 302 times

Re: PIC18F57Q84 UART Error

Post by LeighM »

Could you provide a sample picture and what data it represents that you are sending

seokgi
Posts: 238
Joined: Thu Dec 03, 2020 1:43 pm
Has thanked: 8 times
Been thanked: 8 times

Flowcode v11 Re: PIC18F57Q84 UART Error

Post by seokgi »

The pink waveform is the waveform outputting "Test" from the PIC18F57Q84.
PIC18F57Q84_Wave_Test.jpg
PIC18F57Q84_Wave_Test.jpg (118.28 KiB) Viewed 107 times

The second yellow waveform is the waveform outputting "Test" from another device (PC USB-Serial).
USB_Wave_Test.jpg
USB_Wave_Test.jpg (118.92 KiB) Viewed 106 times
260810-18F57Q84-1.fcfx
(18.74 KiB) Downloaded 23 times

LeighM
Valued Contributor
Posts: 558
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 104 times
Been thanked: 302 times

Re: PIC18F57Q84 UART Error

Post by LeighM »

Looks like the TX output is being forced into a non-Idle (break) state
One for Ben and the UART CAL I think
(UxCON1 issue with this device?)

BenR
Matrix Staff
Posts: 2262
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 622 times
Been thanked: 827 times

Re: PIC18F57Q84 UART Error

Post by BenR »

Hmm that's pretty odd indeed.

There is a register that controls the state of the TX pin but it completely flips the signal and the signal looks mostly ok, though not 100% correct.

Our CAL doesn't write to the register in question and the default state should be 0 so again this is very odd.

You could try with a C icon changing the 1 for the specific UART channel you're using.

Code: Select all

U1CON2bits.TXPOL = 0;
Let us know if this makes a difference.

LeighM
Valued Contributor
Posts: 558
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 104 times
Been thanked: 302 times

Re: PIC18F57Q84 UART Error

Post by LeighM »

Hi Ben.
The signal looks inverted, but if you analyse the data it looks correct for "Test"
So I think it is in break mode in the inter data gaps.
There is a bit in UxCON1 that controls break, I wondered if that is causing it, perhaps it is getting inadvertently set?

BenR
Matrix Staff
Posts: 2262
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 622 times
Been thanked: 827 times

Re: PIC18F57Q84 UART Error

Post by BenR »

Thanks Leigh,

We can also try this using this C code to see if this makes a difference.

Code: Select all

U1CON1 = 0x80;
The CAL code does write to this register on initialise but the reset value should be 0x00 and we just set the ON bit which should be bit 7.

Could be a silicone bug, in fact I'll check the errata document for the chip now.

From the Errata :-
UART TXDE Signal May Go Low before the STOP Bit Has Been Entirely Transmitted

The UART Transmit Drive Enable (TXDE) signal could potentially transition into a low state before the UART STOP bit has been entirely transmitted due to the effects of parasitic capacitance on the TX line. In some applications, this could result in communication being prematurely terminated due to the TXDE bit going low before the STOP bit has had enough time to settle.

Work around To ensure that the STOP bit settles into its final logic state before the TXDE signal transitions low, a biasing circuit can be implemented. A biasing circuit allows the TX line to either be driven high or low, rather than being left in a floating tri-state mode where prolonged rise or fall times could lead to communication being disrupted. This bias circuit should only be implemented on one end of the serial bus, and a termination resistor should be used on the other end.
So I think they are recommending an external pull up resistor on the TX pin, maybe 10K - 100K?

LeighM
Valued Contributor
Posts: 558
Joined: Mon Dec 07, 2020 1:00 pm
Has thanked: 104 times
Been thanked: 302 times

Re: PIC18F57Q84 UART Error

Post by LeighM »

Good research, that sure looks like the issue then

Post Reply