STC15W408AS library 0.12.0
Loading...
Searching...
No Matches
Enumerations
UART1 Mode2

Enumerations

enum  uart1_mode2_baudrate_t { baudrate_172800 = 172800U , baudrate_345600 = 345600U }
 UART1 baud rate enumeration.
 

init

UART1 initialization functions

#define uart1_mode2_init(pins, baudRate)
 Initializes UART1 in Mode 0.
 

Detailed Description

Functions and data structures for UART1 communication in Mode 2.

Mode 2 provides asynchronous communication with fixed baud rate and 9-bit data. 9-N-1.

The baud rate is fixed at 1/32 (or 1/64) the System clock cycle.

Attention
Baud rate is biased by frequency divider
See also
uart1_send_9bit()
uart1_receive_9bit()
is_uart1_send_byte_complete()
is_uart1_receive_byte_complete()
Author
Michael Golovanov

Macro Definition Documentation

◆ uart1_mode2_init

#define uart1_mode2_init (   pins,
  baudRate 
)
Value:
do { \
enable_mcu_interrupts(); \
enable_uart1_interrupt(); \
\
/* PCON.7 always set to 1. Is it error? */ \
baudRate == baudrate_345600 ? bit_set(PCON, SBIT7) : bit_clr(PCON, SBIT7); \
\
/* SM1 = 1, SM0 = 0 to select UART1 mode2 */ \
SCON = 0x90; \
\
/* Set AUXR1 bits 6, 7 to select RxD/TxD pins */ \
AUXR1 &= 0x3F; \
AUXR1 |= pins; \
} while (0)

Initializes UART1 in Mode 0.

Must be called before any UART communication is initiated.

Parameters
pinsuart1_pins_t The desired UART1 pins.
baudRateuart1_mode2_baudrate_t The desired UART1 baud rate.
Attention
Baud rate is biased by frequency divider.