您当前的位置:五五电子网电子知识单片机-工控设备PIC单片机16C5X模拟串口 正文
16C5X模拟串口

16C5X模拟串口

点击数:7664 次   录入时间:03-04 11:50:53   整理:http://www.55dianzi.com   PIC单片机

, ; *******************************************************************
;   Plug in Libraries for the by 12 architecture                    *
;   Written and Tested using MPASM V1.40                            *
;********************************************************************
;   Filename:        SWUART12.ASM                                *
;   Date:               05 November 1997                            *
;   File Version:       1.00                                        *
;********************************************************************
;   Functions:                                                      *
;                                                                   *
;            OpenUART                                    *
;            getcUART                                    *
;            putcUART                                    *
;********************************************************************
;   Revision History:                                               *
;      V1.00 - Beta release of Peripheral Libraries                 *
;********************************************************************
;   Notes:                                                          *
;     - Change these parameters as needed and reassemble the library *
;
        title "SOFtware UART for by 12 Architecture.
    list p=pIC16c5x
#include <p16c5x.inc>
;
#define UARTPORT PORTA
#define TXPIN  3        
#define RXPIN  2        
#define TRISMASK  0x04
;
MODE  equ     1       ; If ( X_MODE==1) Then transmit LSB first
Nbit  equ     1       ; if (X_Nbit==1) # of data bits ( Transmission ) 
;                              is 8 else 7
STOPBITS   equ  0     ; if Sbit2 = 0 then 1 Stop Bit else 2 Stop Bits
CLOCKSPEED equ  10
BAUDRATE   equ  9600
;
; *******************************************************************
;
    if UARTPORT < 5 || UARTPORT > 7
        messg "Invalid port value"
    endif
    if RXPIN > 7
        messg "Invalid rxpin value"
    endif

    if TXPIN > 7
        messg "Invalid txpin value"
    endif

; both Rx and Tx pins must be on the same port
portmask = ((0x01 << RXPIN) | TRISMASK) & ~(0x01 << TXPIN)
;
;
LSB     equ     0
MSB     equ     7

;*****************  Communication Parameters   **************************
;
    ifndef MODE
MODE  equ     1       ; If ( X_MODE==1) Then transmit LSB first
;                         if ( X_MODE==0) Then transmit MSB first ( CODEC like )
    endif
    ifndef Nbit
Nbit  equ     1       ; if (X_Nbit==1) # of data bits ( Transmission ) is 8 else 7
    endif

[1] [2] [3] [4] [5]  下一页


本文关键字:暂无联系方式PIC单片机单片机-工控设备 - PIC单片机