Using the comparator on a 28X2

MartinM57

Moderator
(yes, I've got my 28X2's so I've now got the questions!)

Manual 1 shows legs 2 to 5 being the comparator inputs. The PIC18F2520 datasheet shows them also and (page 233) indicates that the CMCON register is used to control their operation and determine the comparator output values.

I can't find anything in any (PICAXE) manuals that indicates how to access/use CMCON - is it just left to the programmer to use the appropriate PEEKSFR/POKESFR commands to the right location?

The PIC datasheet shows CMCON at 0xFB4 - how does that map onto the PEEKSFR/POKESFR location parameter which is 0 to 255?

TIA
Martin
 

Technical

Technical Support
Staff member
You never need to use direct sfr registers for general PICAXE features.
The BASIC command you are missing in this case is 'compsetup' - this will do all the hard work for you! Look it up in part 2 of the manual.

For peeksfr/pokesfr you drop the inital F, so 0xFB4 is $B4
 

MartinM57

Moderator
Wow - I completely missed those 4 pages in the manual :redface:

I was searching for C1- C1+ etc which are the pin layout diagrams, but nowhere else.

I think I need to read the new manual cover to cover and post as a last resort :moreredface:

Thanks for the info about mapping SFRs to PEEKSFR/POKESFR locations
 
Top