Code:
00,81,82,83,84,85,86,87,88,89,8A,8B,8C,8D,8E,8F
00,81,82,83,84,85,86,87,88,89,8A,8B,8C,8D,8E,8F
90,91,92,93,94,95,96,97,98,99,9A,9B,9C,9D,9E,9F
90,91,92,93,94,95,96,97,98,99,9A,9B,9C,9D,9E,9F
A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF
A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,AA,AB,AC,AD,AE,AF
Code:
;----[16F1828 Hardware Configuration]-------------------------------------------
#IF __PROCESSOR__ = "16F1828"
#DEFINE MCU_FOUND 1
#CONFIG
cfg1 = _FOSC_INTOSC ; INTOSC oscillator: I/O function on CLKIN pin
cfg1&= _WDTE_OFF ; WDT disabled
cfg1&= _PWRTE_OFF ; PWRT disabled
cfg1&= _MCLRE_OFF ; MCLR/VPP pin function is digital input
cfg1&= _CP_ON ; Program memory code protection is enabled
cfg1&= _CPD_OFF ; Data memory code protection is enabled
cfg1&= _BOREN_ON ; Brown-out Reset enabled
cfg1&= _CLKOUTEN_OFF ; CLKOUT function is disabled. I/O or oscillator function on the CLKOUT pin
cfg1&= _IESO_ON ; Internal/External Switchover mode is enabled
cfg1&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled
__CONFIG _CONFIG1, cfg1
cfg2 = _WRT_OFF ; Write protection off
cfg2&= _PLLEN_OFF ; 4x PLL disabled
cfg2&= _STVREN_ON ; Stack Overflow or Underflow will cause a Reset
cfg2&= _BORV_19 ; Brown-out Reset Voltage (Vbor), low trip point selected.
cfg2&= _LVP_OFF ; High-voltage on MCLR/VPP must be used for programming
__CONFIG _CONFIG2, cfg2
#ENDCONFIG
#ENDIF
;----[Verify Configs have been specified for Selected Processor]----------------
; Note: Only include this routine once, after all #CONFIG blocks
#IFNDEF MCU_FOUND
#ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
#ENDIF
TRISA=%00000000 'PORTS AS OUTPUTS
TRISB=%00010000
TRISC=%00000110 'TWO AS BUTTON INPUTS
OSCCON=%01110011 'INTOSC ENABLED AT 8MHZ
WPUC=%0 'DISABLE C PULLUPS
WPUA=%0
WPUB=%0
ANSELA=%0 'DISABLE ADC
ANSELB=%0 'DISABLE ADC
ANSELC=%0
ADCON0=%0
OPTION_REG=%11011000 'disable pull-ups
DEFINE OSC 8 'SET OSC 16MHZ
X VAR BYTE
FOR X=0 TO 255
SEROUT2 PORTC.5.84,[X]
PAUSE 30
NEXT
;----[16F886 Hardware Configuration]--------------------------------------------
#CONFIG
cfg1 = _INTRC_OSC_NOCLKOUT ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
cfg1&= _WDT_ON ; WDT enabled
cfg1&= _PWRTE_OFF ; PWRT disabled
cfg1&= _MCLRE_OFF ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD
cfg1&= _CP_OFF ; Program memory code protection is disabled
cfg1&= _CPD_OFF ; Data memory code protection is disabled
cfg1&= _BOR_OFF ; BOR disabled
cfg1&= _IESO_ON ; Internal/External Switchover mode is enabled
cfg1&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled
cfg1&= _LVP_OFF ; RB3 pin has digital I/O, HV on MCLR must be used for programming
cfg1&= _DEBUG_OFF ; In-Circuit Debugger disabled, RB6/ICSPCLK and RB7/ICSPDAT are general purpose I/O pins
__CONFIG _CONFIG1, cfg1
cfg2 = _BOR40V ; Brown-out Reset set to 4.0V
cfg2&= _WRT_OFF ; Write protection off
__CONFIG _CONFIG2, cfg2
#ENDCONFIG
TRISA=%00000001 'SET A TO OUTPUT 1=input
TRISC=%00000000 'set half C for in/out
TRISB=%00011000 'set PortB to output
ANSELH=%00000000 ' ADC OFF B
ANSEL=%000000000 'configure PortA as digital except first 2
ADCON1=%10000000 'adc justify
OSCCON=%01110101 'SET FREQUENCY TO 8MHZ
WPUB=%00000000 'turn off Pullups
CM1CON0=0 'DISABLE COMPARATORS
CM2CON0=0 'SAME HERE
DEFINE OSC 8
DEFINE ADC_BITS 12
DEFINE ADC_CLOCK 5
DEFINE ADC_SAMPLEUS 5
X VAR BYTE
FOR X=0 TO 255
SEROUT2 PORTC.5.84,[X]
PAUSE 30
NEXT
Bookmarks