usart_common

USART common

Author Stef Mientki Copyright (c) 2002..2010, all rights reserved.
Adapted-by Sebastien Lelong, Joep Suijs
Compiler >=2.4g

Description

USART common functions
This file provides common functions to other libraries.



Baudrate can simply be set through a human constant,
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.


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions


API details

Global variables/contants

Procedures

Private
  • _calculate_and_set_baudrate()

    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 (see also page 74/75 of DS40300B):
    {{{
    if TXSTA_BRGH = 0 (low speed)
     SPBRG = ( Fosc / ( 64 * Baudrate ) ) -1
    
    if TXSTA_BRGH = 1 (high speed)
     SPBRG = ( Fosc / ( 16 * Baudrate ) ) -1
    }}}
    
    Synchronous baudrate settings:
     * TXSTA_BRGH = 0 (low speed)
     * SPBRG = ( Fosc / ( 4 * Baudrate ) ) -1
    
    


Functions


Related samples

No sample found