Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC16F877 ADC EXAMPLES assembly

Status
Not open for further replies.
STUDY ABOUT THE FOUR REGISTERS RELATED TO ADC;
1> ADCON0
2>ADCON1
3>ADRESH
4>ADRESL


make sure to give the required delay before reading adc(capacitor charge time ) and what you are reading(if it is from battery one read will do the work else you have to read more and take the average of that
 

STUDY ABOUT THE FOUR REGISTERS RELATED TO ADC;
1> ADCON0
2>ADCON1
3>ADRESH
4>ADRESL
This is available in data sheet..



Then using a C compiler 'like HIGH TECH C' try 2 write a program...
I am sure u could do it....


yes thanks.. i've read it in the data sheet and somehow i understand the functions and operations. but im required in my project to use MPLAB-IDE and assembly code programming.
 

Hi,
Using assembly, it's not a problem. If you know assembly, just follow the process of setting ADCON0 and ADCON1 as required meeting suitable timing requirements, and then read from ADRESH and ADRESL. Now the catch is if you can use assembly or not. If you can, then go ahead and start coding, we'll help when you get stuck. If you can't time to grab hold of some tutorials or more preferably a book to understand all the instructions. If you've used assembly somewhere earlier, you might be able to get hold of it directly from the datasheet, otherwise you need some more help.

Hope this helps.
Tahmid.
 
do anyone have a code for soureboost IDE
 

Re: pic adc sample code

it`s very strange! why do you add 48 (30h)??? of course if you are converting the number to ASCII in some poor way it can`t display float numbers! did you think that usart_write can convert numbers to float???
mmmmm
well, i can suggest something like this
Code:
void main() { 
float volt,press,calc,adc_value; 
char inter, deci;
ADCON1 = 0x80; // Configure analog inputs and Vref 
TRISA = 0xFF; // PORTA is input 
TRISB = 0x3F; // Pins RB7, RB6 are outputs 
TRISD = 0; // PORTD is output 
usart_init(2400); 


do { 

adc_value = Adc_Read(2); // Get results of AD conversion 
press = adc_value*0.005; 
inter = (int) press;
deci= (int) (press*10.0) - inter*10;
usart_write('V'); 
usart_write('O'); 
usart_write('L'); 
usart_write('T'); 
usart_write('='); 
usart_write(inter | 0x30);
usart_write('.'); 
usart_write(deci | 0x30);
usart_write(13);
usart_write(10); 
delay_ms(1000); 
} while(1); 
}


sir, i would just like to ask, how can i do it that the output has 2 or 3 decimal places?
 
Last edited:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top