and for 18f4620 it`s ADCON=00001111 isnt it? do you do that right after tris initialsation or after?
I do not have the data sheet with me but if you have the correct register and all it should be
ADCON=%00001111
Dave
Always wear safety glasses while programming.
From the data sheet:
19.0 10-BIT ANALOG-TO-DIGITAL CONVERTER (A/D) MODULE
The Analog-to-Digital (A/D) converter module has
10 inputs for the 28-pin devices and 13 for the 40/44-pin
devices. This module allows conversion of an analog
input signal to a corresponding 10-bit digital number.
The module has five registers:
• A/D Result High Register (ADRESH)
• A/D Result Low Register (ADRESL)
• A/D Control Register 0 (ADCON0)
• A/D Control Register 1 (ADCON1)
• A/D Control Register 2 (ADCON2)
In the 5 Min it took me to read this thread started by Melanie in 2004 & the PDF referenced by mister_e.
you have solved:
- I now understand how to read and make sense out of the Microchip data sheets.
- using the PIC16F628A I understand what CMCON=7 is actually CMCON=%00000111 (which is binary for 7, and $07 is hexadecimal. lol you think a programmer of as many languages as me would have picked that up, shows I'm still a rookie in my career)
- How registers work and how to set them
- And many more things
This post is a great aid in going from playing with PBP to being confident in the ability of having a task and completing it.
Thank you
There's nothing nicer than knowing the time spent in posting something has been of help - even after all the years. *smiles*
Thanks Melanie,
That is a good troubleshooting doc to have on hand and review.
And as sbobowski noted it is much easier for a newbie to understand why/how to set a particular register if it is depicted as a binary value.
ie. cmcon = %00000111 instead of =07, Since each bit has a unique function, showing it in binary rather than hex or dec is easier for me to understand.
Thanks
Dwight
Dwight
These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.
Some folks think in Binary, some in Decimal, other in Hexadecimal.
I like Binary (when dealing with say up to 8 bits), because in my mind it immediately relates to those BIT positions in the PICs Registers.
It doesn't matter what you use, or if you chop and change throughout your code, the compiler doesn't care - it's there just for YOUR convenience.
The biggest confusion is when folks come along and say "What's inside the BYTE - is it Decimal or Hex or Binary?". It takes some explaining to convince people the answer is YES - It's ALL OF THOSE simultaneously! It's simply a matter of how you perceive it YOURSELF.
If you wanted to extract say just BIT 5 out of a BYTE... what's easier to visualise what is going on...
Example A.
NewByte=OldByte & %00100000
or...
Example B.
NewByte=Oldbyte & 32
or...
Example C.
NewByte=Oldbyte & $20
All three examples are EXACTLY the same. Use whichever one turns you on.
Another option to set PortA to digital automatically is Darrel's "AllDigital.pbp" . It will set the required registers on the selected device to make PortA digital and there is also a provision to see which registers have been set by the "All Digital" include.
http://www.picbasic.co.uk/forum/showthread.php?t=11100
I have used this in almost all of my 16F designs.
Last edited by shahidali55; - 9th May 2012 at 13:46.
Port A works, it’s port A bit 4 that doesn’t work lol!![]()
Bookmarks