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.
PIC18F66K80 - Confused by UART config
Moderator: Benj
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: PIC18F66K80 - Confused by UART config
Hello,
Have you tried editing the definitions in the FCD file to make them correct. Hopefully that is all you need to do.
Have you tried editing the definitions in the FCD file to make them correct. Hopefully that is all you need to do.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Flowcode v5 User
- Posts: 55
- Joined: Mon Apr 06, 2015 6:30 pm
- Has thanked: 20 times
- Been thanked: 22 times
Re: PIC18F66K80 - Confused by UART config
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.
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.
-
- Flowcode v5 User
- Posts: 55
- Joined: Mon Apr 06, 2015 6:30 pm
- Has thanked: 20 times
- Been thanked: 22 times
Re: PIC18F66K80 - Confused by UART config
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.....
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.....