adc0832 can't display normal

Status
Not open for further replies.

jamasliu

New Member
https://www.amobbs.com/thread-5511802-1-1.htmlaccording to the book writing program can't run,attached the program and screenshot.if i want to testing than 5v ,how to set circuit and modification program.pls give me some advise,thanks in advance!!


#include "reg51.h"
sbit CS=P3^4;
sbit Clk=P1^0;
sbit DIO=P1^1;
unsigned char adval;
unsigned char code tab[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned char A_D(bit CH)
{
unsigned char i;
CS=0;
Clk=0;
Clk=1;
DIO=1;
if(CH==0)
{
Clk=0;
Clk=1;
DIO=1;
Clk=0;
Clk=1;
DIO=0;
}
else
{
Clk=0;
Clk=1;
DIO=1;
Clk=0;
Clk=1;
DIO=1;
}
Clk=1;
Clk=0;
for(i=0;i<8;i++)
{
Clk=1;
Clk=0;
if(DIO)
adval=(adval>>1)|0x80;
else
adval=(adval>>1)|0x00;
}

CS=1;
return(adval);
}
void delay1(void)
{

int k;
for(k=0;k<400;k++);

}

void display(int k)
{
P2=0xfe;
P0=tab[k/1000];
delay1();
P2=0xfd;
P0=tab[k%1000/100];
delay1();
P2=0xfb;
P0=tab[k%100/10];
delay1();
P2=0xf7;
P0=tab[k%10];
delay1();
P2=0xff;
}
void main(void)
{
P0=0xff;
P2=0xff;
while(1)
{
A_D(0x01);
display(adval);
}
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…