C51 ADC0804LCN Application

Publisher:ZhenxiangLatest update time:2018-12-19 Source: eefocusKeywords:C51  ADC0804LCN Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Write the picture description here

#include  

//stdio.h, string.h are used for printf function prototype  

#include  

#include


sbit AD_CS = P1^2; 

sbit AD_WR = P1^0;

sbit AD_RD = P1^1;

sbit AD_PORT = P0;



/**************************************

*

* Enable ADC

*

***************************************/

void AdcStart(void)

{

    AD_CS = 0;

    _nop_();

    AD_WR = 0;

    _nop_();

    AD_WR = 1;

    _nop_();

    AD_CS = 1;

    _nop_();


}


/**************************************

*

* Read ADC value

*

***************************************/

int AdcRead(void)

{

    int temp;

    AD_PORT = 0xFF; // Write high to PORT port before MCU reads AD value   

    AD_CS = 0;

    _nop_();

    AD_RD = 0;

    _nop_();

    _nop_();

    _nop_();

    temp = P0;

    _nop_();

    AD_RD = 1;

    _nop_();

    AD_CS = 1;

    _nop_();

    return temp;

}

Keywords:C51  ADC0804LCN Reference address:C51 ADC0804LCN Application

Previous article:C51 Timer Counter
Next article:C51 serial port sending and receiving, printf, receiving character string

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号