Author | Stef Mientki Copyright (c) 2002..2010, all rights reserved. |
Adapted-by | Sebastien Lelong, Joep Suijs, Rob Hamerling |
Compiler | >=2.4n |
USART2 common functions This file provides common functions to other libraries. Baudrate can simply be set through a constant in the application program, because the baudrate depending registers are calculated by this unit. Baudrate is calculated, starting at the high baudrate flag, which will ensure the highest possible accuracy.
No dependency found
_calculate_and_set_baudrate2()
internal function, calculates and sets baudrate divider and stores it in the appropiate register. the high-speed / low-speed bit is not stored but returned as the result Special attention is payed to the highest and lowest baudrates, a deviation of 5% is accepted in these cases Asynchronous baudrate settings {{{ for ESUART (with 16 bits baudrate generator) SPBRGH2/SPBRG2 = ( Fosc / ( 4 * Baudrate ) ) -1 if TXSTA2_BRGH = 1 (high speed) SPBRG2 = ( Fosc / ( 16 * Baudrate ) ) -1 if TXSTA2_BRGH = 0 (low speed) SPBRG2 = ( Fosc / ( 64 * Baudrate ) ) -1 }}} Synchronous baudrate settings: * TXSTA2_BRGH = 0 (low speed) * SPBRG2 = ( Fosc / ( 4 * Baudrate ) ) -1