Page 110 of 346 Start Back Next End ZBasic System Library 98 ZBasic Microcontrollers Serial Channel Configuration Flag Values Function Hex Value Bit Mask Inverted Logic¹ &H80 1x xx xx xx Non-inverted Logic &H00 0x xx xx xx Ignore Parity Bit &H40 x1 xx xx xx Even Parity &H30 xx 11 xx xx Odd Parity &H20 xx 10 xx xx No Parity &H00 xx 00 xx xx 7-bit Data &H07 xx xx 01 11 8-bit Data &H08 xx xx 10 00 7-bit Data, bussed mode¹ &H0b xx xx 10 11 8-bit Data, bussed mode¹ &H0c xx xx 11 00 ¹ Applicable only to software-based channels (3-6). The remaining bit values are currently undefined but may be employed in the future. When Non-inverted Logic is selected, the idle state of the transmit line will be logic 1. When a character transmission is begun, a “start bit” of logic zero will be sent for one bit time (the inverse of the baud rate). Next the data bits are sent, each for one bit time, beginning with the least significant bit and continuing through the eighth data bit or parity bit as the case may be. Finally, one or more “stop bits” of logic one are sent, each for one bit time. With Inverted Logic, each of these elements is complemented – the idle state of the transmit line is logic 0. Whether you should choose the inverted or non-inverted mode depends on the device that you intend to communicate with and how many, if any, level converters exist between the two devices. Typically, if the other device is capable of sending and receiving TTL-level serial data, you’ll likely choose non-inverted Logic. If the “Ignore Parity” flag is asserted, in 7-bit mode the most significant bit of each character received will be zero and in 8-bit mode only one byte will be stored in the queue for each character received. If the “Ignore Parity” bit is not asserted, in 7-bit mode the MSB will contain the received parity bit and in 8-bit mode a second byte containing the parity bit will be stored in the queue for each character received. The ParityCheck() function is useful for checking the parity of a received character. The software UART channels support a bussed mode where the transmit pin is actively driven only during logic zero periods (low for non-inverted mode, high for inverted mode). This mode, selected by using the special values shown in the table above for 7-bit and 8-bit data widths (i.e., the normal values augmented by 4), is useful for having multiple devices driving the same transmit line. This mode is commonly referred to as open drain (non-inverted mode) or open source (inverted mode) operation and requires a pullup resistor (non-inverted mode) or a pulldown resistor (inverted mode) on the common transmit line in order to establish the proper logic level when the line is not being actively driven by any device. Note that a pullup resistor (non-inverted mode) or a pulldown resistor (inverted mode) is recommended on the transmit line to force the transmit line to the idle state prior to the time your program initializes the COM port. If you don’t do this, the receiving device may see false transmissions prior to the first character actually transmitted. Depending on what other circuitry is connected to the receive line, you may need to do the same to prevent the ZBasic device from receiving false transmissions. Example Call ComChannels(2, 9600) Call DefineCom(4, 0, 12, &H08) This call prepares software-based channel 4 for transmit-only using pin 12, eight data bits, no parity and non-inverted logic.