廣告廣告
  加入我的最愛 設為首頁 風格修改
首頁 首尾
 手機版   訂閱   地圖  簡體 
您是第 2676 個閱讀者
 
發表文章 發表投票 回覆文章
  可列印版   加為IE收藏   收藏主題   上一主題 | 下一主題   
aniegg
數位造型
個人文章 個人相簿 個人日記 個人地圖
初露鋒芒
級別: 初露鋒芒 該用戶目前不上站
推文 x0 鮮花 x26
分享: 轉寄此文章 Facebook Plurk Twitter 複製連結到剪貼簿 轉換為繁體 轉換為簡體 載入圖片
推文 x0
[C/C++] RS232 demo後問題
下面程式碼我是用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 >> ..

訪客只能看到部份內容,免費 加入會員 或由臉書 Google 可以看到全部內容




颯風沾、問途寒,誰與共飲,誰敢擋關?
燕戟歸命人不還。
獻花 x0 回到頂端 [樓 主] From:台灣教育部 | Posted:2005-12-01 15:57 |

首頁  發表文章 發表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.018363 second(s),query:15 Gzip disabled
本站由 瀛睿律師事務所 擔任常年法律顧問 | 免責聲明 | 本網站已依台灣網站內容分級規定處理 | 連絡我們 | 訪客留言