亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? 80c196kc的高速輸入口和高速輸出口模擬一個全雙工的串口.txt

?? c51源程序總結
?? TXT
字號:
初學者:請大家?guī)兔Γ。。。。?[2shift] [26次] 01-8-8 下午 03:40:25
我想用80c196kc的高速輸入口和高速輸出口模擬一個全雙工的串口,該怎么來實現(xiàn)?
請大家出出主意! 我的郵箱是: liu7705250@163.com
或:a80c196@263.net 

網(wǎng)上找到的,應該可以參考 [power27] [22次] 01-8-8 下午 04:41:04 
IAR Application Note G - 001
1
IAR Application Note G - 001
Generic Software Uart
written in C
SUMMARY
This application note details a generic software UART written in C which
can be implemented on any microprocessor with a C compiler. It requires a
timer interrupt to be set to 3 times the baud rate, and two software-controlled
pins for the receive and transmit functions.
KEYWORDS
UART, C code
The Problem to be solved
Software UARTs are generally coded in assembly for speed purposes, but
with the increasing speed of processors, a software UART written in C is now
easily implemented and highly portable.
The Difficulties Involved
The implementation has three fundamental requirements:
1. A compiler must exist for the microprocessor.
2. A timer interrupt must be set to interrupt at three times the required
baud rate. Most microprocessors have a timer interrupt that can be
used for this, or an external clock interrupt could be used to achieve
the same goal.
3. There must be a transmit pin which can be set from the software, and a
receive pin which can be read by the software.
The Solution
The C source file must be linked into the user’s application with the necessary
interface routines listed as follows:
1. void get_rx_pin_status( void )
Returns 0 or 1 dependent on whether the receive pin is high or low.
2. void set_tx_pin_high( void )
Sets the transmit pin to the high state.
3. void set_tx_pin_low( void )
Sets the transmit pin to the low state.
4. void idle( void )
Background functions to execute while waiting for input.
5. void timer_set( int BAUD_RATE )
Sets the timer to 3 times the baud rate.
// UART.C
//
// Generic software uart written in C, requiring a timer set to 3 times
// the baud rate, and two software read/write pins for the receive and
// transmit functions.
//
// * Received characters are buffered
// * putchar(), getchar(), kbhit() and flush_input_buffer() are available
// * There is a facility for background processing while waiting for input
//
// Colin Gittins, Software Engineer, Halliburton Energy Services
//
// The baud rate can be configured by changing the BAUD_RATE macro as
// follows:
//
// #define BAUD_RATE            19200.0
//
// The function init_uart() must be called before any comms can take place
//
// Interface routines required:
// 1. get_rx_pin_status()
//    Returns 0 or 1 dependent on whether the receive pin is high or low.
// 2. set_tx_pin_high()
//    Sets the transmit pin to the high state.
// 3. set_tx_pin_low()
//    Sets the transmit pin to the low state.
// 4. idle()
//    Background functions to execute while waiting for input.
// 5. timer_set( BAUD_RATE )
//    Sets the timer to 3 times the baud rate.
// 6. set_timer_interrupt( timer_isr )
//    Enables the timer interrupt.
//
// Functions provided:
// 1. void flush_input_buffer( void )
//    Clears the contents of the input buffer.
// 2. char kbhit( void )
//    Tests whether an input character has been received.
// 3. char getchar( void )
//    Reads a character from the input buffer, waiting if necessary.
// 4. void turn_rx_on( void )
//    Turns on the receive function.
// 5. void turn_rx_off( void )
//    Turns off the receive function.
// 6. void putchar( char )
//    Writes a character to the serial port.

#include <stdio.h>

#define BAUD_RATE        19200.0

#define IN_BUF_SIZE        256

#define TRUE 1
#define FALSE 0

static unsigned char        inbuf[IN_BUF_SIZE];
static unsigned char        qin = 0;
static unsigned char        qout = 0;

static char             flag_rx_waiting_for_stop_bit;
static char             flag_rx_off;
static char             rx_mask;
static char             flag_rx_ready;
static char             flag_tx_ready;
static char             timer_rx_ctr;
static char             timer_tx_ctr;
static char             bits_left_in_rx;
static char             bits_left_in_tx;
static char             rx_num_of_bits;
static char             tx_num_of_bits;
static char            internal_rx_buffer;
static char            internal_tx_buffer;
static char            user_tx_buffer;

