RS232 demo後問題

Home Home
引用 | 編輯 aniegg
2005-12-01 15:57
樓主
推文 x0
下面程式碼我是用TC寫的,demo後發生RS232無法傳數據,而且鍵盤跟滑鼠整個當機,請各位大大幫幫忙,謝謝!


#include <stdio.h>
#include <conio.h>
#include <dos.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* port characteristic definitions for use with rs_initport */

#define base 0x3f8 /* Port Address Goes Here */

#define THR base+0
#define RBR base+0
#define DLL base+0
#define DLM base+1
#define IER base+1
#define IIR base+2
#define FCR base+2
#define LCR base+3
#define MCR base+4
#define LSR base+5
#define MSR base+6

#define IRQ 0x1c
#define base_812 0x220




/*****************************************************************/
/*** global variables ***/
/*****************************************************************/
/* static variables */
int flag = 0, indx = 0;
int cnt = 0, freq;
float read_volt1=0;
double ad812;
unsigned char data;


/* dynamic variables */
float read_AD_volt(unsigned int chan)
{
unsigned char hibyte,lowbyte;

outportb(base_812+10,chan);
outportb(base_812+9,0);
outportb(base_812+12,1);

while(1) {
hibyte=inportb(base_812+5);
if ( (hibyte&0x10) == 0 )
break;
}

hibyte=inportb(base_812+5);
lowbyte=inportb(base_812+4);
return(((hibyte%16)*256+lowbyte)-2048)/4096.0*20;
}


void PC_tickset(int freq)
{
int cn;
if (freq == 18) {
cn = 0;
}
else if (freq > 0){
cn=(int)(((long)2386360L/freq+1) >> 1);
}
else{
cn=0;
}
outp(0x43,0x36);
outp(0x40,cn & 0xFF);
outp(0x40,(cn >> ..

訪客只能看到部份內容,免費 加入會員



獻花 x0