-
我的ad0809模块EOC一直处于低电平 sos
[color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "]做学校的电子设计竞赛要做一个电压测量器,想使用ad0809模块去做,ad0809的IN0口外接了一个ne555信号发生器,单片机使用的是STC89C52RC,输入地址位使用模块上的跳线帽选择了IN0,设备的其余部分还没有加上去,但是测试的时候发现程序一直卡在“[/font][/backcolor][/color][color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]while(EOC==0)”这个地方无法继续运行,想请求各位大佬看看可能是什么问题,万分感谢![/font][/backcolor][/color][font=Tahoma, Microsoft Yahei, Simsun][color=#252525] [/color][/font][color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]#include
[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]#define uint unsigned int[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]#define uchar unsigned char[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]uint volt=0; //电压值测定值[/font][/backcolor][/color] [color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "]sbit CLK=P2^7; //时钟信号[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]sbit START=P2^4; //转换启动开关[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]sbit EOC=P2^5; //转换结束标志[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]sbit OE=P2^6;//定义ADC0809各脚[/font][/backcolor][/color] [color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "]void delay(uint x)[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]{[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] uchar y,z;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] for(y=x;y>0;y--)[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] for(z=250;z>0;z--);[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] }[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]void ADC()[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]{[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] EA=1;//开中断[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] OE=0;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] //确保进入正常AD转换状态[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] START=0;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] delay(10);[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] START=1;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]delay(10);[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] START=0;//ad开始转换 [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] while(EOC==0);[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][/backcolor][/color][color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "] OE=1;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] EA=0;//关中断[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] volt=P0;//获取转换值保存到volt中,(P0为转换后数据)[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] volt=volt*196;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] OE=0;//输出转换结束 (要在获取转换值之后)[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]}[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]void timer() interrupt 1[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]{[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] TH0=(65536-2)/256; //重装计数初值[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]TL0=(65536-2)%256; //重装计数初值[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]CLK=!CLK; //取反[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]}[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]void main()[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]{[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] TMOD=0X01; [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]CLK=0; [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]TH0=(65536-2)/256; [/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]TL0=(65536-2)%256;[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] ET0=1;//开定时器0中断[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] TR0=1;//开启定时器0*/[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] while(1)[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "] {[/font][/backcolor][/color] [color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "] ADC();//调用模数转换程序 [/font][/backcolor][/color] [color=#252525][backcolor=rgb(255, 255, 255)][font=Tahoma, "]}[/font][/backcolor][/color] [color=rgb(37, 37, 37)][backcolor=rgb(255, 255, 255)][font=Tahoma, "]}[/font][/backcolor][/color] 2026浏览量 0回复量 关注量