7026uart接口
0赞
发表于 1/11/2012 5:53:48 PM
阅读(3044)
ADI公司在夏令营中要用到数据传输的实验,那我就把一些7026关于数据传输的程序写给大家看看吧
#include#define CR 0x0D int putchar(int ch); char getchar2(void); int write(char*ptr,int len); char output1[65]; int main(void){ unsigned char jchar=0x30; int i; GP1CON=0x011; COMCON0 = 0x80; // Setting DLAB COMDIV0 = 0x88; COMDIV1 = 0x00; COMCON0 = 0x07; // Clearing DLAB GP4DAT=0x04000000; while(1) { for(i = 0;i <64;i++) { output1[i] = getchar2(); } i = 0; // output1[64] = 0x00; //char output1[13]=getchar2(); GP4DAT^=0x00040000; write(output1,65); // jchar=getchar(); } } int putchar2(int ch) { /* Write character to Serial Port */ if(ch =='\n'){ while(!(0x020==(COMSTA0 & 0x020))) {} COMTX=CR; } while(!(0x020==(COMSTA0 & 0x020))) {} return (COMTX = ch); } char getchar2 (void) { while(!(0x01==(COMSTA0 & 0x01))) {} return (COMRX); } int write ( char * ptr, int len) { int i; for (i = 0; i < len; i++) putchar2 (*ptr++); return len; } 实验的结果:

