阅读:1960回复:1
请教串口编程的问题,高手帮忙看看
我想使用winio软件,直接对pc的串口操作,在win xp系统下,使用vc.
下面的程序是对com1的,想读lcr寄存器,但是总是ffh,帮忙看看 以前没搞过 给点儿意见,非常感谢 #include <windows.h> #include <stdio.h> #include <conio.h> #include "winio.h" #define REG_RX 0x3F8 #define REG_TX 0x3F8 #define REG_IER 0x3F9 #define REG_IIR 0x3FA #define REG_LCR 0x3FB #define REG_MCR 0x3FC #define REG_LSR 0x3FD #define REG_MSR 0x3FE #define REG_FCR 0x3FA void f_InitialCom() { _outp(REG_LCR,0x80);//置DLAB为1 _outp(REG_TX,0x78); //9600波特率的除数低8位 _outp(REG_IER,0); //9600波特率的除数高8位 _outp(REG_LCR,0x03);//通信数据格式,无校验,1停止位,8位数据 _outp(REG_IER,0); //禁止中断 _outp(REG_FCR,0x80);//使能FIFO缓冲功能 } void main() { int inVal=0,outVal; bool bResult; // Call InitializeWinIo to initialize the WinIo library. bResult = InitializeWinIo(); if (bResult) { // Under Windows NT/2000/XP, after calling InitializeWinIo, // you can call _inp/_outp instead of using GetPortVal/SetPortVal f_InitialCom(); _outp(REG_LCR,0x80); printf("LCR:%Xh\n",_inp(REG_LCR)); // When you're done using WinIo, call ShutdownWinIo ShutdownWinIo(); } else { printf("Error during initialization of WinIo.\n"); exit(1); } } |
|
沙发#
发布于:2007-05-04 16:44
没人给看看啊?
主程序里就两句话,我就想知道为什么读com1寄存器读出来但不对,全是ff,给点意见. 这里没人使用winio? |
|