retepsnikrep
- 10th June 2010, 02:58
Having got a 16F88 project to work thanks to all the members on here i'm back on another project.
The most confusing aspect of the whole thing is getting the chip config settings and defines correct
to start with.
The actual program is usually a doodle in comparison. I've tried to digest the 16F886 datasheet and have cribed quite a lot of code from other threads. But there aren't many exmples specifically for the 16F886. the learning curve for the config is so steep you could become totally frustrated if it was not for forums such as this ;)
I want the chip to run at 8mhz using the internal oscillator, and I would like to use the crystal pins at a
later stage.
I want 10bit analogue inputs on AN0 to AN3
No comparators.
portA 0,1,2,3 analog inputs. Rest as outputs
portB all outputs
portC all inputs
I use the PM assembler.
Can anyone show me an example or two of the config/defines for a similar setup.
I've come up with the following so far.
@ DEVICE PIC16F886,LVP_OFF
@ DEVICE PIC16F886,FCMEN_OFF
@ DEVICE PIC16F886,IESO_OFF
@ DEVICE PIC16F886,BOR_OFF
@ DEVICE PIC16F886,CPD_OFF
@ DEVICE PIC16F886,CP_OFF
@ DEVICE PIC16F886,MCLRE_OFF
@ DEVICE PIC16F886,PWRTE_ON
@ DEVICE PIC16F886,WDT_OFF
@ DEVICE PIC16F886,INTRC_OSC_NOCLKOUT
@ DEVICE PIC16F886,WRT_OFF
@ DEVICE PIC16F886,MCLR_OFF
@ DEVICE PIC16F886,BOD_OFF
@ DEVICE PIC16F886,PROTECT_OFF
Define OSC 8 'Set PicBasic Pro processor speed to 8 Mhz (Must match oscillator value)
OSCCON = %01110001 'Internal 8 mhz Osc
CM1CON0 = 0 'Comparator Off
CM2CON0 = 0 'Comparator Off
'Define ADCIN parameters
Define ADC_BITS 10 'Set number of bits in result (10)
Define ADC_CLOCK 3 'Set clock source (3=rc)
Define ADC_SAMPLEUS 50 'Set sampling time in microseconds (50us)
include "modedefs.bas" 'Allows the use of the serin/serout command
I realise there is still a lot missing from this. :(
The most confusing aspect of the whole thing is getting the chip config settings and defines correct
to start with.
The actual program is usually a doodle in comparison. I've tried to digest the 16F886 datasheet and have cribed quite a lot of code from other threads. But there aren't many exmples specifically for the 16F886. the learning curve for the config is so steep you could become totally frustrated if it was not for forums such as this ;)
I want the chip to run at 8mhz using the internal oscillator, and I would like to use the crystal pins at a
later stage.
I want 10bit analogue inputs on AN0 to AN3
No comparators.
portA 0,1,2,3 analog inputs. Rest as outputs
portB all outputs
portC all inputs
I use the PM assembler.
Can anyone show me an example or two of the config/defines for a similar setup.
I've come up with the following so far.
@ DEVICE PIC16F886,LVP_OFF
@ DEVICE PIC16F886,FCMEN_OFF
@ DEVICE PIC16F886,IESO_OFF
@ DEVICE PIC16F886,BOR_OFF
@ DEVICE PIC16F886,CPD_OFF
@ DEVICE PIC16F886,CP_OFF
@ DEVICE PIC16F886,MCLRE_OFF
@ DEVICE PIC16F886,PWRTE_ON
@ DEVICE PIC16F886,WDT_OFF
@ DEVICE PIC16F886,INTRC_OSC_NOCLKOUT
@ DEVICE PIC16F886,WRT_OFF
@ DEVICE PIC16F886,MCLR_OFF
@ DEVICE PIC16F886,BOD_OFF
@ DEVICE PIC16F886,PROTECT_OFF
Define OSC 8 'Set PicBasic Pro processor speed to 8 Mhz (Must match oscillator value)
OSCCON = %01110001 'Internal 8 mhz Osc
CM1CON0 = 0 'Comparator Off
CM2CON0 = 0 'Comparator Off
'Define ADCIN parameters
Define ADC_BITS 10 'Set number of bits in result (10)
Define ADC_CLOCK 3 'Set clock source (3=rc)
Define ADC_SAMPLEUS 50 'Set sampling time in microseconds (50us)
include "modedefs.bas" 'Allows the use of the serin/serout command
I realise there is still a lot missing from this. :(