PIC18F66K80 - Confused by UART config
Posted: 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.
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.