|
|
View previous topic :: View next topic |
Author |
Message |
wakaka
Joined: 11 Sep 2006 Posts: 27
|
12F675 comparator |
Posted: Tue Jan 09, 2007 10:40 pm |
|
|
Hi there, at the 12F675.h i found this
Code: | //////////////////////////////////////////////////////////////////
COMP
// Comparator Variables: C1OUT, C2OUT
// Constants used in setup_comparator() are:
#define NC_NC_NC_NC 0x0ff07
#define NC_NC 0x0ff07
#define A0_A1 0x3ff02
#define A1_VR_OUT_ON_A2 0x6fb03
#define A1_VR 0x2ff04
#define A0_A1_OUT_ON_A2 0x3fb01 |
I've check the datasheet, it only has COUT, no C1OUT and C2OUT, so i dun really understand the constants in the header file.
and why it has a 20 bit data? ( 0x0ff07). I think it only has CMCON and VRCON register to be configure, which total up 16bit.
for #define A0_A1....... is it for the A/D module, which sets the ADCON0 and ANSEL register? again, total up is 16 bit, but y the defination is in 20bit?
Or can anyone plz explain each of the constants above?
Plz help, thanks. |
|
|
wakaka
Joined: 11 Sep 2006 Posts: 27
|
|
Posted: Wed Jan 10, 2007 2:03 am |
|
|
i just figured it out, for 12F675, only the last 2 hex numbers are used, others are ignore...
To off the comparator module, CMCON = 7;
#define NC_NC 0x0ff07
To use comparator with A1 as Vin-, A0 as Vin+, A2 as output, CMCON = 1;
#define A0_A1_OUT_ON_A2 0x3fb01
and so on...........
But my question is, instead of define NC_NC 0x07, y it is defined as 0x0ff07???? |
|
|
ckielstra
Joined: 18 Mar 2004 Posts: 3680 Location: The Netherlands
|
|
Posted: Wed Jan 10, 2007 3:16 am |
|
|
Quote: | But my question is, instead of define NC_NC 0x07, y it is defined as 0x0ff07???? | Do not try to understand these values as they are defined for compiler internal use only. Most likely there will be a direct relationship to the defined value and some register setting but this is undocumented and not important.
The #define's are great in that they describe a desired functionality to be achieved by calling setup_comparator(). If you ever decide to move to another processor you can still use your same program by only changing the included processor header file. To accommodate for the differences in procesor types it is very likely the values in the #defines contain some extra bits to steer the compiler internally. |
|
|
|
|
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 You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|