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.

sir help me rhis 16f72 c code

Status
Not open for further replies.

sitaram

Junior Member level 1
Joined
Sep 18, 2012
Messages
16
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,380
unsigned char adc_read(unsigned char chanel)
{

chanel<<=3;
ADCON0=0xc1|chanel;
sir i not understand it
 

If chanel = 1 then it is shifted 3 bits left so it becomes 0x08 after executing

Code C - [expand]
1
chanel<<=3;


ADCON is assigned the value got by ORing 0xC1 and chanel value.

If chanel was 0x08 then 0xC1 ORed with 0x08 will be assigned to ADCON0 regsiter.
 
Last edited:
or even the ADCON0 channel :-D
Jayanth is right though, it uses the value in 'chanel' to set the bits in ADCON0 by ORing them with 0xC1. The value you provide is shifted three places to the left so it aligns with the channel bit positions in the register.

Brian.
 

hello

Code:
chanel=chanel << 3;  // chanel value transmitted by the paramter of unction is multiply by 2 power 3 = 8 
ADCON0= 0xC1 | chanel;      // OR function to add the chanel number into the register

Ana_select.jpg

so chanel 0 will give 0xC1
chanel 1 -> 0xC9
chanel 2 -> 0xD1
chanel 3 -> 0xD9
.....
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top