STC15W408AS library 0.12.0
|
Macros | |
#define | uart1_mode1_timer2_1T_init(pins) |
Initialize UART1 in Mode 1 with Timer2 1T configuration. | |
#define | uart1_mode1_timer2_1T_start(baudrate) |
Start UART1 communication with standart baudrate value. | |
#define | uart1_mode1_timer2_1T_ticks(baudrate) (65536 - (((MAIN_Fosc / baudrate) >> 2) >> get_frequency_divider_scale())) |
Get UART1 ticks for given baudrate and frequency divider scale. | |
#define | uart1_mode1_timer2_1T_start_ext(baudrate) |
Start UART1 communication with baudrate value. | |
#define | uart1_mode1_timer2_1T_stop (bit_clr(AUXR, CBIT4)) |
Stop UART1 communication and disable Timer2. | |
#define | is_uart1_mode1_timer2_1T_started() (test_if_bit_set(AUXR, SBIT4)) |
Is UART1 started? | |
Enumerations | |
enum | uart1_mode1_timer2_1t_baudrate_t { baudrate_1200 = 0xF6FF , baudrate_2400 = 0xFB80 , baudrate_4800 = 0xFDC0 , baudrate_9600 = 0xFEE0 , baudrate_19200 = 0xFF70 , baudrate_38400 = 0xFFB8 , baudrate_57600 = 0xFFD0 , baudrate_115200 = 0xFFE8 } |
UART1 precalculated baudrates. More... | |
Functions and data structures for UART1 communication in Mode 1 with Timer2 1T as baudrate generator. Dont use Timer2 for other purposes.
This module implements UART1 point-to-point communication. Relay and broadcast features are not supported by this module.
UART1 Mode 1 provides 8-bit asynchronous communication with variable baud rate. Sent data is transmitted to the TxD pin, and received data is read from the RxD pin. The frame data includes one start bit, 8 data bits, and one stop bit. 8-N-1
UART1 baudrate is determined by the T2 overflow rate. T2 overflow rate is configured by setting T2H and T2L registers.
THTL = 65536 - Sysclk/(4 * baudrate). Sysclk = master clock frequency / frequency divder.
THTL value is precalulated for standard baudrates with none freq divider.
In UART1 Mode 1, three sets of RxD/TxD pins can be used: RxD on P3.0/TxD on P3.1, RxD on P3.6/TxD on P3.7 and RxD on P1.6/TxD on P1.7.
Typical usage:
#define is_uart1_mode1_timer2_1T_started | ( | ) | (test_if_bit_set(AUXR, SBIT4)) |
Is UART1 started?
#define uart1_mode1_timer2_1T_init | ( | pins | ) |
Initialize UART1 in Mode 1 with Timer2 1T configuration.
The clock source of Timer2 is SYSclk. AUXR.T2x12 = 1. AUXR.UART_M0x6 = 0. Timer2 are used as timer. AUXR.T2_C/T = 0. Timer2 is not started. AUXR.T2R = 0.
pins | Pin configuration from uart1_pins_t enum |
#define uart1_mode1_timer2_1T_start | ( | baudrate | ) |
Start UART1 communication with standart baudrate value.
baudrate | const uart1_mode1_timer2_1t_baudrate_t Baudrate selection from uart1_mode1_timer2_1t_baudrate_t enum |
#define uart1_mode1_timer2_1T_start_ext | ( | baudrate | ) |
Start UART1 communication with baudrate value.
baudrate | const uint32_t Baudrate value. Value may be non standard (not in 1200, 9600 etc). |
#define uart1_mode1_timer2_1T_stop (bit_clr(AUXR, CBIT4)) |
Stop UART1 communication and disable Timer2.
#define uart1_mode1_timer2_1T_ticks | ( | baudrate | ) | (65536 - (((MAIN_Fosc / baudrate) >> 2) >> get_frequency_divider_scale())) |
Get UART1 ticks for given baudrate and frequency divider scale.
Ticks used as input parameter for uart1_mode1_timer2_1T_start_ext()
baudrate | uint32_t baudrate |