It is currently Fri May 26, 2017 3:02 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Wed Jan 11, 2017 11:20 pm 
Offline
Member
Member

Joined: Wed Jan 11, 2017 11:01 pm
Posts: 2
Location: UK
In the sample A to D program, when obtaining the temperature, ADRESH is divided by 2. The result is that the temperature value is half of what it actually is. Is there any reason why ADRESH is divided by 2 or did they just mean to mask out the last bit (ADRESH & ~1)


Top
 Profile  
 
PostPosted: Thu Jan 12, 2017 7:30 am 
Offline
User avatar
Velleman Support
Velleman Support

Joined: Mon Dec 11, 2006 12:03 pm
Posts: 4897
Location: Belgium
I'm sorry, but I can't locate where the ADRESH is divided by 2 in the code.
Code:
unsigned char ntc (void)
{

    ADCON0 = 0b10000001;    // Analog-to-Digital FOSC/32, Channel 0 (RA0),
                            //   input from NTC
    delay();                // Acquisition delay
    ADCON0bits.GO = 1;      // start conversion
    while (ADCON0bits.GO);  // wait until done
    return ADRESH;
}


Top
 Profile  
 
PostPosted: Thu Jan 12, 2017 5:23 pm 
Offline
Member
Member

Joined: Wed Jan 11, 2017 11:01 pm
Posts: 2
Location: UK
Somehow the version I have has return ADRESH << 1

Anyway, looks like that is incorrect. Thanks.


Top
 Profile  
 
PostPosted: Thu Jan 12, 2017 6:32 pm 
Offline
User avatar
Velleman Support
Velleman Support

Joined: Mon Dec 11, 2006 12:03 pm
Posts: 4897
Location: Belgium
OK. It seems that you have a modified version.
Here you can download the original EDU10 examples:
http://www.velleman.eu/downloads/files/ ... /edu10.zip


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group