assembly for PIC16X8x

Discussion in 'Embedded Systems and Microcontrollers' started by mail866, Apr 28, 2010.

  1. mail866

    Thread Starter New Member

    Apr 27, 2010
    1
    0
    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.
     
  2. rjenkins

    AAC Fanatic!

    Nov 6, 2005
    1,015
    69
    Should this be in the Homework forum (and posted using the 'code' tags?).
     
  3. Markd77

    Senior Member

    Sep 7, 2009
    2,803
    594
    you need to change this bit:
    Code ( (Unknown Language)):
    1. ;PORTA 7-------0
    2. movlw b'00000001'
    3. 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: Apr 28, 2010
Loading...