广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 2690 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为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.012527 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言