USART2 Declares for use with HRsin2, HSerin2, HRsout2 and HSerout2.
Declare HSerout2_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the TX2 line must be given, so that the compiler can setup the PPS SFRs before the program starts. This may be any valid port on the microcontroller, but check the datasheet to see if the Port is valid for the peripheral.
Declare HSerin2_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the RX2 line must be given, so that the compiler can setup the PPS SFRs before the program starts. This may be any valid port on the microcontroller, but check the datasheet to see if the Port is valid for the peripheral.
Declare Hserial2_Baud = Constant value Sets the Baud rate that will be used to transmit a value serially. The Baud rate is calculated using the Xtal frequency declared in the program. The compiler will assign the best values to the SFRs for the Baud rate required. Within the asm file listing are the Baud rate achieved and the error percentage. Once compiled, press the F2 button and view the asm listing.
Declare Hserial2_Parity = Odd or Even Enables/Disables parity on the serial port. For HRsout2, HRsin2, HSerout2 and HSerin2. The default serial data format is 8N1, 8 data bits, no parity bit and 1 stop bit. 7E1 (7 data bits, even parity, 1 stop bit) or 7O1 (7data bits, odd parity, 1 stop bit) may be enabled using the Hserial2_Parity declare.
Declare Hserial2_Parity = Even ' Use if even parity desired
Declare Hserial2_Parity = Odd
' Use if odd parity desired
Declare Hserial2_Clear = On or Off Clear the overflow error bit before commencing a read.
Because the hardware serial port only has a 2-byte input buffer, it can easily overflow is characters are not read from it often enough. When this occurs, the USART stops accepting any new characters, and requires resetting, so the program will not know if an error occurred while reading, therefore some characters may be lost.
Declare Hserial2_Clear = On