Barry, as I said I used the 1827 and it was a pain to find all correct settings. I had to enable PWM for two outputs.
I do not claim that the settings may be complete, and according to your needs you have to change some.
But is is a good start:
Code:
ASM
__config _CONFIG1, _FOSC_INTOSC & _WDTE_OFF & _PWRTE_ON & _MCLRE_ON & _CP_ON & _CPD_OFF & _BOREN_ON & _CLKOUTEN_OFF & _IESO_OFF & _FCMEN_OFF
__config _CONFIG2, _WRT_OFF & _PLLEN_ON & _LVP_OFF & _STVREN_OFF & _BORV_25
ENDASM
DEFINE OSC 32 'Internal RC Oscillator with PLL
DEFINE HSER_RCSTA 90h
DEFINE HSER_TXSTA 24h
DEFINE HSER_BAUD 115200
DEFINE HSER_SPBRG 68
DEFINE HSER_CLROERR 1
DEFINE ADC_BITS 10 ' Set number of bits in result (8, 10 or 12)
DEFINE ADC_CLOCK 3 ' Set clock source (rc = 3)
DEFINE ADC_SAMPLEUS 50 ' Set sampling time in microseconds
OSCCON= %11110000 'PLL enabled, Internal RC-8MHz and PLL x 4
PORTB = 0:PORTA=0
TRISB = %10110111
TRISA = %00111111
ADCON0 = %00000001
ADCON1 = %10100011
ANSELA = %00000001 'ANS0 analog in, all ohters digital I/O
ANSELB = %00000110 ' PB1,PB2 Analog inputs
APFCON0 = %00000000
APFCON1 = %00000001
BAUDCON = %00011000 'Bit 4: 1 Inverted data on Tx, 0 Non inverted for direct serial use
CCP1CON = %00111100 'Control of CCPx modules
CCP2CON = %00111100
CCP3CON = %00000000
CCP4CON = %00000000
CM1CON0.7=0
CM2CON0.7=0
CPSCON0 = 0
CPSCON1 = 0
DACCON0 = 0
FVRCON = %10000011
INTCON = %11000000 ' global & peripheral ints enabled
OPTION_REG = %01000111 'Tmr0 from 256 presc and Int Clock
WPUB=%10110001 ' Weak pullup individual settings. See also on Option_Reg
DEFINE CCP1_REG PORTB
DEFINE CCP1_BIT 3
DEFINE CCP2_REG PORTB
DEFINE CCP2_BIT 6
CCPTMRS=0
PR2=255
CCP1CON=$0C
CCP2CON=$0C
T2CON=%00000110 'Prescaller / 16, Timer2 ON
Ioannis
Bookmarks