2020-01-02 19:39发布
iamlangzi 发表于 2012-11-23 10:34 您好,非常感谢您的回复。能够将这些给大家学习,真是太不容易了! 希望有机会和您多交流! ...
我已将您要的东西移植到 Keil C51 的工程上了,接下来您得自己学习了.
链接: https://pan.baidu.com/s/1iR4oBeyPWuoDb_4b9-4rXA 提取码: z4mb
最多设置5个标签!
我已将您要的东西移植到 Keil C51 的工程上了,接下来您得自己学习了.
链接: https://pan.baidu.com/s/1iR4oBeyPWuoDb_4b9-4rXA 提取码: z4mb
GPIB For Keil C51这个需要看NAT9914的手册,编写函数才行吧
楼主应该是要驱动 NI 的 NAT9914 吧? 我冒着工作不保的风险传给您我们公司商业用的标准驱动代码,希望能带给您学习上的方便.
两个 Void,第一个是初始化的程序,第二个是 NAT9914 中断使用的程序,最后是程序内要使用到的 .h 文件,我能提供的也就这么多了.
P.S. 这 NAT9914 是使用于 24 MHz 的晶震! 所有的注释我都已移除了,盼您能谅解..
- void Init_Gpib(void)
- {
- unsigned char temp_uc;
- char temp_zero=0;
-
- GpibAUXCR=GPIB_CHIPRST;
- GpibAUXCR=GPIB_PIACCR;
- GpibACCR=NAT9914_6MHZ;
- GpibAUXCR=GPIB_PIEOSR;
- GpibEOSR=CR;
- GpibAUXCR=GPIB_PIACCR;
- GpibACCR=0x94;
- GpibADR=GpibAddr;
- temp_uc=GpibISR0;
- temp_uc=GpibISR1;
- temp_uc=GpibISR2;
- GpibSPMR=temp_zero;
- GpibAUXCR=GPIB_PIACCR;
- GpibACCR=0xd0;
- GpibAUXCR=GPIB_NVSTDL;
- GpibAUXCR=GPIB_NSTDL;
- GpibPPR=temp_zero;
- GpibAUXCR=GPIB_NHDFE;
- GpibAUXCR=GPIB_NHDFA;
- GpibAUXCR=GPIB_NSHDW;
- GpibIMR0=0x3f;
- GpibIMR1=0x8d;
- GpibACCR=GPIB_PIIMR2;
- GpibIMR2=0xc8;
- temp_uc=GpibDIR;
- GpibCDOR=temp_zero;
- GpibAUXCR=temp_zero;
- }
- void Gpib_ISR (void) interrupt 0 using 1
- {
- char temp_c,err;
- EX0=0;
- GpibAUXCR=GPIB_DAI;
- GpibIsr0Reg|=GpibISR0;
- GpibIsr1Reg|=GpibISR1;
- GpibIsr2Reg|=GpibISR2;
- if(GpibADSR&GPIB_LA){
- GpibIsr0Reg&=(~GPIB_BO);
- }
- GpibAUXCR=GPIB_DAI;
- if(GpibIsr0Reg&GPIB_INT0){
- GpibIsr0Reg&=(~GPIB_INT0);
- while(1){
- if(GpibIsr0Reg&GPIB_BI){
- GpibIsr0Reg&=(~GPIB_BI);
- temp_c=GpibDIR;
- if(GpibIsr0Reg&GPIB_END){
- GpibIsr0Reg&=(~GPIB_END);
- if(temp_c==LF){
- GpibPutRxChar(temp_c);
- }
- else if(temp_c==CR){
- GpibPutRxChar(temp_c);
- }
- else{
- GpibPutRxChar(temp_c);
- }
- }
- else{
- // GpibPutRxChar(temp_c);
- }
- GpibIsr0Reg|=GpibISR0;
- }
- else
- break;
- }
- if(GpibADSR&GPIB_TA){
- }
- while(1){
- if(GpibIsr0Reg&GPIB_BO){
- temp_c=GpibGetTxChar(&err);
- if(err==COMM_NO_ERR){
- if(IOBufTxCtr==0){
- GpibAUXCR=GPIB_FEOI;
- GpibTxFlag=0;
- }
- GpibIsr0Reg&=(~GPIB_BO);
- GpibCDOR=temp_c;
- GpibIsr0Reg|=GpibISR0;
- }
- else
- break;
- }
- else
- }
- if(GpibIsr0Reg&GPIB_RLC){
- GpibIsr0Reg&=(~GPIB_RLC);
- if((GpibADSR&GPIB_REM)==GPIB_REM){
- }
- }
- if(GpibIsr0Reg&GPIB_MAC){
- GpibIsr0Reg&=(~GPIB_MAC);
- }
- }
- if(GpibIsr0Reg&GPIB_INT1){
- GpibIsr1Reg&=(~GPIB_INT1);
- if(GpibIsr1Reg&GPIB_GET){
- GpibIsr1Reg&=(~GPIB_GET);
- GpibAUXCR=GPIB_NRDAC;
- }
- if(GpibIsr1Reg&GPIB_ERR){
- GpibIsr1Reg&=(~GPIB_ERR);
- GpibAUXCR=GPIB_NBAF;
- }
- if(GpibIsr1Reg&GPIB_DCAS){
- GpibAUXCR=GPIB_RHDF;
- GpibIsr0Reg=0;
- GpibIsr1Reg=0;
- GpibIsr2Reg=0;
- GpibAUXCR=GPIB_NRDAC;
- GpibStbReg&=~(GPIB_MAV);
- }
- if(GpibIsr1Reg&GPIB_MA){
- GpibIsr1Reg&=(~GPIB_MA);
- GpibAUXCR=GPIB_VRDAC;
- }
- if(GpibIsr1Reg&GPIB_IFC){
- GpibIsr1Reg&=(~GPIB_IFC);/
- }
- }
- if(GpibIsr2Reg&GPIB_STBO){
- GpibSPMR=GpibStbReg;
- GpibStbReg&=(~GPIB_RQS);
- }
- if(GpibIsr2Reg&GPIB_LLOC){
- }
- if(GpibADSR&GPIB_LA){
- GpibIsr0Reg&=(~GPIB_BO);
- }
- GpibAUXCR=GPIB_NDAI;
- EX0=1;
- }
- /*下方是 GPIB 要调用到的 GPIB.H 文件*/
- #define IO_GPIB 0x0000
- #define GpibISR0 XBYTE[IO_GPIB]
- #define GpibIMR0 XBYTE[IO_GPIB]
- #define GpibISR1 XBYTE[IO_GPIB+1]
- #define GpibIMR1 XBYTE[IO_GPIB+1]
- #define GpibADSR XBYTE[IO_GPIB+2]
- #define GpibIMR2 XBYTE[IO_GPIB+2]
- #define GpibEOSR XBYTE[IO_GPIB+2]
- #define GpibBCR XBYTE[IO_GPIB+2]
- #define GpibACCR XBYTE[IO_GPIB+2]
- #define GpibBSR XBYTE[IO_GPIB+3]
- #define GpibAUXCR XBYTE[IO_GPIB+3]
- #define GpibISR2 XBYTE[IO_GPIB+4]
- #define GpibADR XBYTE[IO_GPIB+4]
- #define GpibSPSR XBYTE[IO_GPIB+5]
- #define GpibSPMR XBYTE[IO_GPIB+5]
- #define GpibCPTR XBYTE[IO_GPIB+6]
- #define GpibPPR XBYTE[IO_GPIB+6]
- #define GpibDIR XBYTE[IO_GPIB+7]
- #define GpibCDOR XBYTE[IO_GPIB+7]
- #define GPIB_SWRST 0x80
- #define GPIB_NSWRST 0x00
- #define GPIB_CHIPRST 0x1c
- #define GPIB_VRDAC 0x81
- #define GPIB_NRDAC 0x01
- #define GPIB_RHDF 0x02
- #define GPIB_HDFA 0x83
- #define GPIB_NHDFA 0x03
- #define GPIB_HDFE 0x84
- #define GPIB_NHDFE 0x04
- #define GPIB_NBAF 0x05
- #define GPIB_FEOI 0x08
- #define GPIB_LON 0x89
- #define GPIB_NRSV2 0x18
- #define GPIB_RSV2 0x98
- #define GPIB_SW7210 0x99
- #define GPIB_SW9914 0x15
- #define GPIB_PIEOSR 0x9e
- #define GPIB_PIACCR 0x9f
- #define GPIB_PIIMR2 0x1e
- #define GPIB_NTON 0x0a
- #define GPIB_SRE 0x90
- #define GPIB_NVSTDL 0x17
- #define GPIB_NSTDL 0x15
- #define GPIB_STDL 0x95
- #define GPIB_REQT 0x9a
- #define GPIB_NREQT 0x1a
- #define GPIB_RTL 0x87
- #define GPIB_NRTL 0X07
- #define GPIB_SHDW 0x96
- #define GPIB_NSHDW 0X16
- #define GPIB_DAI 0x93
- #define GPIB_NDAI 0X13
- #define GPIB_BIIE 0x20
- #define GPIB_BOIE 0x10
- #define GPIB_ENDIE 0x08
- #define GPIB_RLCIE 0x02
- #define GPIB_INT0 0x80
- #define GPIB_INT1 0x40
- #define GPIB_BI 0x20
- #define GPIB_BO 0x10
- #define GPIB_END 0x08
- #define GPIB_SPAS 0x04
- #define GPIB_RLC 0x02
- #define GPIB_MAC 0x01
- #define GPIB_GETIE 0x80
- #define GPIB_ERRIE 0x40
- #define GPIB_UNCIE 0x20
- #define GPIB_APTIE 0x10
- #define GPIB_DCASIE 0x08
- #define GPIB_MAIEE 0x04
- #define GPIB_IFCIE 0x01
- #define GPIB_GET 0x80
- #define GPIB_ERR 0x40
- #define GPIB_UNC 0x20
- #define GPIB_APT 0x10
- #define GPIB_DCAS 0x08
- #define GPIB_MA 0x04
- #define GPIB_SRQ 0x02
- #define GPIB_IFC 0x01
- #define GPIB_GLINT 0x80
- #define GPIB_STBOIE 0x40
- #define GPIB_STBO 0x40
- #define GPIB_LLOC 0x08
- #define GPIB_EEQ 0x04
- #define GPIB_MAV 0x10
- #define GPIB_ESB 0x20
- #define GPIB_RQS 0x40
- #define GPIB_MSS 0x40
- #define GPIB_TA 0x02
- #define GPIB_LA 0x04
- #define GPIB_LLO 0x40
- #define GPIB_REM 0x80
- #define GPIB_REN 0x01
- #define GPIB_ADDR 0x01
复制代码编辑原因: 将繁体字转为简体字,方便阅读..能否将这段发一份给我,非常感谢您了,我的邮箱:xxrsharesky@163.com
非常感谢
一周热门 更多>