VERIFY USART2_TX/RX PIN error with USART_2

General discussion relating to the library modules supplied with the compiler

Moderators: David Barker, Jerry Messina

Post Reply
garryp4
Posts: 104
Joined: Mon May 21, 2007 7:18 am
Location: Loveland, CO USA

VERIFY USART2_TX/RX PIN error with USART_2

Post by garryp4 » Sat Sep 05, 2020 8:13 pm

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

Jerry Messina
Swordfish Developer
Posts: 1245
Joined: Fri Jan 30, 2009 6:27 pm
Location: US

Re: VERIFY USART2_TX/RX PIN error with USART_2

Post by Jerry Messina » Sat Sep 05, 2020 10:28 pm

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.

garryp4
Posts: 104
Joined: Mon May 21, 2007 7:18 am
Location: Loveland, CO USA

Re: VERIFY USART2_TX/RX PIN error with USART_2

Post by garryp4 » Sun Sep 06, 2020 3:50 pm

That was it.

Thanks so much!

Post Reply