gopintj
Member level 4
![Member level 4](/styles/images/ranks/dlevel4.gif)
Hello friends,..!!!!
I am very new to Microcontrollers. As i am a Final Year Electronics student, I would like to build ADC as my mini project.
I hav searched lots of webpage and i found nothing helpful.
This is my program coding.. Please help me.![Frown :( :(](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I am using 16f877a and High Tech C compiler.
Thanks in advance..![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I am very new to Microcontrollers. As i am a Final Year Electronics student, I would like to build ADC as my mini project.
I hav searched lots of webpage and i found nothing helpful.
This is my program coding.. Please help me.
Code:
#include<pic.h>
#include"delay.c"
#include"lcd_driver.c"
__CONFIG(0x1932);
void adc_init(void);
void adc_channel(void);
unsigned char adc_res(void);
void main()
{
unsigned char result=0;
setup_lcd_port();
lcd_init();
adc_init();
adc_channel();
while(1)
{
result=0;
DelayUs(20);
result=adc_res();
lcd_goto_pos(1);
lcd_putn(result);
DelayUs(20);
}
}
void adc_init(void)
{
TRISA=0x01;
TRISC4=0;
DelayUs(20);
ADCON1=0b10000010;
}
void adc_channel(void)
{
DelayUs(20);
ADCON0=0b11000001;
}
unsigned char adc_res(void)
{
ADRESL=0;
DelayUs(10);
ADGO=1;
while(ADGO)
{
continue;
}
return ADRESL;
}
I am using 16f877a and High Tech C compiler.
Thanks in advance..
Last edited by a moderator: