Please show me how to organize the configuration bits for PICs with more than one configuration word in the same format that they can be organized for PICs with a single configuration word. There are two code samples: one is for a 12F683 and the configuration bits are organized the way I like to see them; the second is for a 16F88 and the configuration bits are in a long string, but I would like to know how to organize them like they are organized in the 12F683 file. Thanks
Code:
' Name: 16F88 Blink1.pbp
' Compiler: PICBASIC PRO Compiler 3
' Assembler: MPASM
' Author:
' Target PIC: 16F88
' Hardware: CRH Breadboard
' Oscillator: 4MHz Internal
' Date: 10 Dec 2013
' Description:
'Device Configuration
#IF __PROCESSOR__ = "16F88"
#config
__CONFIG _CONFIG1, _CP_OFF & _CCP1_RB0 & _DEBUG_OFF & _WRT_PROTECT_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _MCLR_OFF & _PWRTE_ON & _WDT_OFF & _INTRC_IO
__CONFIG _CONFIG2, _IESO_OFF & _FCMEN_OFF
#ENDCONFIG
#else
#MSG "Wrong microcontroller selected!"
#endif
'Register Initialization
TRISB = %11111110 ' Sets up RB0 pin of PORTB as an output
' and pins RB7-RB1 of PORTB as inputs
OSCCON = $60 ' Sets the internal oscillator in the
' 16F88 to 4 MHz
'Main Code
start: ' Label for beginning loop
PORTB.0 = 1 ' Makes pin PORTB.0,(RB0), output HIGH (+5 volts)
Pause 500 ' Pause 500 milliseconds (0.5 seconds) with LED on
PORTB.0 = 0 ' Makes pin PORTB.0,(RB0), output LOW (0 volts)
Pause 500 ' Pause 500 milliseconds (0.5 seconds) with LED off
GoTo start ' Jump to loop label
' Makes the program run forever.
End ' This line is in case the
' the program gets lost.
Code:
' Name: 12F683 HPWM.pbp
' Compiler: PICBASIC PRO Compiler 3
' Assembler: MPASM
' Author:
' Target PIC: 12F683
' Hardware: CRH Breadboard
' Oscillator: 8MHz Internal
' Date: 1 Nov 2013
' Description:
' Device Configuration:
#IF __PROCESSOR__ = "12F683"
#config
cfg1 = _INTRC_OSC_NOCLKOUT ; Internal oscillator
cfg1&= _WDT_OFF ; Watch Dog Timer disabled
cfg1&= _PWRTE_ON ; Power-up Timer enabled
cfg1&= _MCLRE_OFF ; Master Clear Reset disabled
cfg1&= _CP_OFF ; Program Code Protection disabled
cfg1&= _CPD_OFF ; Data Code Protection is disabled
cfg1&= _BOD_OFF ; Brown-out Detect disabled
cfg1&= _IESO_OFF ; Internal External Switchover mode disabled
cfg1&= _FCMEN_OFF ; Fail-safe Clock Monitor disabled
__CONFIG cfg1 ; Set the configuration bits
#ENDCONFIG
#else
#MSG "Wrong microcontroller selected!"
#endif
' Register Initializations:
ADCON0 = 0
ANSEL = 0
CMCON0 = 7 ' Comparators off.
TRISIO = 0
GPIO = 0
OSCCON = %01110001 ' Internal 8MHz osc.
CCP1CON = %00001100 ' CCP1, PWM mode
CCPR1L = 0
T2CON = %00000101 ' TMR2 on, prescaler 1:4
PR2 = 250 ' Set the PWM period.
' Includes:
' Defines:
DEFINE OSC 8
' Constants:
' Variables:
' Aliases and modifiers:
Speed var CCPR1L
Btn Var GPIO.4 ' Assuming ; the pin is pulled down to GND by 10K resistor, and button pulls it high to Vdd.
' LED is connected to GPIO.2 (on board PWM module)
' Program Code:
pause 10
Start:
if btn then
if speed + 51 < 256 then ' 0, 51, 102, 153, 204, 255 0
speed = speed + 51
else
speed = 0
endif
while btn : pause 20 : wend
endif
pause 2
goto Start
end
Bookmarks