USART5 Declares for use with HRsin5, HSerin5, HRsout5 and HSerout5.
Declare HSerout5_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the TX5 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 HSerin5_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the RX5 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 Hserial5_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 Hserial5_Parity = Odd or Even Enables/Disables parity on the serial port. For HRsout5, HRsin5, HSerout5 and HSerin5. 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 Hserial5_Parity declare.
Declare HSerial5_Parity = Even ' Use if even parity desired
Declare HSerial5_Parity = Odd ' Use if odd parity desired
Declare Hserial5_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 if bytes are not read from it often enough. When this occurs, the USART stops accepting any new characters, and requires resetting, so the Hserial5_Clear declare can be used to automatically clear this error. However, the program will not know if an error occurred while reading, therefore some characters may be lost.
Declare Hserial5_Clear = On
