PDA

View Full Version : Setting up digital inputs



quester
- 22nd March 2008, 21:03
I am trying to learn how to set up digital inputs in a 16f84a
In the manual it gives CMCON =1 : ASCON1 = 7 : ANSEL = 0 to place at the beginning of the programme
I have tried all of these but it comes up with message undefined symbol
I would be grateful for any help.
Thanks.
This is the project from Chucks book but I am using a 16f84a instead.

Init:
adcon1 = 6 ' Set all PortA to digital I/O
trisa = %00000001 ' set PortA RA4-RA1 to outputs, RA0 input
porta = %00000010 ' Set PortA RA1 high to turn on LED1

Main:
' *** Test the switch state ***
if portA.0 = 0 then led2 'If switch is pressed then jump to LED2 routine

PortA.1 = 1 ' Turn LED1 on
portA.2 = 0 ' Turn LED2 off
goto Main ' Jump to the top of the main loop

LED2:
'*** Turn LED2 on ***
porta.2 = 1 ' LED2 on
porta.1 = 0 ' LED1 off
goto Main ' Jump to the top of the main loop

skimask
- 22nd March 2008, 22:14
I am trying to learn how to set up digital inputs in a 16f84a
Check the 16F84A datasheet.
Question #1 : How many Analog/Digital converter ports does the PIC16F84A have?
Question #2 : What position in memory does the ADCON1 register occupy in the PIC16F84A's memory space?