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.
PIC18F57Q84 UART Error
-
seokgi
- Posts: 238
- http://meble-kuchenne.info.pl
- Joined: Thu Dec 03, 2020 1:43 pm
- Has thanked: 8 times
- Been thanked: 8 times
-
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
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.
Let us know if this makes a difference.
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;Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
-
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
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?
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
Thanks Leigh,
We can also try this using this C code to see if this makes a difference.
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 :-
We can also try this using this C code to see if this makes a difference.
Code: Select all
U1CON1 = 0x80;Could be a silicone bug, in fact I'll check the errata document for the chip now.
From the Errata :-
So I think they are recommending an external pull up resistor on the TX pin, maybe 10K - 100K?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.
Regards Ben Rowland - MatrixTSL
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel
Flowcode Online Code Viewer (Beta) - Flowcode Product Page - Flowcode Help Wiki - My YouTube Channel