PDA

View Full Version : 16F628A Configuring all pins for digital I/O ?



marcusk
- 11th February 2018, 12:22
Hello. Help please! I have a very basic noob question:
On my 16F628A, How do I configure all my pins as digital I/O ?
I have been reading all sorts of confusing info about how very important it is to configure default analog ports to digital at the start of a program but zilch on how to actually do this!
It says "...you must find and set a register to select digital mode for the pins." OK, but the 16F628A doesn't seem to have ANSEL or ADCON registers and I can't find anything in the data sheet on how to turn off analog pins.
It is very difficult for a noob to find out fundamental things like this... help appreciated!

mpgmike
- 11th February 2018, 22:19
Though I never worked with that PIC, looking over the data sheet it would appear there is no analog option; all PORT Pins are digital...always.

richard
- 11th February 2018, 22:23
except for the comparator , read the data sheet porta section

F1CHF
- 12th February 2018, 08:25
hello I am not a super specialist, but I have used this 16F628 in a DTMF decode function
here is the beginning (I use CMCON to have digital input)
'************************************************* ***************
'* Name : prefetch V6.bas *
'* Author : F1CHF *
'* Date : 1/06/2007 *
'* LED ENB ON sur codes ordinaires *
'* mais pas sur ABCD et code Zero *
'************************************************* ***************
@ device pic16f628, pwrt_on, protect_off
define osc 3 'car le quartz fait 3.58 Mhz
CMCON = 7 'modif pour PIC 16F628
'définition des entrées
STB var PORTA.4 '1 si réception d'un code DTMF valide(STROBE du 8870)
E1 var PORTA.0 'Q1 du 8870
E2 var PORTA.1 'Q2 du 8870
E3 var PORTA.2 'Q3 du 8870
E4 var PORTA.3 'Q4 du 8870
' definition des sorties
DTMFA var PORTB.2
DTMFB var PORTB.4
DTMFC var PORTB.3
DTMFD var PORTB.5

hope this help you
Francois

Art
- 13th February 2018, 08:40
CMCON = 7 is it,
then it’s immediately compatible with any 16F84 source.