void timer_isr(void)
    {
    char            mask, start_bit, flag_in;

// Transmitter Section
    if ( flag_tx_ready )
        {
        if ( --timer_tx_ctr<=0 )
            {
            mask = internal_tx_buffer&1;
            internal_tx_buffer >>= 1;
            if ( mask )
                {
                set_tx_pin_high();
                }
            else
                {
                set_tx_pin_low();
                }
            timer_tx_ctr = 3;
            if ( --bits_left_in_tx<=0 )
                {
                flag_tx_ready = FALSE;
                }
            }
        }
// Receiver Section
    if ( flag_rx_off==FALSE )
        {
        if ( flag_rx_waiting_for_stop_bit )
            {
            if ( --timer_rx_ctr<=0 )
                {
                flag_rx_waiting_for_stop_bit = FALSE;
                flag_rx_ready = FALSE;
                internal_rx_buffer &= 0xFF;
                if ( internal_rx_buffer!=0xC2 )
                    {
                    inbuf[qin] = 
internal_rx_buffer;
                    if ( ++qin>=IN_BUF_SIZE )
                        {
                        qin = 0;
                        }
                    }
                }
            }
        else        // rx_test_busy
            {
            if ( flag_rx_ready==FALSE )
                {
                start_bit = get_rx_pin_status();
// Test for Start Bit
                if ( start_bit==0 )
                    {
                    flag_rx_ready = TRUE;
                    internal_rx_buffer = 0;
                    timer_rx_ctr = 4;
                    bits_left_in_rx = 
rx_num_of_bits;
                    rx_mask = 1;
                    }
                }
            else    // rx_busy
                {
                if ( --timer_rx_ctr<=0 )
                    {        
        // rcv
                    timer_rx_ctr = 3;
                    flag_in = 
get_rx_pin_status();
                    if ( flag_in )
                        {
                    
    internal_rx_buffer |= rx_mask;
                        }
                    rx_mask <<= 1;
                    if ( --
bits_left_in_rx<=0 )
                        {
                    
    flag_rx_waiting_for_stop_bit = TRUE;
                        }
                    }
                }
            }
        }
    }

void init_uart( void )
    {
    flag_tx_ready = FALSE;
    flag_rx_ready = FALSE;
    flag_rx_waiting_for_stop_bit = FALSE;
    flag_rx_off = FALSE;
    rx_num_of_bits = 10;
    tx_num_of_bits = 10;

    set_tx_pin_low();

    timer_set( BAUD_RATE );
    set_timer_interrupt( timer_isr );     // Enable timer interrupt
    }

char _getchar( void )
    {
    char        ch;

    do
        {
        while ( qout==qin )
            {
            idle();
            }
        ch = inbuf[qout] & 0xFF;
        if ( ++qout>=IN_BUF_SIZE )
            {
            qout = 0;
            }
        }
    while ( ch==0x0A || ch==0xC2 );
    return( ch );
    }

void _putchar( char ch )
    {
    while ( flag_tx_ready );
    user_tx_buffer = ch;

// invoke_UART_transmit
    timer_tx_ctr = 3;
    bits_left_in_tx = tx_num_of_bits;
    internal_tx_buffer = (user_tx_buffer<<1) | 0x200;
    flag_tx_ready = TRUE;
    }

void flush_input_buffer( void )
    {
    qin = 0;
    qout = 0;
    }

char kbhit( void )
    {
    return( qin!=qout );
    }

void turn_rx_on( void )
    {
    flag_rx_off = FALSE;
    }

void turn_rx_off( void )
    {
    flag_rx_off = TRUE;
    }


