Question: PICs with two configuration words versus one, e.g., 16F88 versus 12F683
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
Re: Question: PICs with two configuration words versus one, e.g., 16F88 versus 12F683
Tracecom, Either way is acceptable, There are 2 configuration words for the F88 processor. There are even more for some of the higher end processors. I don't understand the question?
Re: Question: PICs with two configuration words versus one, e.g., 16F88 versus 12F683
Quote:
Originally Posted by
Dave
Tracecom, Either way is acceptable, There are 2 configuration words for the F88 processor. There are even more for some of the higher end processors. I don't understand the question?
Thanks for the response. I know that both ways work, but I want to use the same style layout for the 16F88 as for the 12F683. I have tried several times to rearrange the 16F88 configuration in a vertical list instead of a long horizontal string, but can't get it to compile.
Re: Question: PICs with two configuration words versus one, e.g., 16F88 versus 12F683
Code:
#CONFIG
cfg1 = _INTRC_IO ; Internal Oscillator
cfg1&= _CP_OFF ; Code protection OFF
cfg1&= _CCP1_RB0 ; CCP1 function on RB0
cfg1&= _DEBUG_OFF ; In-Circuit Debugger Disabled
cfg1&= _WRT_PROTECT_OFF ; Flash Program Memory Write Enable bits
cfg1&= _CPD_OFF ; Data EE Memory Code Protection Disabled
cfg1&= _LVP_OFF ; Low Voltage Programming Disabled
cfg1&= _BODEN_OFF ; Brown-out Reset Enable bit
cfg1&= _MCLR_OFF ; Master Clear Reset Disabled
cfg1&= _PWRTE_ON ; Power-up Timer Enabled
cfg1&= _WDT_OFF ; Watch-Dog Timer Disabled
__CONFIG _CONFIG1, cfg1 ; -- Set config word 1
cfg2 = _IESO_OFF ; Internal External Switchover Disabled
cfg2&= _FCMEN_OFF ; Fail-Safe Clock Monitor Disabled
__CONFIG _CONFIG2, cfg2 ; -- Set config word 2
#ENDCONFIG
Re: Question: PICs with two configuration words versus one, e.g., 16F88 versus 12F683