Continue to Site

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.

  • 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.

temperature controller

Status
Not open for further replies.

pinky

New Member
Sir,

i am using pic16f877,my project is temperature controller.i would like to use inbuilt adc of pic16f877, but the output of the adc is 10bit.
how can i convert the output data(10bit) of adc into equal value of 8 bit data and display result using 7-segment display.
 
The Real MicroMan said:
divide by 4 or shift right twice...same thing

sir,

Thanks for reply

i am sorry , i didn't get the result

shall i rotate the 10bit value?

output of 10bits are stored into two 8bit register of adc

how can i move 10bit value into 8bit output register.
 
Yes, you have to shift right the entire 10 bits. But this way you'll loose lower 2 bits.

For e.g
Code:
Before Shifting:  00000010 11010110
After Shifting:   00000000 10110101
 
10bit to 8bit conversion

kinjalgp said:
Yes, you have to shift right the entire 10 bits. But this way you'll loose lower 2 bits.

For e.g
Code:
Before Shifting:  00000010 11010110
After Shifting:   00000000 10110101

sir,

adresh has 8bit
adresl has 8bit
how can i shift both registers
i have to right shift the both registers separately and tell with carry or without carry

can u give me code for this shiffting the registers

thank you
 
Code:
     BCF    STATUS, C     ;Clear carry, it will be shifted into MSB of adressh
     RRF     ADRESH, F     ;rotate adresH Right trough carry, carry holds previous LSB of adressH 
     RRF     ADRESL, F     ;rotate adresL right trough carry,  LSB will be in carry

Do this twice and the entire value will be shifted right 2 bits
 
No need for that shift none sense. During initialization, make sure bit7 (ADFM) of ADCON1 register is "0". The 8-bit ADC result is read from ADRESH only (i.e. ADRESL values are ignored).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top