Andre_Pretorius
- 13th March 2011, 14:59
I am trying to set my PIC16F913 to use a internal ossilator in code without changing any other files. acording to another post i just add "@__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF" to the code but i get a error on compiling "Overwriting previous address contents" can any one shed some light on this
INCLUDE "MODEDEFS.BAS"
Asm
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
ERRORLEVEL -306
Endasm
'DEFINE OSC 4 ' Define crystal as 4Mhz
'*ADC setup*
DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS
'This Part set PORTA 0-5 an analog inputs
ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
ANSEL = %00000011 'PortA 0 & 1 Analog 2 - 5 Digital
'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
TRISA = %00001111 'set PORTA 0-4 as inputs PORTA 5 output
ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913
LCDCON = 0 'Disable LCD function on PORTC 0 - 2
TRISC = %00000000 'Set PORTC as output
TRISB = %00000000 'Sert PORTB as output
INCLUDE "MODEDEFS.BAS"
Asm
__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF
ERRORLEVEL -306
Endasm
'DEFINE OSC 4 ' Define crystal as 4Mhz
'*ADC setup*
DEFINE ADC_BITS 10 'SETS NUMBER OF BITS IN RESULTS 8,10,12
DEFINE ADC_CLOCK 3 'SETS CLOCK SOURCE (RC = 3)
DEFINE ADC_SAMPLEUS 50 'SETS SAMPLING TIME IN MICROSECONDS
'This Part set PORTA 0-5 an analog inputs
ADCON1 = %01110000 'FRC (clock derived from a dedicated internal oscillator = 500 kHz max)
ANSEL = %00000011 'PortA 0 & 1 Analog 2 - 5 Digital
'The ANSEL (91h) and CMCON0 (9Ch)registers must be initialized to configure an
CMCON0 = %00000111 'analog channel as a digital input. Pins configured as analog inputs will read ‘0’.
TRISA = %00001111 'set PORTA 0-4 as inputs PORTA 5 output
ADCON0.7 = 1 'Right justify output of ADC datasheet P145 of 16F913
LCDCON = 0 'Disable LCD function on PORTC 0 - 2
TRISC = %00000000 'Set PORTC as output
TRISB = %00000000 'Sert PORTB as output