Positron Compiler Documentation

USART4 Declares for use with HRsin4, HSerin4, HRsout4 and HSerout4.

Positron8 · Revision 4.0.6.5 · PDF page 428

Declare HSerout4_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the TX4 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 HSerin4_Pin = Port.Pin For devices that have PPS (Peripheral Pin Select), the port and pin used for the RX4 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 Hserial4_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 Hserial4_Parity = Odd or Even Enables/Disables parity on the serial port. For HRsout4, HRsin4, HSerout4 and HSerin4. 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 Hserial4_Parity declare.

Declare Hserial4_Parity = Even   ' Use if even parity desired
Declare Hserial4_Parity = Odd    ' Use if odd parity desired

Declare Hserial4_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 Hserial4_Clear declare can be used to automatically clear this error, even if no error occurred. However, the program will not know if an error occurred while reading, therefore some characters may be lost.

Declare Hserial4_Clear = On
View original PDF page 428Open page in PDFOriginal PDF page 428