How to set PortA's RA0, RA1 as output using PIC18F2455

Thread Starter

Digital_Mike

Joined Mar 6, 2008
2
Hi,

I am using a PIC18F2455. I would like to run a program that sets PortA as an output, then set RA0 High and RA1 low. I am using Assembly. How can i do that?

I thought that simply using the following code would do that, however when i simulate it in MPlab, PortA seems to remain unchanged.

???
clrf TRISA

BSF RA0, b'1'
BCF RA1, b'0'

Why does this not work? What am I missing?
 

atferrari

Joined Jan 6, 2004
4,004
Basically, you have two ways:

Read the description of EVERY pin to see whit what else it is involved or read the whole manual, noting every pin affected by a peripheral.

I always go the first way. It works 100%. Manuals are complete enough for that.

Your register if I recall right should be somthing like ADCON... But check it yourself.
 

0xFF

Joined Feb 26, 2008
12
Rich (BB code):
CLRF PORTA ; Initialize PORTA by clearing output data latches
MOVLW 0Fh ; Configure A/D
MOVWF ADCON1 ; for digital inputs
MOVLW 07h ; Configure comparators
MOVWF CMCON ; for digital input
BSF PORTA, 0 ; set RA0 high
Page 113 of the datasheet gives you a clear example of initializing PORTA.

Page 256 is the A/D Control Register 1.

Page 265 is the start of the Comparator Module (CMCON).
 

nanovate

Joined May 7, 2007
666
There should also be a table in the datasheet that tells you what the default state of the registers are after reset, POR, etc... I always look for this.
 
Top