1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

adc0832 can't display normal

Discussion in '8051/8951' started by jamasliu, Dec 15, 2012.

  1. jamasliu

    jamasliu New Member

    Joined:
    Jun 21, 2012
    Messages:
    6
    Likes:
    0
    http://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: Dec 15, 2012

Share This Page