謝謝您! [2shift] [1次] 01-8-8 下午 04:49:25 

 
點擊這里回復這篇貼子>>
_____________________________________________________________________________
Copyright?,C51BBS論壇 2000-2001 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲综合色自拍一区| av在线不卡网| 成人午夜免费视频| 91精品一区二区三区久久久久久 | 国产精品中文字幕一区二区三区| 色欧美片视频在线观看 | 国产精品久久久久久久浪潮网站| 奇米精品一区二区三区在线观看| 色综合久久综合网| 国产精品成人在线观看| 国产一级精品在线| 欧美成人乱码一区二区三区| 亚洲国产婷婷综合在线精品| www.色精品| 国产欧美一区二区精品婷婷| 九九久久精品视频| 日韩欧美不卡一区| 日韩国产欧美三级| 欧美精品自拍偷拍动漫精品| 亚洲一区在线观看免费 | 精品写真视频在线观看| 国产成人av福利| 精品国偷自产国产一区| 日本欧美久久久久免费播放网| 色视频成人在线观看免| 中文字幕av不卡| 国产.欧美.日韩| 欧美—级在线免费片| 国产麻豆视频一区| 久久久亚洲精华液精华液精华液| 国产一区二区三区观看| 精品精品国产高清一毛片一天堂| 激情欧美一区二区三区在线观看| 精品第一国产综合精品aⅴ| 丁香婷婷综合色啪| 国产精品高潮呻吟| 一本色道久久综合亚洲精品按摩| 亚洲综合男人的天堂| 欧美色爱综合网| 强制捆绑调教一区二区| 久久综合久久久久88| 国产激情偷乱视频一区二区三区| 中文字幕精品综合| 色哟哟国产精品| 五月婷婷久久丁香| 精品欧美乱码久久久久久| 国产高清一区日本| 亚洲日本在线观看| 欧美一区二区三区色| 国产呦萝稀缺另类资源| 国产精品无码永久免费888| 一本色道久久加勒比精品| 午夜视频在线观看一区二区| 精品少妇一区二区三区在线视频| 粉嫩av亚洲一区二区图片| 亚洲蜜臀av乱码久久精品 | 日韩一区精品字幕| 欧美一二三区精品| 国产91在线|亚洲| 亚洲精品大片www| 制服丝袜成人动漫| 国产精品一区二区在线观看不卡 | 精品国产91久久久久久久妲己 | 国产精品护士白丝一区av| 欧美影片第一页| 国产一区二区在线视频| 亚洲色图欧洲色图| 精品日韩欧美在线| 91麻豆国产自产在线观看| 免费成人在线观看视频| 亚洲日本va在线观看| 欧美xxx久久| 欧美综合久久久| 国模无码大尺度一区二区三区| 最新中文字幕一区二区三区| 欧美一区二区三区视频| 91免费观看视频在线| 国产主播一区二区| 日韩av午夜在线观看| 日韩毛片精品高清免费| 精品福利视频一区二区三区| 欧美亚洲一区二区三区四区| 国产乱人伦偷精品视频免下载| 亚洲午夜久久久| 国产精品久久久久久亚洲毛片| 日韩精品自拍偷拍| 欧美三日本三级三级在线播放| 丁香六月综合激情| 国内精品视频666| 日本va欧美va瓶| 亚洲成人av电影在线| 亚洲丝袜自拍清纯另类| 中文字幕精品一区二区精品绿巨人 | 久久99久久久久| 亚洲一区二区av在线| 国产精品久久久久久户外露出| www激情久久| 精品理论电影在线观看| 欧美一区二区视频观看视频 | 中文字幕免费不卡在线| 久久久亚洲国产美女国产盗摄 | 欧美日韩一区不卡| 在线免费观看一区| 色综合久久中文综合久久牛| 99久久国产免费看| 成人av动漫网站| 成人午夜大片免费观看| 国产不卡一区视频| 国产91清纯白嫩初高中在线观看 | 精品污污网站免费看| 欧美性一级生活| 色噜噜狠狠色综合中国| 日本高清不卡在线观看| 欧美综合亚洲图片综合区| 欧美影院精品一区| 欧美精品一二三四| 欧美精品v日韩精品v韩国精品v| 欧美色区777第一页| 宅男噜噜噜66一区二区66| 在线不卡免费av| 日韩一区二区免费高清| 日韩久久久精品| 国产亚洲人成网站| 最新中文字幕一区二区三区 | 欧美日韩mp4| 欧美成人性战久久| 久久精品无码一区二区三区| 国产精品国产三级国产普通话三级 | 久久美女高清视频| 国产精品美女一区二区在线观看| 最新国产成人在线观看| 亚洲中国最大av网站| 美国毛片一区二区三区| 国产精品一二二区| 日本电影欧美片| 91精品国产91久久久久久最新毛片| 精品久久久久久久久久久久包黑料| 国产亚洲午夜高清国产拍精品| 国产精品传媒视频| 日本午夜精品一区二区三区电影| 国产伦精品一区二区三区视频青涩 | 91精品国产91久久综合桃花| 精品久久久久一区| 国产精品初高中害羞小美女文| 亚洲一级不卡视频| 国产一区三区三区| 91伊人久久大香线蕉| 欧美绝品在线观看成人午夜影视| 久久影院视频免费| 亚洲最色的网站| 久久国产夜色精品鲁鲁99| 99精品欧美一区二区三区小说 | 成人永久aaa| 欧美主播一区二区三区美女| 日韩精品影音先锋| 中文字幕一区二区在线播放| 午夜精品久久久久久久 | 欧美日本不卡视频| 久久综合狠狠综合久久综合88| 一区二区三区四区激情 | 免费看日韩精品| 91在线观看地址| 精品国产网站在线观看| 一区二区三区不卡视频 | 欧美精品乱码久久久久久按摩| 国产亚洲精品福利| 日韩成人伦理电影在线观看| 99精品1区2区| 欧美高清在线一区| 久久精品国产99| 欧美精品123区| 亚洲精品国产a| 成人在线视频一区| 久久综合九色综合欧美亚洲| 午夜国产精品一区| 色婷婷国产精品| 国产精品欧美久久久久一区二区| 激情丁香综合五月| 欧美一区二区三区四区视频| 一区二区欧美精品| 99国产精品久久久久久久久久久 | 五月综合激情网| 成人一区二区三区视频 | 久久久国产精品不卡| 一区二区三区电影在线播| 在线免费观看日本欧美| 五月激情丁香一区二区三区| 8x8x8国产精品| 国内精品伊人久久久久av影院| 国产日本亚洲高清| 一本久久a久久精品亚洲| 午夜精品久久久久久久99水蜜桃 | 99re这里只有精品首页| 一区二区三区精品视频| 777久久久精品| 国产一区二区女| 伊人婷婷欧美激情| 欧美变态口味重另类| 99久久免费精品| 日韩精品电影一区亚洲|