Hi, Glenn
a '2520 config header, just for example.
Code:
'*****************************************************************************
'*****************************************************************************
'Config processeur
'*****************************************************************************
'
@ __CONFIG _CONFIG1H, _IESO_OFF_1H & _OSC_XT_1H & _FCMEN_OFF_1H
@ __CONFIG _CONFIG2L, _BOREN_OFF_2L & _PWRT_ON_2L
@ __CONFIG _CONFIG2H, _WDT_OFF_2H & _WDTPS_128_2H
@ __CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_PORTBE_3H
@ __CONFIG _CONFIG4L, _STVREN_OFF_4L & _LVP_OFF_4L & _DEBUG_OFF_4L & _XINST_OFF_4L
@ __CONFIG _CONFIG5L, _CP0_OFF_5L & _CP1_OFF_5L
@ __CONFIG _CONFIG5H, _CPB_OFF_5H & _CPD_OFF_5H
@ __CONFIG _CONFIG6L, _WRT0_OFF_6L & _WRT1_OFF_6L
@ __CONFIG _CONFIG6H, _WRTB_OFF_6H & _WRTC_OFF_6H & _WRTD_OFF_6H
@ __CONFIG _CONFIG7L, _EBTR0_OFF_7L & _EBTR1_OFF_7L
@ __CONFIG _CONFIG7H, _EBTRB_OFF_7H
'*****************************************************************************
'Config TIMERs
OSCCON = %01100000
'*****************************************************************************
'Config TIMERs
T0CON = %00000010 ' 16Bits 1/8 prescaler, Horloge Système, OFF
' Utilisé pour détection sous regime ou arret
T1CON = %00000000 '1/1 prescaler, Quartz 32,768
' *** Géré par Elapsed Timer ***
T3CON = %01110001 ' CCP SUR TMR3,1/8 prescaler,Horloge système,ON
' Mesure de la vitesse
'*****************************************************************************
'Config CCP1 arret CCP2
CCP1CON = %00000101 ' Capture sur front montant
CCP2CON = %00000000 'inhibition module CCP2
'*****************************************************************************
'Inhibition SSP
SSPCON1.5 = 0
'*****************************************************************************
'Inhibition Comparateurs
CMCON = 7
'*****************************************************************************
'Inhibition Reference interne
CVRCON = 0
'*****************************************************************************
'Config Interruptions
INTCON = %10000000
INTCON2 = %11110000
INTCON3 = %00000000
PIE1 = %00000100
PIE2 = %00000000
IPR1 = %00000001
IPR2 = %00000000
RCON = %10000000
'*****************************************************************************
'Config ADC
'*****************************************************************************
ADCON0 = %11000000 '
ADCON1 = %00011100 ' A0 > A2 Vref+ A3, Vref- = Vss
ADCON2 = %10100110 ' Right Just., 8Tad, clock /64
'*****************************************************************************
'*****************************************************************************
'Config et Prepositionnement E/S
'*****************************************************************************
PORTA = %00110000
PORTB = %00010000
PORTC = %00001000
'PORTD = 0
'PORTE = 0
TRISA = %00011111
TRISB = %00000110
TRISC = %00000111
'TRISD = %00000000
'TRISE = %00000000
'
Powerful devices need to configure more registers ... that's it !!!
Alain
Bookmarks