论坛元老
- 积分
- 6661
- 金钱
- 6661
- 注册时间
- 2016-5-29
- 在线时间
- 909 小时
|
直接上代码
;中断服务程序
ORG 0H
NOP
RST
ORG 8H
ISR()
{
COPYA = A
SWAPR COPYA,1
COPYS = STATUS
IF PBIF
{
INTF = 0XFD
PORTA = PORTA
TMR0 = TMR0_INIT_VAL104
}
IF T1IF
{
INTF = 0XF7
TICK = 1
IF UART_BIT_N
{
IF UART_BIT_N = 10
{
TX = 0
}
ELSE
IF UART_BIT_N = 1
{
TX = 1
}
ELSE
{
UART_TD >>>
TX = FC
}
IF UART_BIT_N --
{
UART_BUF_N ++
IF UART_BUF_N < UART_SEND_LEN
{
MOVIA TX_BUF; ---------- A = BUF#UART_BUF_N
ADDAR UART_BUF_N,0
MOVAR FSR
BANK1 = 1
MOVR INDF,0
BANK1 = 0
UART_TD = A
UART_BIT_N = 10
}
}
}
}
IF T0IF
{
INTF = 0XFE
TMR0 = TMR0_INIT_VAL
IF RX_BUF_N < 9
{
FC = RX
UART_RD >>>
}
RX_BUF_N ++
IF RX_BUF_N = 1
IF RX
{
RX_BUF_N = 0
}
ELSE
IF RX_BUF_N = 10
{
RX_BUF_N = 0
IF RX
{
MOVIA RX_BUF
ADDAR RXN , 0
MOVAR FSR
A = UART_RD
BANK1 = 1
INDF = A
BANK1 = 0
RXN ++
RXN & 0X0F
RXTIME = 10
}
}
}
STATUS = COPYS
SWAPR COPYA,0
RETIE
}
|
|