PDA

View Full Version : PIC16F767 IOs



Nicmus
- 28th May 2006, 20:56
Hi all,
I’m using PBP 2.45 and PIC16F767
I have plenty of PIC16F767 on hand and my new project asks for lots of digital IOs .
I need to make sure all the IOs are in digital mode.
Reading the data sheet I got a little confused.
Is it enough to get all IOs as digital using the generic lines:

CMCON = 7 for analog comparators and
ADCON1 = 7 for A/D IOs ?

Do I need to change this lines or add some more?
Any input will be appreciated.
Nick

Travin77
- 28th May 2006, 21:11
As I understand it, you should do adcon1=7 to make all analog pins digital. Thats how I do it. ports a and e are both affected by adcon1 reg and adcon1 = 7 will make port a digital so it should make both digital.

Travin

Nicmus
- 28th May 2006, 22:15
Thanks Travin.
So, I should be safe using ADCON1=7 annd no strange behavior from the analog IOs?
Regards,
Nick

Travin77
- 28th May 2006, 23:30
Pin a.4 is an open drain. Read page 11 in the PBP manual if you intend on using that pin as an output.

Travin

Nicmus
- 28th May 2006, 23:36
I'm using this code and I do not get any action from Pin 7 (RA5).
I know about Pin 6 (RA4 open collector output)

ADCON1=7
CMCON=7

main:


Toggle PORTA.0
Pause 300
Toggle PORTA.1
Pause 300
Toggle PORTA.2
Pause 300
Toggle PORTA.3
Pause 300
Toggle PORTA.4
Pause 300
Toggle PORTA.5
GoTo main
End
Am I missing something?
Regards,

Nick

Travin77
- 28th May 2006, 23:49
Is that your entire code. You might want to try and establish a know condition of the pins at the beggining. What osc are you using?

cmcon=7
adcon1=7

trisa = %00000000 ' makes them outputs
porta = %11111111 ' makes them high

main:
Toggle PORTA.0
Pause 300
Toggle PORTA.1
Pause 300
Toggle PORTA.2
Pause 300
Toggle PORTA.3
Pause 300
Toggle PORTA.4
Pause 300
Toggle PORTA.5
GoTo main
End

Nicmus
- 29th May 2006, 00:01
The code is only for testing A port.
Am I wrong assuming that ADCON1=7 takes care only of A0-3 ports?
Should I extend it to ADCON1=15 or ADCON1=31 to cover higher bits?
Regards,

Nick

Travin77
- 29th May 2006, 00:12
Adcon1 should set all of port a to digital. Is there a good conection on porta.5?

Nicmus
- 29th May 2006, 00:36
Yes, connection is good, it just does not toggle.
I used ADCON1=15 and the port A5 works(?!?!?!?!).
With ADCON1=7 it does not work.
All other A ports work in both cases.
What about CVRCON register?

Nick

Travin77
- 29th May 2006, 02:29
Unfortunately, you are beyond my knowledge level. I am a semi-newbie. I read the datasheet and noticed that some of port b has a/d capabilities. That is probally why the adcon1 = 15 worked. Sorry for the bad gouge.

travin

Nicmus
- 29th May 2006, 02:56
Thanks again Travin!
Will any of "Big Guns" step in, please!
Nick

Ron Marcus
- 29th May 2006, 03:46
The '767 is like the 18F26XX series. ADCON1 = 15 or %00001111 to turn all IOs digital.

Nicmus
- 29th May 2006, 04:55
Thanks Ron,
You confirmed my suspicion.

Nick