assembly for PIC16X8x

Thread Starter

mail866

Joined Apr 27, 2010
1
Modifiy the following the assembley program so 1 pin of the PORTA as input=5v or 0v and other 1 pin of PORTA as output= 5v or ov





;*****Set
up the
Constants****




STATUS
equ
03h ;Address
of the
STATUS
register


TRISA

equ
85h ;Address
of the
tristate
register
for port
A


PORTA
equ
05h ;Address
of Port
A


COUNT1
equ
08h ;First
counter
for our
delay
loops


COUNT2

equ
09h ;Second
counter
for our
delay
loops




;****Set
up the
port****




bsf STATUS,5
;Switch
to Bank
1


movlw
00h ;Set
the Port
A pins


movwf
TRISA ;to
output.


bcf STATUS,5
;Switch
back to
Bank 0



;****Turn
the LED
on****




Start
movlw 02h ;Turn
the LED
on by
first
putting
it


movwf PORTA
;into
the w
register
and then
on the
port



;****Add
a delay






call

Delay



;****Delay
finished,
now turn
the LED
off****




movlw
00h ;Turn
the LED
off by
first
putting
it


movwf
PORTA
;into
the w
register
and then
on the
port



;****Add
another
delay****



call

Delay



;****Now
go back
to the
start of
the
program



goto
Start

;go back
to Start
and turn
LED on
again



;****Here
is our
Subroutine




Delay




Loop1 decfsz COUNT1,1
;This
second
loop
keeps
the LED

goto

Loop1
;turned
off long
enough
for us
to

decfsz
COUNT2,1
;see
it
turned
off

goto
Loop1 ;


return



;****End
of the
program****




end ;Needed
by some
compilers,
and also

;just
in case
we miss
the goto
instruction.
 

Markd77

Joined Sep 7, 2009
2,806
you need to change this bit:
movlw
00h ;Set
the Port
A pins


movwf
TRISA ;to
output.
Rich (BB code):
;PORTA 7-------0
movlw b'00000001'
movwf TRISA
Anything set as 1 is an input.

If you go advanced, highlight the code and then click the icon like this "#" it looks a lot nicer.
 
Last edited:
Top