Arizona Microchip P16F883 config setting
Just spent 3 days trying to figure this out. You would think this information would be readily available but its not.
There's lot of stuff out there, but most don't work. They assume you know things. Like a missing , "comma" is vital. I use Mplab 8.7 not because its the latest version, but it seems to get the least complaints. Has the least Bugs.
Anyway this works for me.
; COMMENTED OUT PROGRAM DESRIPTION AND
; DATE STARTED GOES HERE AT THE TOP OF THE PAGE
; YOU WILL REGRET IT LATER IF YOU DO NOT DO A PROPER JOB OF COMMENTING
; TAKE SOME TIME WITH THIS. YOU WILL FORGET HOW THIS PROGRAM WORKS IN A FEW WEEKS
; ANYTHING ON A LINE AFTER THE SEMI COLON ;;;; HAS NO EFFECT IN PROGRAM RUNNING
NO 1 MISTAKE IS: 1st thing when you open MPLAB pull down configure then select device and make sure your device is selected. The device you were last using will be selected when MPLAB opens.
NO 2 MISTAKE IS: 2nd thing when you open MPLAB pull down configure then configuration settings and make sure the box "Configuration Bits set in code" is ticked.
When on the configuration settings page un tick this box if its not already un-ticked and study the various options for your device by clicking on them. You will notice that the value in the value box will change as you change the options in the settings boxes. When you program a device, the values in the values boxes gets programed in to memory locations H2007 and H2008. Make sure that when you have finished looking here that you re-tick the "Configuration Bits set in code" box.
NO 3 MISTAKE IS: If you are programing a number of chips, say 20 for example. You get to about 10 and try to read one. Just to make sure you are code protecting. Mplab comes back with "device code protected" that OK so you carry on programing the rest of your chips. When you read the chip you were checking Mplab fills the program memory with rubbish. And this is what you put in the remaining chips. So if you do a read at anytime, Make sure you rebuild the program before you program any more.
In config world MCLRE_ON means that MCLRE acts as a reset pin. You tie it to +5v with a resistor (15k works nice) and if you short MCLRE to 0v the chip will reset.
With MCLRE_OFF. MCLRE pin acts as a digital input. NOT digital input and output.
,
LIST C=132,F=INHX8M,P=PIC16F883,R=HEX
#INCLUDE <P16F883.INC>
__CONFIG_CONFIG1,_LVP_OFF&_FCMEN_ON&_IESO_OFF&_BOR_ON&_CPD_OFF&_CP_OFF&_MCLRE_ON&_WDT_ON&_PWRTE_ON&_INTRC_OSC_NOCLKOUT
__CONFIG_CONFIG2,_WRT_OFF&_BOR40V
You must put this at the top of your asm file just before your code, but below your commented out program description. Do not add or remove things. There is a comma after CONFIG1, AND CONFIG2,
You can change things like _WDT_ON to _WDT_OFF obviously.
If you are having problems like "BUILD FAILED" try just 1 or 2 config instructions at a time like
__CONFIG _CONFIG1, _LVP_OFF&_FCMEN_ON
Until you get the whole line to work. Its reaaly fussy you must stick to the syntax exactly. Put & on the end and it won't build.
I have 2 versions of the config lines. One for development and one for production. Comment out the one you are not using. If you forget to code protect on prodution devices people will steel your work. When you finish work for the day get in to the habbit of un commenting the code protected version.
Look in C:\Program Files\Microchip\MPASM Suite Here you will find the .inc file , for example P16F883.inc Print out this file. The exact config labels for your device will be here.
; INTOSCIO OSC TYPE _INTRC_OSC_NOCLKOUT 12 OPTIONS
; WDT WATCH DOG TIMER _WDT_ON _WDT_OFF
; PWRT POWER UP TIMER _PWRTE_ON _PWERT_OFF
; MCLR RE3/MCLR PIN FUNCTION _MCLRE_ON _MCLRE_OFF
; CP CODE PROTECTION _CP_ON _CP_OFF
; CPD CODE PROTECTION _CPD_ON _CPD-OFF
; BOREN BROW OUT RESET ENABLE _BOR_ON 4 OPTIONS
; IESO INTERNAL EXTERNAL SWITCH OVER _IESO_ON _IESO_OFF
; FCMEN FAIL SAFE CLOCK MONITOR _FCMEN_ON _FCMEN_OFF
; LVP LOW VOLTAGE PROGRAMMING _LVP_ON _LVP_OFF
; BOR4V BROWN OUT RESET VOLTAGE 4 V OR 2.1 V _BOR21V _BOR40V
; WRT SELF WRITE PROTECTION _WRT_OFF 4 OPTIONS
; DEBUG IN CIRCUIT DEBUG ENABLE _DEBUG_ON _DEBUG_OFF
USE THESE CONFIGS FOR DEVELOPMENT
__CONFIG_CONFIG1,_LVP_OFF&_FCMEN_ON&_IESO_OFF&_BOR_ON&_CPD_OFF&_MCLR_ON&_WDT_ON&_PWRTE_ON&_INTRC_OSC_NOCLKOUT
__CONFIG_CONFIG2,_WRT_OFF&_BOR40V
USE THESE CONFIGS FOR PRODUCTION
__CONFIG_CONFIG1,_LVP_OFF&_FCMEN_ON&_IESO_OFF&_BOR_ON&_CPD_ON&_CP_ON&_MCLRE_ON&_WDT_ON&_PWRTE_ON&_INTRC_OSC_NOCLKOUT
__CONFIG _CONFIG2, _WRT_OFF&_BOR40V
Arizona Microchip P12F675 config setting
LIST C=80,F=INHX8M,P=12F675,R=HEX
#INCLUDE <P12F675.INC>
__CONFIG _INTRC_OSC_NOCLKOUT&_WDT_OFF&_PWRTE_ON&_CP_ON &_CPD_ON &_MCLRE_OFF&_BODEN_ON
I love pics. really glad to have been alive when they were invented, but they are not perfect. Lots of bugs in the pics and in MPLAB, But we will manage.
BACK TO SOLARFRIEND