Connect with us

First steps with the PIC16F819

Discussion in 'Electronic Basics' started by Robbs, Jul 26, 2003.

Scroll to continue with content
  1. Robbs

    Robbs Guest

    I've written/plagiarized the following, as my first attempt to do anything
    with a microcontroller:

    ------------------------------------begin code------

    list p=16f819 ; list directive to define processor
    #include <> ; processor specific variable definitions

    errorlevel -302 ; suppress message 302 from list file



    BANKSEL PORTA ; select bank of PORTA
    CLRF PORTA ; Initialize PORTA by
    ; clearing ouput
    ; data latches

    BANKSEL TRISA ; Select Bank of TRISA
    MOVLW 0x00 ; Value used to
    ; inititalize data
    ; direction
    MOVWF TRISA ; Actually write the
    ; value to the register

    BANKSEL PORTA ; select bank of PORTA
    MOVLW 0xAA ; Output '10101010b' to
    ; PORTA (in theory)
    MOVWF PORTA ; Set RA<7:0> as outputs

    ; initialize eeprom locations

    ORG 0x2100
    DE 0x00, 0x01, 0x02, 0x03

    END ; directive 'end of program'

    ------------------------------------------end code-----------
    Will this do what I hope it will, simply output 10101010b (0xAA) to PORTA?If
    so, is it safe to check the pins with a voltmeter between the I/O pin
    andVss? would a series resistor be wise?

    Is the last bit of code necessary, under 'initialize eeprom locations'? it
    was part of the example code supplied with MPLABS, and I'm not sure exactly
    what it does.

    I realize that one pin on PORTA (pin 5, i think) is an input only.

    Thank you very much,

Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day