R
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 <p16F819.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _CCP1_RB2 & _DEBUG_OFF &
_LVP_OFF & _BODEN_OFF & _MCLR_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_IO
main
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,
Robbs
with a microcontroller:
------------------------------------begin code------
list p=16f819 ; list directive to define processor
#include <p16F819.inc> ; processor specific variable definitions
errorlevel -302 ; suppress message 302 from list file
__CONFIG _CP_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _CCP1_RB2 & _DEBUG_OFF &
_LVP_OFF & _BODEN_OFF & _MCLR_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_IO
main
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,
Robbs