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

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

?? 80c196kc

?? 里面包括很多的驅動程序的
??
字號:
初學者:請大家幫忙!!!!! [2shift] [26次] 01-8-8 下午 03:40:25
我想用80c196kc的高速輸入口和高速輸出口模擬一個全雙工的串口,該怎么來實現?
請大家出出主意! 我的郵箱是: liu7705250@163.com
或:a80c196@263.net 

網上找到的,應該可以參考 [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一区二区三区免费野_久草精品视频
91精品国产综合久久福利| 欧美一区二区日韩| 成人网在线播放| 成人av在线影院| 风间由美一区二区av101| 国产精品伊人色| 色中色一区二区| 欧美日韩一区高清| 久久一日本道色综合| 一区视频在线播放| 免费看日韩精品| 成人免费视频视频在线观看免费 | 国产精品一级二级三级| 91福利视频久久久久| 欧美久久一区二区| 国产精品私人自拍| 不卡一区二区三区四区| 欧美老肥妇做.爰bbww| 国产精品美女一区二区| 三级久久三级久久| 91美女片黄在线| 久久久久国产一区二区三区四区 | 99国产精品99久久久久久| 欧美福利视频一区| 亚洲欧美日韩国产综合在线 | 欧美午夜精品一区二区蜜桃| 国产精品久久久久久妇女6080 | 精品动漫一区二区三区在线观看| 中文字幕一区二区三区在线播放 | 亚洲一级在线观看| 粉嫩aⅴ一区二区三区四区| 日韩欧美另类在线| 亚洲va韩国va欧美va精品| 色婷婷亚洲精品| 综合分类小说区另类春色亚洲小说欧美| 狠狠色综合播放一区二区| 91首页免费视频| 国产精品久久久久久久久免费丝袜| 婷婷国产在线综合| 精品视频色一区| 蜜桃久久久久久| 久久婷婷一区二区三区| www.亚洲人| 一区二区三区不卡视频在线观看| 成人激情开心网| 亚洲在线免费播放| 欧美丰满高潮xxxx喷水动漫| 视频一区二区三区中文字幕| 在线不卡中文字幕| 成人永久免费视频| 亚洲最新视频在线播放| 日韩一级片在线播放| 国产成人免费视频一区| 欧美国产精品一区| 欧美三级欧美一级| 粉嫩一区二区三区在线看| 亚洲视频图片小说| 91精品国产欧美一区二区成人 | 91精品国产色综合久久久蜜香臀| 国产精品一区三区| 一区二区三区免费看视频| 日韩一卡二卡三卡国产欧美| 国产a久久麻豆| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产网站一区二区三区| 欧美在线播放高清精品| 国产精品资源在线| 午夜激情综合网| 中文字幕一区二区三区四区| 精品日韩欧美一区二区| 日本久久电影网| av成人免费在线观看| 国产美女一区二区| 日韩精品免费视频人成| 亚洲精品中文字幕乱码三区| 久久精品欧美一区二区三区麻豆| 欧美日韩高清在线播放| 色综合久久66| 在线观看中文字幕不卡| 99久久精品国产导航| av男人天堂一区| 欧美一区二区三区在| 67194成人在线观看| 欧美美女激情18p| 88在线观看91蜜桃国自产| 欧美视频三区在线播放| 欧美日本精品一区二区三区| 欧美一级片在线观看| 欧美一区二区黄| 欧美精品一区二区三区在线| 精品久久五月天| 国产精品婷婷午夜在线观看| 中文字幕一区日韩精品欧美| 亚洲欧美另类图片小说| 亚洲国产人成综合网站| 日本美女一区二区三区视频| 国产在线日韩欧美| 91蝌蚪国产九色| 91精品国产免费久久综合| 久久久无码精品亚洲日韩按摩| 国产精品久久久久婷婷| 午夜精品福利一区二区三区av| 国内精品免费**视频| 色偷偷88欧美精品久久久| 日韩欧美卡一卡二| 久久伊人蜜桃av一区二区| 在线视频综合导航| 久久国产精品色婷婷| 91同城在线观看| 亚洲精品成人精品456| 欧美影视一区在线| 首页国产丝袜综合| 精品少妇一区二区三区视频免付费| 青青草成人在线观看| 精品粉嫩超白一线天av| 国产精品66部| 在线综合+亚洲+欧美中文字幕| 久久久精品国产免费观看同学| 亚洲aⅴ怡春院| 一本色道久久综合亚洲91| 久久久国产精品午夜一区ai换脸| 视频一区在线视频| 在线播放中文一区| 亚洲一区二区三区视频在线| 91免费版在线| 久久久精品影视| 极品少妇一区二区三区精品视频 | 国产精品色哟哟网站| 极品美女销魂一区二区三区| 337p亚洲精品色噜噜噜| 日韩精彩视频在线观看| 精品视频一区三区九区| 亚洲已满18点击进入久久| 欧洲一区二区三区在线| 亚洲国产wwwccc36天堂| 91精品国产一区二区| 国产一区二区0| 亚洲欧美日韩国产另类专区| 91片在线免费观看| 亚洲一二三区不卡| 欧美精品一区男女天堂| 欧美性猛片aaaaaaa做受| 精品一区二区三区在线播放| 亚洲成av人片一区二区三区| 国产亲近乱来精品视频| 在线精品视频免费播放| 国产一区二区三区在线观看免费| 亚洲精品国产无天堂网2021| 久久综合久久久久88| 欧美在线不卡一区| 成人97人人超碰人人99| 精品一区二区三区在线视频| 一区二区三区中文免费| 亚洲国产精品精华液2区45| 91精品国产色综合久久久蜜香臀| 91美女在线观看| 日本伊人色综合网| 午夜精彩视频在线观看不卡| 亚洲一区在线电影| 亚洲一区二区视频| 亚洲国产精品久久久久婷婷884| 亚洲免费电影在线| 亚洲精品成人少妇| 国产三级三级三级精品8ⅰ区| 欧美人妖巨大在线| 欧美性生活一区| 91亚洲资源网| 成人h精品动漫一区二区三区| 久久国产成人午夜av影院| 欧美电影精品一区二区| 欧美吞精做爰啪啪高潮| 91在线观看地址| 日本久久一区二区三区| 色成年激情久久综合| 91丨porny丨首页| 色呦呦国产精品| 欧美日韩国产高清一区二区三区| 91精品久久久久久久99蜜桃| 91精品国产综合久久精品| 美女一区二区久久| 一区二区三区四区亚洲| 亚洲国产精品久久不卡毛片 | 免费观看久久久4p| 成人午夜免费av| 懂色av一区二区在线播放| www.欧美色图| 在线播放欧美女士性生活| 久久久久9999亚洲精品| 亚洲精品中文字幕在线观看| 青青青伊人色综合久久| 91在线视频网址| 日韩午夜精品电影| 久久综合狠狠综合久久激情| 欧美激情一区不卡| 亚洲视频小说图片| 午夜精品免费在线观看| 国产精品一区二区在线播放| 成年人国产精品| 日韩一区二区三区免费观看| 久久久精品日韩欧美|