PIC18F66K80 - Confused by UART config

Moderator: Benj

lexicon
Flowcode v5 User
Posts: 54
Joined: Mon Apr 06, 2015 6:30 pm
Has thanked: 20 times
Been thanked: 22 times
Contact:

PIC18F66K80 - Confused by UART config

Postby lexicon » Wed Nov 14, 2018 10:12 am

I'm updating an old project written on FC5 and I needed to add a 2nd serial port to receive data from an RF device on UART2.
I'm already using UART1 with no issues.
Although I can transmit data out of TX2, I cannot receive anything on RX2 - the receive line seems to be held permanently high.
So, I had a look at the relevant 18F66K80.fcd file and found this config pertaining to the UARTs:

Define22=#define MX_UART_1
Define23=#define MX_UART_1_TX_PORT portc
Define24=#define MX_UART_1_TX_TRIS trisc
Define25=#define MX_UART_1_TX_PIN 6
Define26=#define MX_UART_1_RX_PORT portc
Define27=#define MX_UART_1_RX_TRIS trisc
Define28=#define MX_UART_1_RX_PIN 7
Define29=#define MX_UART_2
Define30=#define MX_UART_2_TX_PORT portd
Define31=#define MX_UART_2_TX_TRIS trisd
Define32=#define MX_UART_2_TX_PIN 6
Define33=#define MX_UART_2_RX_PORT portd
Define34=#define MX_UART_2_RX_TRIS trisd
Define35=#define MX_UART_2_RX_PIN 7

Which has me really puzzled as the UART1 is Rx on port G0 and Tx on G3. UART2 uses E6 & E7.

User avatar
Benj
Matrix Staff
Posts: 14453
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4515 times
Been thanked: 4192 times
Contact:

Re: PIC18F66K80 - Confused by UART config

Postby Benj » Wed Nov 14, 2018 11:43 am

Hello,

Have you tried editing the definitions in the FCD file to make them correct. Hopefully that is all you need to do.
These users thanked the author Benj for the post:
lexicon (Wed Nov 14, 2018 5:02 pm)
Rating: 5.26%
 

lexicon
Flowcode v5 User
Posts: 54
Joined: Mon Apr 06, 2015 6:30 pm
Has thanked: 20 times
Been thanked: 22 times
Contact:

Re: PIC18F66K80 - Confused by UART config

Postby lexicon » Wed Nov 14, 2018 12:26 pm

Hi Ben,

No, not yet, although that is the obvious thing to do - I will try it and see.
The thing that got me was that 3 out of 4 pins seem to work, regardless of the config file seemingly being wrong for all of them....

Cheers,
Martin.

lexicon
Flowcode v5 User
Posts: 54
Joined: Mon Apr 06, 2015 6:30 pm
Has thanked: 20 times
Been thanked: 22 times
Contact:

Re: PIC18F66K80 - Confused by UART config

Postby lexicon » Wed Nov 14, 2018 5:05 pm

I changed the config file to this:

Define22=#define MX_UART_1
Define23=#define MX_UART_1_TX_PORT portg
Define24=#define MX_UART_1_TX_TRIS trisg
Define25=#define MX_UART_1_TX_PIN 3
Define26=#define MX_UART_1_RX_PORT portg
Define27=#define MX_UART_1_RX_TRIS trisg
Define28=#define MX_UART_1_RX_PIN 0
Define29=#define MX_UART_2
Define30=#define MX_UART_2_TX_PORT porte
Define31=#define MX_UART_2_TX_TRIS trise
Define32=#define MX_UART_2_TX_PIN 7
Define33=#define MX_UART_2_RX_PORT porte
Define34=#define MX_UART_2_RX_TRIS trise
Define35=#define MX_UART_2_RX_PIN 6

Made not a scrap of difference!
Anyway, some considerable time later I found that my actual issue was a PCB manufacturing fault whereby the RX2 line was shorted to +5v.....
These users thanked the author lexicon for the post:
Benj (Wed Nov 14, 2018 5:35 pm)
Rating: 5.26%