Hi,
ADCON0 and CM1CON0 etc are not commands they are registers (memory in the PIC) which you use to control the ADC and the comparator in this particular case. When you use the dot notation, ie. ADCON0.7 = 1 you set bit 7 of ADCON0. When you THEN do ADCON0 = %0000001 you overwrite anything in ADCON with this new value thus clearing bit 7 that you just set.
The datasheet for the 12F510, intimidating as it may seem, IS you friend. If you open it up and look at the comparator section you'll find what each bit in the CM1CON0 register does. Bit3, ie CM1CON0.3 happens to enable/disable the comparator, clearing that bit disables the comparator.
If you do a search for CM1CON0 in the datasheet you'll find table 4-1 on page 17. This shows the power up state of the registers and if you look at the CM1CON0 register you'll see that it's %11111111 on power up (all bits are set) which means that the comparator is enabled. Therefor CM1CON0.3=0 is needed in order to disable it.
Same thing for the ADC, look at the datasheet. It'll tell you what each bit in the register(s) does. For "small" devices like the 12F510 there may only be one or two registers controlling the ADC while on larger chip there are several. Always use the datasheet for the particular device you're working with.
/Henrik.




Bookmarks