Im new and need help in MPLAB

Discussion in 'Embedded Systems and Microcontrollers' started by Caleta, Sep 10, 2007.

  1. Caleta

    Thread Starter New Member

    Sep 10, 2007
    1
    0
    Hi, Iam new to the forum and wanted to say hi.

    Iam majoring computer engineering, yet iam having a total black out in MPLAB.

    Classes just started and I took C before but it was five years ago.
    Here is my problem:

    2. Program Two: Name this program SF2.asm. Modify so that you initially write the 0X55 to the PORTB LEDs and then you write the compliment of 0X55 to PORTB after the pause. You will not be loading W with 0XAA!

    So here is how sf2.asm looks:

    ; USE THE OSCILATOR SETTING OF HS
    ;==============Wk2-File3.asm=========================
    list p=16F877A
    #INCLUDE <P16F877A.INC>
    __config h'3f32'
    radix hex
    ;=====================================================
    ;Register Equates go here
    ncount EQU 0x20
    mcount EQU 0x21
    lcount EQU 0x22
    ;-----------------------------------------------------
    org 0x000
    goto start
    org 0x005
    start bsf STATUS,RP0 ;Switch to Bank 1
    movlw 0x00 ;load w with all zeros
    movwf TRISB ;Set PORTB direction bits to outputs
    bcf STATUS,RP0 ;Switch back to Bank 0
    ;-----------------------------------------------------
    loop movlw 0xAA ;load w with 0xAA
    movwf PORTB ;write contents of w to portb
    call pause ;DELAY for visablity
    movlw 0x55 ;load w with 0x55
    movwf PORTB ;write contents of w to portb
    call pause ;DELAY for visablity
    goto loop ;loop to write again
    ;=====================================================================
    ;Pause is a 3 loop counter. Adjust time delay by altering
    ;lcount. Lcount should be between 0x20 and0x40 for for visable change.
    ;--------------OUTER LOOP---------------------------------------->|
    pause movlw 0x04 ;CHANGE THIS VAL FOR TIME DELAY |
    movwf lcount ;load l wilh 4 Decimal |
    ;--------------MIDDLE LOOP--------------------------------->| |
    loadm movlw 0xff ;load mcount will ff | |
    movwf mcount ; | |
    ;-----------INNER MOST LOOP----------------------------->| | | |
    loadn movlw 0xff ;n | | |
    movwf ncount ;load ncount with ff | | |
    decn decfsz ncount,f ;decrement N | | |
    goto decn ;again thru inner loop N | | |
    ;-------------------------------------------------------<| | |
    decfsz mcount,f ;decrement M | |
    goto loadn ;again thru middle loop M | |
    ;---------------------------------------------------------<<| |
    decfsz lcount,f ;decrement L |
    goto loadm ;again thru outer loop L |
    ;---------------------------------------------------------------<<|
    return ;done
    ;======================================================================
    end
    ;---------------------------------------------------

    Iam really lost can anyone provide help
     
Loading...