您的位置:

c语言电压表,电压ce

本文目录一览:

纯新手,设计电压表汇编语言转换成c语言如何写,已附上汇编语言,在线等

#includereg51.h

typedef unsigned char u8;

typedef unsigned int u16;

typedef unsigned long u32;

sbit CLOCK = P2^4;

sbit ST = P2^5;

sbit EOC = P2^6;

sbit OE = P2^7;

sbit W2 = P2^1;

sbit W1 = P2^2;

sbit W0 = P2^3;

u8 Led2,Led1,Led0;//显示变量

void Delay(void);//延时

void Disp(void);

u8 code Seg7[] = {

0x3f,0x06,0x5b,0x4f,0x66,

0x6d,0x7d,0x07,0x7f,0x6f};

void Delay(void)

{

u8 i,j;

for(i = 10;i != 0;i --)

for(j = 250;j != 0;j --)

;

}

void Disp(void)

{

P0 = Seg7[Led0];

W0 = 0;

Delay();

W0 = 1;

P0 = Seg7[Led1];

W1 = 0;

Delay();

W1 = 1;

P0 = Seg7[Led2];

W2 = 0;

Delay();

W2 = 1;

}

void T0_ISR(void)interrupt 1

{

CLOCK = !CLOCK;

}

void main(void)

{

u8 i;

Led0 = 0;

Led1 = 0;

Led2 = 0;

P2 = 0xff;

TMOD = 0x02;

TH0 = 245;

TL0 = 245;

IE = 0x82;

TR0 = 1;

while(1)

{

ST = 0;

ST = 1;

ST = 0;

while(!EOC)

;

OE = 1;

i = P1;

OE = 0;

Led2 = i / 51;

Led1 = i / 51 / 5;

Led0 = i / 51 % 5;

Disp();

}

}

用C语言做数字电压表,不知道哪里出错了,求解

P2=0x80; P1=table[qian]0x7F; //显示小数点 delay(50); P2=0x04; P1=table[bai]; delay(50); P2=0x02; P1=table[shi]; delay(50); P2=0x01; P1=table[ge];}

你这几个打串拉 改一下

单片机C语言,关于数字电压表的初值设计问题

4000是人为设置的,写程序的人考虑的,你问问就可以了,我觉得你设10000也没有什么大碍。

单片机12M晶体,12T模式下计时器加1的时间为1us,所以4000 * 1us 就是4ms,是先有想得到的定时周期,才有的计数器初值的,不要搞混。

基于ADC0832做的电压表仿真求C语言代码

uchar ADC0832_Read(uchar ch)

{

/*读取ADC的 CH 通道电压值,ADC作为2路单独电压输入*/

uchar i;

uchar ADC_buff=0;

uchar temp=0;

EA = 0;

ADC0832_CS = 1;

ADC0832_DIO = 1; /*启动位*/

ADC0832_CLK = 0;

ADC0832_CS = 0;

nop();

ADC0832_CLK = 1;

nop();

ADC0832_CLK = 0;

ADC0832_DIO = 1; /*送 SGL/DIF 位 */

nop();

ADC0832_CLK = 1;

nop();

ADC0832_CLK = 0;

if(ch==0) ADC0832_DIO = 0; /*送转换通道值*/

else ADC0832_DIO = 1;

ADC0832_CLK = 1;

nop();

ADC0832_CLK = 0;

nop();

ADC0832_DIO = 1; /*释放DIO端口,转由ADC控制*/

nop();

ADC0832_CLK = 1;

nop();

for(i=0;i8;i ){ /*准备读取8位数据*/

nop();

ADC0832_CLK = 0;

nop();

nop();

ADC_buff=ADC_buff1;

if(ADC0832_DIO==1) ADC_buff=ADC_buff 1; /*读取数据*/

ADC0832_CLK = 1;

}

for(i=0;i8;i ){

temp = temp1;

if(ADC0832_DIO==1) temp = temp | 0x80; /*读取校验数据*/

ADC0832_CLK = 1;

nop();

ADC0832_CLK = 0;

nop();

}

ADC0832_CS = 1;

ADC0832_CLK = 1;

//if(temp == ADC_buff) ADC_flag = 1;

//else ADC_flag = 0;

EA = 1;

return ADC_buff; /*返回转换值*/

}