?? uarta.c
字號(hào):
/*cjk-dsp-2003-5-10*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/*#include <limits.h>*/
#include <float.h>
asm("pmst .set 0ffe4h ");
asm("icr .set 0ffech ");
asm("wsgr .set 0fffch ");
asm("sdtr .set 0fff0h ");
asm("sspcr .set 0fff1h ");
asm("adtr .set 0fff4h");
asm("aspcr .set 0fff5h");
asm("iosr .set 0fff6h");
asm("brd .set 0fff7h");
asm("tcr .set 0fff8h");
asm("prd .set 0fff9h");
asm("ifr .set 0006h");
asm("imr .set 0004h");
asm("greg .set 0005h");
asm("cr8251 .set 8001h");
asm("dr8251 .set 8000h");
unsigned char counter[9],rend=0,send=0,wang_flag;
int t8251[10], innum[10];
void CouRead();
void tranini();
void CounterInit()
{ int i;
for(i=0;i<=1;i++)
asm(" ldp #0h");
asm(" splk #34h,60h"); //初始化定時(shí)器
asm(" splk #00h,61h");
asm(" splk #74h,62h");
asm(" splk #0b4h,63h");
asm(" out 60h,0103h");
asm(" out 61h,0100h");
asm(" out 61h,0100h");
asm(" out 62h,0103h");
asm(" out 61h,0101h");
asm(" out 61h,0101h");
asm(" out 63h,0103h");
asm(" out 61h,0102h");
asm(" out 61h,0102h");
asm(" out 60h,0203h");
asm(" out 61h,0200h");
asm(" out 61h,0200h");
for(i=0;i<=1;i++);
}
main()
{
int i,k,aflg=0;
for (i=0;i<9;i++) t8251[i]=i;
asm(" setc intm ");
asm(" clrc cnf");
asm(" setc xf");
asm(" LDP #0H ");
asm(" nop");
asm(" SPLK #04H,60H");
asm(" NOP");
asm(" OUT 60H,pmst");
asm(" splk #0e40h,64h");
asm(" nop");
asm(" out 64h,wsgr");
asm(" splk #0000h,63h");
asm(" nop");
asm(" out 63h,greg");
asm(" splk #0000h,60h");
asm(" out 60h,sspcr");
asm(" splk #082fh,63h"); //定時(shí)器
asm(" nop");
asm(" out 63h,tcr ");
asm(" splk #0efffh,62h");
asm(" nop");
asm(" out 62h,prd ");
asm(" ldp #0h");
asm(" nop");
/*asm(" splk #0c100h,61h");*/
asm(" splk #0c080h,61h");
asm(" out 61h,aspcr");
asm(" splk #0fffh,62h");
asm(" out 62h,iosr");
asm(" splk #0104h,63h");
asm(" out 63h,brd ");
/*asm(" splk #0e100h,61h");*/
asm(" splk #0e080h,61h");
asm(" out 61h,aspcr"); //復(fù)位異步串口
/*asm(" mar *,ar3");
asm(" lar ar3, #(_t8251)");
asm(" mar *+");
asm(" sar ar3,76h");*/ //要發(fā)送的字符串的首地址
/*asm(" clrc xf");*/
for (i=0;i<=20000;i++) { asm(" nop");}
asm(" LDP #0H ");
asm(" splk #00AAh,61h"); //空操作
asm(" out 61h,cr8251");
for (i=0;i<=20;i++) { asm(" nop");}
/* asm(" out 61h,cr8251");
asm(" out 61h,cr8251"); */
asm(" nop");
asm(" splk #0050h,61h"); //復(fù)位
asm(" out 61h,cr8251");
for (i=0;i<=20;i++) { asm(" nop");}
asm(" splk #004eh,61h");
asm(" out 61h,cr8251"); //設(shè)置8251方式控制字
for (i=0;i<=20;i++) { asm(" nop");}
asm(" LDP #0H ");
asm(" splk #0014h,62h");
asm(" out 62h,cr8251"); //設(shè)置8251命令控制字
for (i=0;i<=20;i++) { asm(" nop");}
asm(" SPLK #003FH,ifr"); //寫(xiě)1清除所有待決的中斷
asm(" SPLK #0026H,imr"); //開(kāi)讀fifo中斷
asm(" splk #001Dh,60h");
asm(" nop");
asm(" out 60h,icr");
asm(" clrc intm "); //打開(kāi)總中斷
/*asm(" in 60h,dr8251");*/
/*CounterInit(); */
asm(" clrc xf");
asm(" splk #000ah,61h"); /*接收10個(gè)數(shù) */
asm(" splk #0009h,64h"); /*發(fā)送10個(gè)數(shù) */
asm(" splk #0070h,6fh"); /*6f記錄接收地址*/
asm(" splk #(_innum) ,6eh");/*6e記錄 數(shù)組 接收地址*/
asm(" mar *,ar3");
asm(" lar ar3,#(_t8251)");
asm(" mar *+");
asm(" sar ar3,6dh");/*6d記錄 數(shù)組 發(fā)送地址*/
/*asm(" splk #0047h,62h");
asm(" out 62h,dr8251"); */
asm(" splk #0070h,6fh"); /*6f記錄接收地址*/
for (i=0;i<10;i++) {t8251[i]=0; innum[i]=0;}
asm(" splk #(_t8251) ,6ch");/*6d記錄 數(shù)組 發(fā)送地址*/
wang_flag=0;
while(1){
if (innum[9]==0x19 ){
asm(" splk #(_innum) ,6eh") ;
/*CouRead(); //讀 8253 */
for (i=0;i<10;i++) t8251[i]=innum[i]+2;
for (i=0;i<40;i++) ;
tranini();
wang_flag=1;
innum[9]=0x00;
}
for(i=0;i<=20;i++) {} ;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -