Page 1 of 1

VERIFY USART2_TX/RX PIN error with USART_2

Posted: Sat Sep 05, 2020 8:13 pm
by garryp4
I am getting a warning after compile from the USART2 module.

#warning "**VERIFY USART2_TX PIN - assuming PORTB.6**"
#warning "**VERIFY USART2_RX PIN - assuming PORTB.7**"

My guess is I am not setting the PPS pins correctly. The PPS module shows the example "pps.assign_output(RA0PPS, PPS_TMR0)" and "assign_input(PPS_RX2, PPS_IN_RP0)". The input example is very close to what I'm using so don't think the problem is there. However, when I make the output "pps.assign_output(RA1PPS, PPS_TX2)" like the example, I get an error. I am unsure of the output syntax.

Code: Select all

Device = 18F27J13
Clock  = 8
  
Config IOL1WAY = OFF

// import modules...
Include "intosc.bas"
Include "convert.bas"
Include "system.bas"
Include "USART.BAS"
Include "USART2.bas"
#option USART2_TX = PORTA.1            ' SPI data out - RP1 
#option USART2_RX = PORTA.5            ' SPI data in - RP2
Include "spi.bas"
Include "setdigitalio.bas"
Include "PPS.bas"

Private Dim
  b1        As Byte

'****************************************************************
Public Sub SET_2_SERIAL()
  pps.unlock()
  pps.assign_input(PPS_RX2, PPS_IN_RP2)   ' RA.5
  pps.assign_output(PPS_TX2, PPS_OUT_RP1)  ' RA.1
  pps.lock()
  USART2.SetBaudrate(br9600)
End Sub
'**************************************************************** 

SET_2_SERIAL()

'****************************************************************
MAIN:

USART2.Write("I'M ALIVE!",10,13)
DelayMS(5)
Thanks

Re: VERIFY USART2_TX/RX PIN error with USART_2

Posted: Sat Sep 05, 2020 10:28 pm
by Jerry Messina
Garry,

The '#option' statements must be before the module that needs them is included.

The important ones here would be:

Code: Select all

#option USART2_TX = PORTA.1            ' uart2 TX data out - RP1 
#option USART2_RX = PORTA.5            ' uart2 RX data in - RP2
Include "USART2.bas"
Your pps statements look ok to me.

Re: VERIFY USART2_TX/RX PIN error with USART_2

Posted: Sun Sep 06, 2020 3:50 pm
by garryp4
That was it.

Thanks so much!