16F886 Config & Defines


Closed Thread
Results 1 to 5 of 5

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default

    My second effort.

    Code:
    @ 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
    	
    	TRISA = %11111111 		'SET PORTA AS INPUTS
    	TRISB = %00000000 		'SET PORTB AS OUTPUTS
    	TRISC = %11111111 		'SET PORTC AS INPUTS
    	
    	ANSEL = %00001111		'SET INPUTS AN0-AN3 AS ANALOG INPUTS
    	
    	ADCON0 = %01000001		'SETUP ADC CONVERTER MODULE FOSC/8 & ENABLE ADC MODULE
    	ADCON1 = %10000000		'SETUP ADC RIGHT JUSTIFY SET REFV to VDD & VSS 
    
    
    '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

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    I do not use PM, so this is how I set it up using MPASM.

    Code:
    @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    
       OSCCON = %01110000
       DEFINE OSC 8
       CM1CON0 = 0 			'Comparator Off
       CM2CON0 = 0 			'Comparator Off
    	
       TRISA = %11111111 		'SET PORTA AS INPUTS
       TRISB = %00000000 		'SET PORTB AS OUTPUTS
       TRISC = %11111111 		'SET PORTC AS INPUTS
       ANSEL = %00001111		'SET INPUTS AN0-AN3 AS ANALOG INPUTS
       ADCON1 = %10000000		'SETUP ADC RIGHT JUSTIFY SET REFV to VDD & VSS 
    
    '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)
    Not much different than yours...
    Dave
    Always wear safety glasses while programming.

  3. #3


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    Code:
    @ __config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
    Not much different than yours...
    Can you explain __config _CONFIG1 ?

    I understand the other statements on that line.

    Thanks peter

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts