首页 > 微机单片机 >单片机制作 > 用打印机端口做可编程频率发生器电路

用打印机端口做可编程频率发生器电路

来源:互联网发布者:张三叔 更新时间: 2018/04/15

用打印机端口做可编程频率发生器电路 #include #include #include #include #include #define CLK1 0x04 /* Clock Pulse High*/ #define CLK0 0xfb /* Clock Pulse Low*/ #define CS1 0x01 /* Chip Select high to deactivate DAC*/ #define CS0 0xfe /* Chip Select low to activate DAC*/ #define DATA1 0x02 /* Data Pulse High*/ #define DATA0 0xfd /* Data Pulse low*/ int c,dport,ACTUALDATA,out,k; /*Global Declarations*/ float VOUT;/*DAC OUTPUT*/ void d2b(unsigned int x, int*c)/*Routine for Decimal to Binary Conversion*/ { int i; for(i=0;i<=15;i++) *(c++)=(x>>i) %26;amp; 0x1; } float ftov() /*Hertz to DAC output Conversion Routine*/ { int HERTZ; printf("\n \nEnter the frequency within 0 to 10000Hz:"); scanf("%d",%26;amp;HERTZ); VOUT=0.00040955*HERTZ; printf("\n VOUT=%f\n",VOUT); return VOUT; } void CLOCK_DAC(void)/*Routine for clocking the DAC*/ { out|=CLK1; outportb(dport,out);/*Setting the clock high*/ delay(1); out%26;amp;=CLK0; outportb(dport,out);/*Setting the clock low*/ delay(1); } void LOAD_DACDATA(int*c)/*Routine for loading actual data into the DAC*/ { out|=CS1; outportb(dport,out);/*Chip Select high to disable DAC*/ delay(1); out%26;amp;=CS0; outportb(dport,out);/*Chip Select low to enable DAC*/ delay(1); printf("\nDATA loaded into the DAC="); for(k=15;k>=0;k--) { out|=c; outportb(dport,out); printf("%d",c); delay(1); CLOCK_DAC(); } out|=CS1; outportb(dport,out); delay(1); } main() { int v,inc; float y; unsigned int x; double fraction, integer, number; clrscr(); printf("\tUse Your Printer Port as a Programmable Frequency Generator"); printf("\n\t\t\t by\n"); printf("\tK.Suresh,MSD,IGCAR,Kalpakkam,TamilNadu-603102,India"); dport= peek(0x40,8);/*Check up for availability of Printer Port*/ if (dport==0) { printf("\n\n LPT NOT AVIAILABLE! EXITING........"); exit(1); } printf("\n\nAddress of the printer port found =0x%X",dport); ftov(); y=(VOUT*8192)/(2.5*1.6384); v=y/1; number=y; fraction = modf(number, %26;amp;integer); if (fraction<0.44) inc=0; els
提问/讨论

这里还没有内容,您有什么问题吗?

我要提问/讨论

推荐帖子 最新更新时间:2023-12-01 12:17

单片机复位电路的可靠性设计
单片机复位电路的可靠性设计,周立功出品 单片机复位电路的可靠性设计
 tonytong单片机
C2000开发套件申请被拒了
伤心中。 有通过的,来说说经验吧。 C2000开发套件申请被拒了
 安_然微控制器 MCU
ADI无线传感网络解决方案
资料下载: ADI无线传感网络解决方案
 天明ADI参考电路
攒分,请无视攒分,请无视
只为攒分攒分,请无视 攒分,请无视攒分,请无视
 xuesong999嵌入式系统
学习AVR C语言重量级资料AVR c库函数介绍
CodeVisionAVR C Library Functions Reference CodeVisionAVR C 库函数介绍 译自CodeVisionAVR C Compiler Help 学习AVR C语言重量级资料AVR c库函数介绍
 bananaMicrochip MCU
【NUCLEO-L452RE测评】CoreMark跑分
MCU跑分现在都和手机一样流行了, 不跑个分对不起板卡 官方CreMark教程 话说新版STM32CubeMX改进了不少,比如建立工程时MCU选择界面,和ST MCU Finder结合了,可以十分方便的查找MCU资料 STM32L4系列支持LL库和HAL库混合使用,最接近寄存
 dql2016stm32/stm8

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版 版权声明

EEWORLD 电路图 站点相关: 下载中心 Datasheet 参考设计

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2023 EEWORLD.com.cn, Inc. All rights reserved