PDA

View Full Version : Presetting Configuration Fuses (PIC Defines) into your Program


Melanie
- 12th July 2004, 17:57
1. What are the Configuration Fuses?
2. How can I preset them in my Program?
2.a. When using MeLabs default (PM) Assembler
2.b. When using Microchip's (MPASM) Assembler
3. Where can I find a List of the Configuration Definitions?
3.a. When using MeLabs default (PM) Assembler
3.b. When using Microchip's (MPASM) Assembler


1. What are the Configuration Fuses?

The Configuration Fuses (Configuration Bits) are the settings that configure the PIC for the external environment it is expecting to find... typical settings include Oscillator Type, MCLR pin usage, Code Protection, Brown-Out and Watchdog Timer usage, Low Voltage Programming etc. Different families of PICs have different settings, so the list of settings for a 12F675, will not be the same as the list for a 16F877. When you LOAD a program into your programmer, these settings appropriately configure it without you having to make any additional changes. This saves you a lot of time messing with minor settings before you hit the 'Program' Button. Remember though, you are still able to over-ride these setting manually prior to programming your chip. Most programmers will only configure the settings to your compiled defaults when you LOAD the program, so if you change them manually, you will need to RELOAD your program for them to revert to the default (compiled) settings.


2. How can I preset them in my Program?

This very much depends on if you are using MeLabs default (PM) Assembler, or Microchips (MPASM) alternative.


2.a. When using MeLabs default (PM) Assembler

Example: To set the PIC for XT Oscillator...

@ DEVICE XT_OSC

or

@ DEVICE PIC16F628,XT_OSC

The PIC type is optional, if it is included and you accidentally compile for a chip other than that specified (a 16F628 in this example), the compiler will report an error as a reminder you're potentially doing something wrong.

Multiple definitions are entered on separate lines, one line per definition and can be interspersed with comments…

Example: Typical Settings for a 16F628…

@ DEVICE pic16F628, INTRC_OSC_NOCLKOUT
' System Clock Options
@ DEVICE pic16F628, WDT_ON
' Watchdog Timer
@ DEVICE pic16F628, PWRT_ON
' Power-On Timer
@ DEVICE pic16F628, MCLR_OFF
' Master Clear Options (Internal)
@ DEVICE pic16F628, BOD_ON
' Brown-Out Detect
@ DEVICE pic16F628, LVP_OFF
' Low-Voltage Programming
@ DEVICE pic16F628, CPD_ON
' Data Memory Code Protect
' Set to CPD_OFF for Development Copy
' Set to CPD_ON for Release Copy
@ DEVICE pic16F628, PROTECT_ON
' Program Code Protection
' Set to PROTECT_OFF for Development Copy
' Set to PROTECT_ON for Release Copy


2.b. When using Microchip's (MPASM) Assembler

Example: To set the PIC for Internal Oscillator allowing use of the OSC pins as I/O...

@ __config _INTRC_OSC_NOCLKOUT

Only one config statement is allowed when using MPASM, so multiple definitions follow-on from each other each connected to it’s previous buddy with an &.

Example: Typical Settings for a 16F628…

@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _PWRTE_ON & _MCLRE_OFF & _BODEN_ON & _LVP_OFF & _CP_ALL & _DATA_CP_ON


3. Where can I find a List of the Configuration Definitions?

Now you’ll have noticed that my multiple example for PM and MPASM above are for the same configuration settings (they are now, they weren't when first posted!) - you’ll notice however that there are differences… MCLR_OFF in PM becomes MCLRE_OFF when using MPASM… Here’s how you find the list of possible options available to you… whether you chose to use the default PM or the option of the MPASM Assembler, cross-reference your choices with your chosen PICs Datasheet, look in the section entitled “Special Features of the CPU”. Some configurations may be listed under multiple names, the little extra being provided for your convenience.


3.a. When using MeLabs default (PM) Assembler

Open up the PBP directory, and in it you will find an INC subdirectory. Opening that up and you'll see a heap of files. Find the Mxxxx.INC file for the PIC you're interested in... (example M12F675.INC). If you can’t locate your exact PIC, it might be listed under a family of PICs that share the same settings (example chose M16F62X.INC if you need the settings for a 16F628). Open the file up with something like Notepad – (don’t make any changes to it) and have a look what the file contains…It reveals the internal sex life of the PIC. All the Configuration Fuse Defines that you can use from within PBP are listed here at the top, and lower down all the Registers are Listed. If it's not in the list, you can't use it - but trust me, it's usually all there. Remember, this list is for use with the PM (default assembler).


3.b. When using Microchip's (MPASM) Assembler

If you're going to use MPASM, look for the appropriate file (example for a 16F628 look for P16F628.INC) located in something like the MCHIP_Tools subdirectory of your MPLAB installation. Here you’ll find the Configuration Bits located near the bottom of the list. Simply just use the ones you want. Hey presto your PIC is all defined and ready to run.

Melanie

bearpawz
- 7th November 2004, 04:14
O.K., Now is there a way to set the device in the hex file?

Here is what I am using for a "system"

- Picbasic Pro ver 2.44 to compile ....
- Microcode Studio 2.0.1.6
- For programming: ICPROG 1.05C

... The docs for ICPROG 1.05 C says:

IC-Prog also stores the chip name in the saved HEX file. You can use this option to automaticly set the device by openening its file. Use option "Select device from file" on Misc. page.


And actually... After reading the more closly I guess it means ICPROG stores it there.... (?)


They ARE stored in the HEX file, because that's what you load your programmer with and those definitions are embedded in your compiled file. I have not had the urge to tear apart a HEX file so can't answer your question on where exactly that information is located within it. - Melanie

bartman
- 9th November 2004, 17:16
So in PBC NOT pro there is no @ DEVICE command so I assume there is another way to set fuses and pin defaults or is it only done in the programmer itself?

Further if you did MCLR_OFF are you telling the chip not to look for 5 volts on start up?

Thanks,

Bart

I don't have PBC so can't answer your question regarding it. One day I'll go and get myself a copy just for the fun of it. With MCLR_OFF, the PIC handles it's Power-On RESET internally allowing you to use that pin for other purposes. - Melanie

Acetronics
- 5th March 2005, 14:28
Hi, Mel ...

There's a little problem in that using MPLAB ( 7.01 ) and Picstart ...

When compiling ( PM or MPASM ), everything seems to go pretty well, except this "double definition error"
You can program the chip ... yesss ...wonderful !!!

BUT ... the corresponding HEX file is never stored on your Hard Disk !!!

Rather difficult to send the hex file to poor waiting friends.

as it is impossible to cancel the error message ...Do you have a solution ???

I just want to set OSC to HS ( in PbPlibs, it's Ok but boring ,I know.) and PWRTE to ON ( Where to find it ? )

Alain

mister_e
- 5th March 2005, 18:55
O.K. This is ask really often. Worth to be discussed NOW!

What to do if i get "overwriting previous address content" error message?

This error is return by PBP because your configuration fuse overwrite 'PBP default'. If you open with notepad, in PBP directory, the .INC file of your PIC, let's say 16F628, the file will look like this

;************************************************* *************
;* 16F628.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2002 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 09/27/02 *
;* Version : 2.43 *
;* Notes : *
;************************************************* *************
NOLIST
ifdef PM_USED
LIST
include 'M16F62x.INC' ; PM header
device pic16F628, xt_osc, wdt_on, pwrt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F628, r = dec, w = -302
INCLUDE "P16F628.INC" ; MPASM Header
__config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST

So if you try to define HS oscillator, wich is already define, you'll overwrite the previous content of the PBP setting.

To fix it, just comment those lines :
;device pic16F628, xt_osc, wdt_on, pwrt_on, mclr_on, lvp_off, protect_off

OR
;__config _XT_OSC & _WDT_ON & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
depending what you are using to compile your code, MPASM or PM.

OR some will prefer to edit those line directly... as you wish...

Where can i find the configuration fuse for my PIC ?

All the configuration fuse are in the according .INC file located in the MPLAB directory. In MPLAB 7.01, the default directory, i suppose, is C:\Program Files\Microchip\MPASM Suite.

If you open the appropriate .INC file, you will find all the configuration fuse for your PIC at the end of the file.

looks like this for a 16F628...only the end
;================================================= =========================
;
; Configuration Bits
;
;================================================= =========================

_BODEN_ON EQU H'3FFF'
_BODEN_OFF EQU H'3FBF'
_CP_ALL EQU H'03FF'
_CP_75 EQU H'17FF'
_CP_50 EQU H'2BFF'
_CP_OFF EQU H'3FFF'
_DATA_CP_ON EQU H'3EFF'
_DATA_CP_OFF EQU H'3FFF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FF7'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FFB'
_LVP_ON EQU H'3FFF'
_LVP_OFF EQU H'3F7F'
_MCLRE_ON EQU H'3FFF'
_MCLRE_OFF EQU H'3FDF'
_ER_OSC_CLKOUT EQU H'3FFF'
_ER_OSC_NOCLKOUT EQU H'3FFE'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_EXTCLK_OSC EQU H'3FEF'
_LP_OSC EQU H'3FEC'
_XT_OSC EQU H'3FED'
_HS_OSC EQU H'3FEE'

LIST

Acetronics
- 6th March 2005, 09:05
Hi,Steve

Thank you for the answer, I finally found what I was looking for : in the M16F84.inc,and others .inc all the values do not appear !!!
So, I simply had to add them ...

My question was more about how to have the Hex file written on the HDD ...
as it appears in the program window and can be downloaded to the Pic.

IF this stupid uncancellable error message was only a Warning things would be so simpler !!! ( errorlevel - ... etc )

So, I ask it again : is there something reasonnably possible to memorize the content of the program window ??? ( yeah, write it on a paper .... Thanks !!! )

Mhhh ... fore core calculation, have a look here :
http://www.epcos.com/web/generator/Web/Sections/DesignTools/Ferrites/Page__License,templateId=render,locale=en.html

read you soon
Have a nice Sunday

Alain

RUBiksCUbe
- 28th June 2005, 22:58
Oh yeah! Got it working!! I needed to put in the PIC defines in the beginning. It was giving me those errors because I didn't need the line:

@ INCLUDE "P18F252.INC" ; MPASM Header

I'm not sure why I dont need it, but I think its because 18F252.INC has an identical line in it, so I was including it twice. Thanks soooo much!!!:)

eoasap
- 29th October 2005, 16:41
Hi, i'm using the 18F452 chip so required to use MPASM compiler through Picbasic.
if i try to set a fuse using ONLY (for example) the line below

@ __config _LVP_OFF

i get this error:
x.asm 112: symbol not previously defined (_LVP_OFF)
x.asm 112: argument out of range (not a valid config register address)



if i put the following code:
@ INCLUDE "P18F452.INC" ; MPASM Header
@ __config _LVP_OFF

i get errors like the following:
'1042: duplicate label ("DDRA" or redefining symbol that cannot be redefined)
1607: superseding current maximum RAM and RAM map
120: symbol not previously defined (_LVP_OFF)
etc..

i've been trying for a while now with no luck setting the fuses. any ideas what i'm doing wrong?

thanks!

mister_e
- 29th October 2005, 17:22
The 18F serie work different from the other. In the MPASM directory open the according .INC file. Look at the end you'll discover how to use the Config directive.

Free example here...

@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
' Oscillator switch OFF
' Use HS oscillator (20MHZ here)
'
@ __CONFIG _CONFIG2L, _BOR_ON_2L & _PWRT_ON_2L & _BORV_45_2L
' Brown out reset ON @ 4.5Volts
' Power-up timer ON
'
@ __CONFIG _CONFIG2H, _WDT_ON_2H
' Watch dog timer ON
'
@ __CONFIG _CONFIG4L, _STVR_ON_4L & _LVP_OFF_4L & _DEBUG_OFF_4L
' Stack over/underflow ON
' Low Voltage programming OFF
' Background debugger OFF

eoasap
- 29th October 2005, 17:45
Steve,

Once again you are my savior ;)
Thanks alot for always helping me and guiding me in the right direction. your advice worked perfectly and i got the overwrite error which i see from your other post how to handle that.

Thanks so much :)

mister_e
- 29th October 2005, 18:26
If you are using any PIC18 serie, you will have this warning one day or another. Our friends from Microchip decide to change the way to define the config fuses when using the latest MPASM version 5.00.

The solution is still located at the same place... at the end of the 18XXXX.INC file located in the MPASM folder.


; IMPORTANT: For the PIC18 devices, the __CONFIG directive has been
; superseded by the CONFIG directive. The following settings
; are available for this device.
;
; Oscillator Selection:
; OSC = LP LP
; OSC = XT XT
; OSC = HS HS
; OSC = RC RC
; OSC = EC EC-OSC2 as Clock Out
; OSC = ECIO EC-OSC2 as RA6
; OSC = HSPLL HS-PLL Enabled
; OSC = RCIO RC-OSC2 as RA6

SO now the new method to set the config fuse on the PIC18 serie is...

@ CONFIG OSCS=OFF, OSC=HS
' Oscillator switch OFF
' Use HS oscillator (20MHZ here)
'
@ CONFIG BOR=ON, PWRT=ON, BORV=45
' Brown out reset ON @ 4.5Volts
' Power-up timer ON
'
@ CONFIG WDT=ON
' Watch dog timer ON
'
@ CONFIG STVR=ON, LVP=OFF, DEBUG=OFF
' Stack over/underflow ON
' Low Voltage programming OFF
' Background debugger OFF


Or if you prefer...

ASM
CONFIG OSCS=OFF ; Oscillator switch OFF
CONFIG OSC=HS ; Use HS oscillator (20MHZ here)
CONFIG BOR=ON ; Brown out reset ON
CONFIG BORV=45 ; Brown out detect voltage=4.5 Volt
CONFIG PWRT=ON ; Power-up timer ON
CONFIG WDT=ON ; Watch dog timer ON
CONFIG STVR=ON ; Stack over/underflow ON
CONFIG LVP=OFF ; Low Voltage programming OFF
CONFIG DEBUG=OFF ; Background debugger OFF
ENDASM

Don't forget to comment the default PBP config fuses...

Tissy
- 30th October 2005, 00:11
Nope can't get it going !!

I've used

@ CONFIG FOSC = HS

but it returns the error

__CONFIG directives cannot be used with CONFIG directives

I've even tried

@ CONFIG _CONFIG1H, _FOSC_HS_1H

which returns the same error as above and also,

@ __CONFIG _CONFIG1H, _FOSC_HS_1H

which returns two errors stating:
Overwriting previous address contents (0000)
Overwriting previous address contents (0001)

Any ideas?

eoasap
- 30th October 2005, 01:03
tissy, i just got the same thing you did. That's too bad because Steve's code looks so neat and orderly :) i personally would rather not use all the underscores and such.

Tissy
- 30th October 2005, 01:11
Right, i think i've figured this out.

You need to find the 18F2550.INC (or whatever device you are using) in the PicBasic Pro installation directory.

When you open that file it should look something like this:

;************************************************* ***************
;* 18F2550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F2550, r = dec, w = -311, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HS_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32

This is effectivly where you modify the fuses. The fuse definitions are contained within the P18F2550.INC as contained within your MPASMWIN directory.

*** Note: My advice would be to back any files up before any modifications ***

Hope this clears things up, it worked for me in the end. Now all the fuses are set without the need for modification each time.

Steve

mister_e
- 30th October 2005, 01:47
Just to make things clear for everybody. My solution work!!! As i said in my previous post don't forget to comment the PBP default fuse wich are located in the PBP folder in the according .INC file as Tissy found. So after the modification, Tissy's .INC file will looks like

;************************************************* ***************
;* 18F2550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F2550, r = dec, w = -311, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
;__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
;__CONFIG _CONFIG1H, _FOSC_HS_1H
;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
;__CONFIG _CONFIG3H, _PBADEN_OFF_3H
;__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32


If you don't comment the default fuses... you'll always have this Warning message + another like overwriting previous content..

Also be sure you have the latest MPASM version. 5.00 as now.

About now?

Tissy
- 30th October 2005, 02:09
Yup, that cleared it up, thank you.

Also where can i download MPASM ver 5.00. I've looked at Microchips site but can't find the link. Do you have it by chance?

Thanks again,

Steve

Tissy
- 30th October 2005, 02:36
I had it all going in version 4.01 of MPASM and then downloaded version 5.00....big mistake !!

Now i am getting all sorts of errors. If i use no config fuses in the code and set them manually all compiles fine, but when i try and set the fuses, errors occur again.

I have done what is suggested above and commented out the necessary lines in the 18F2550.INC file found in the PBP directory.

Any suggestions?

Tissy
- 30th October 2005, 02:59
Sorry, to clarify, it does seem to compile, but i get this error:

Warning[230]c:\develo~1\susdco~1\rfusb~1.asm 67:__CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.

This error is repeated a number of times.

Melanie
- 30th October 2005, 09:48
http://www.picbasic.co.uk/forum/showthread.php?p=13087#post13087

Tissy
- 30th October 2005, 11:24
Nope, still getting stacks of errors.

Here is exactly what i have at the tope of my code:

' ---------- [ Configuration fuse ] ----------
@ CONFIG PLLDIV = 5, CPUDIV = OSC1_PLL2, USBDIV = 2
@ CONFIG FOSC = HS
@ CONFIG WDT = ON, WDTPS = 128
@ CONFIG PBADEN = OFF
@ CONFIG LVP = OFF, ICPRT = OFF, XINST = OFF

'@ __CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
'@ __CONFIG _CONFIG1H, _FOSC_HS_1H
'@ __CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
'@ __CONFIG _CONFIG3H, _PBADEN_OFF_3H
'@ __CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L


Clear
DEFINE OSC 20

The necessary lines are commented out in the .INC file as suggested.

The .INC file in the MPASM directory is untouched.

Any other ideas?

mister_e
- 30th October 2005, 12:01
Tissy... are you saying that modifying and saving your C:\PBP\18F2550.INC as follow

;************************************************* ***************
;* 18F2550.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 12/31/04 *
;* Version : 2.46 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F2550, r = dec, w = -311, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
;__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
;__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
;__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
;__CONFIG _CONFIG3H, _PBADEN_OFF_3H
;__CONFIG _CONFIG4L, _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32


And use the following fuse setting...

asm
CONFIG PLLDIV = 12 ; 96 MHz PLL Prescaler: Divide by 12 (48 MHz input)
CONFIG CPUDIV = OSC1_PLL2 ; System Clock Postscaler: [OSC1/OSC2 Src: /1][96 MHz PLL Src: /2]
CONFIG USBDIV = 2 ; Full-Speed USB Clock Source: 96 MHz PLL/2 ;
CONFIG FOSC = HS ; HS oscillator, HS used by USB
CONFIG FCMEM = ON ; Fail-Safe Clock Monitor enabled
CONFIG IESO = OFF ; Internal/External Switch Over Disabled
CONFIG PWRT = ON ; Power-up Timer enabled
CONFIG BOR = ON_ACTIVE ; Brown-out Reset Enabled when the device is not
CONFIG BORV = 43 ; Brown-out Voltage: 4.3V
CONFIG VREGEN = ON ; USB Voltage Regulator Enabled
CONFIG WDT = ON ; Watchdog timer = HW Enabled - SW Disabled
CONFIG WDTPS = 128 ; Watchdog Postscaler = 1:128
CONFIG MCLRE = ON ; MCLR Enabled
CONFIG LPT1OSC = OFF ; Timer1 oscillator configured for high power
CONFIG PBADEN = OFF ; PORTB<4:0> pins are configured as digital I/O on Reset
CONFIG CCP2MX = OFF ; CCP2 input/output is multiplexed with RB3
CONFIG STVREN = OFF ; Stack Overflow Reset Disabled
CONFIG LVP = OFF ; Low Voltage Programming Disabled
CONFIG ICPRT = OFF ; In-Circuit Debug/Programming Disabled
CONFIG XINST = ON ; Extended Instruction Set Enabled
CONFIG DEBUG = OFF ; Background Debugger Disabled
CONFIG CP0 = OFF ; Code Protection Block 0 Disabled
CONFIG CP1 = OFF ; Code Protection Block 1 Disabled
CONFIG CP2 = OFF ; Code Protection Block 2 Disabled
CONFIG CP3 = OFF ; Code Protection Block 3 Disabled
CONFIG CPB = OFF ; Boot Block Code Protection Disabled
CONFIG CPD = OFF ; Data EEPROM Code Protection Disabled
CONFIG WRT0 = OFF ; Write Protection Block 0 Disabled
CONFIG WRT1 = OFF ; Write Protection Block 1 Disabled
CONFIG WRT2 = OFF ; Write Protection Block 2 Disabled
CONFIG WRT3 = OFF ; Write Protection Block 3 Disabled
CONFIG WRTB = OFF ; Boot Block Write Protection Disabled
CONFIG WRTC = OFF ; Configuration Register Write Protection Disabled
CONFIG WRTD = OFF ; Data EEPROM Write Protection Disabled
CONFIG EBTR0 = OFF ; Table Read Protection Block 0 Disabled
CONFIG EBTR1 = OFF ; Table Read Protection Block 1 Disabled
CONFIG EBTR2 = OFF ; Table Read Protection Block 2 Disabled
CONFIG EBTR3 = OFF ; Table Read Protection Block 3 Disabled
CONFIG EBTRB = OFF ; Boot Block Table Read Protection Disabled
ENDASM


it works here...

Tissy
- 30th October 2005, 12:10
Yup, affraid so. I have just comapared the .INC file to yours, exactly the same.

I have also copied your ASM section to my code and it still produces a stack of errors.

Any suggestions?

mister_e
- 30th October 2005, 14:14
OK, i also have the same problem here.. hum hum when i add some code line as you did.

SO it looks like PicBasic is not "New MPASM Compliant" for the config fuses. I'll contact Charles tomorrow.

For now, what you can do is to place your config fuses in the 18F2550.INC in the PBP folder. BUT if you do different project and you need different config fuse setting, You can add a device to the MCS list and create a new .INC and .BAS file for it. OR do an include file to be loaded in the 18F2550.INC file.

NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F2550, r = dec, w = -311, f = inhx32
INCLUDE "P18F2550.INC" ; MPASM Header
INCLUDE "C:\PBPProg\ConfigFuse.cfg" ; Your Config Fuses
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 32


Just drop your config lines in the ConfigFuse.cfg file and it's work... this time. DOH sorry.

Tissy
- 30th October 2005, 15:20
Thanks for that. I thought i was going mad !! Theres nothing worse than people saying it should work when it doesn't. You have save my insanity.

I think the .CFG approach is a good solution.

Many thanks,

Steve

pramodsinha
- 30th October 2005, 15:55
Thanks for that. I thought i was going mad !! Theres nothing worse than people saying it should work when it doesn't. You have save my insanity.

I think the .CFG approach is a good solution.

Many thanks,

Steve
hi,
i also facing similar problem if i try to compile programe on 18f452 i get the similar message like:
Warning[230]c:\develo~1\susdco~1\rfusb~1.asm 67:__CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.
i am using pbp2.44 with mpasm7.21.
I tried to rectify the problems with the above directives but fail should i go for the other version of mplab
pl. help
thanks

Tissy
- 31st October 2005, 00:54
Havin gtaken the .CFG route, Steve does yours come up with these errors?

Warning[205] c:\pbp\sdcconfigfuse.cfg 1 : Found directive in column 1. (CONFIG)
Warning[205] c:\pbp\sdcconfigfuse.cfg 2 : Found directive in column 1. (CONFIG)
Warning[205] c:\pbp\sdcconfigfuse.cfg 3 : Found directive in column 1. (CONFIG)
Warning[205] c:\pbp\sdcconfigfuse.cfg 4 : Found directive in column 1. (CONFIG)
Warning[205] c:\pbp\sdcconfigfuse.cfg 5 : Found directive in column 1. (CONFIG)


Could you post your .CFG file?

Cheers

mister_e
- 31st October 2005, 08:18
The CFG file is the one i post few post before. You just need to Indent your CONFIG lines as i did.

Tissy
- 31st October 2005, 19:33
Yup, got that now, thanks.

One fuse that doesn't work is

BOREN = SBORDIS

But the fuse settings in the .INC are

; Brown-out Reset:
; BOREN = OFF Disabled
; BOREN = ON SBOREN Enabled
; BOREN = NOSLP Enabled except Sleep, SBOREN Disabled
; BOREN = SBORDIS Enabled, SBOREN Disabled

So obvioulsy not all is compatible between, PBP and MPASM.

Out of interest can you try this fuse on your configuration.

Cheers.

Darrel Taylor
- 8th April 2006, 03:01
Well, I was finally forced to upgrade MPASM. And along with it came the dreaded __CONFIG has been deprecated warning. So I figured .. No problem, these guys have already figured it out.

But after trying everything out, and having to modify include files in the include files each time I compile a program that needs a different config, espescially when my programs already have all the config statements in them, just wasn't working out very well. And the thought of having to modify every program I've ever written, to use the new Config syntax, was leaving a bad taste in my mouth.

Fortunately, the old __CONFIG directives still work. The __CONFIG has been deprecated warning, is just that. &nbsp; A warning. &nbsp; And Warnings can be turned off. &nbsp; So until Microchip decides to make it not work anymore, what I'm doing is to add this line to the .inc file for the chip it's being compiled for. errorlevel -230Then everything works just like it always has.
<br>

Melanie
- 8th April 2006, 09:00
Warning[230]: __CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.

If using 18F Parts...

Check this answer by Bruce...

http://www.picbasic.co.uk/forum/showthread.php?p=13087

... if you're not using 18F Parts and you're getting this message - you're in deep trouble.

Darrel Taylor
- 9th April 2006, 00:35
Hi Melanie,

I've read Bruce's post, I've read Mr.E's posts and I've read everyone else's posts about having problems using the new CONFIG syntax.

Then after trying to implement those ideas, I find that it's just not worth it.

I prefer the configuration methods as laid out in your original posts in this thread. The way that it's always been, and the way my programs are already written. And, since there's currently NO reason to use the new syntax, I wanted everyone to know that they don't have to go thru what I just went through.

Simply turn off the warnings, and forget about it. (for now)
<br>

Melanie
- 9th April 2006, 11:42
I agree... (tried them today) the new statements don't appear to work (yet!) in many cases (Warning is replaced... by Error 122... although when I've a spare moment I'll try to find out why), and I'm continuing to use the old method too.

vaidyasp1
- 27th April 2006, 04:43
I am really confused from the thread. It has many different approaches. I am using picbasic pro 2.45 and Mpasm of mplab v7.22. I get the same error.

:__CONFIG has been deprecated for PIC18 devices. Use directive CONFIG.

So, how can i set my configuration bits??? I am using 18f4520.

paul borgmeier
- 2nd July 2006, 15:36
So in PBC NOT pro there is no @ DEVICE command so I assume there is another way to set fuses and pin defaults or is it only done in the programmer itself? ...
PIC BASIC COMPILER USERS (PBC), see this thread for some options on presetting fuses

http://www.picbasic.co.uk/forum/showthread.php?t=4158

(don't let the name of the thread fool you, what you want is toward the bottom)

Paul Borgmeier
Salt Lake City, Utah
USA

dhouston
- 2nd July 2006, 16:36
To save reading the thread Paul cited, this syntax (case insensitive) works with both PBC and PBP when using PM.
asm
DEVICE PIC12F629, INTRC_OSC_NOCLKOUT ;4MHz INT OSC
DEVICE PIC12F629, WDT_OFF ;WATCHDOG
DEVICE PIC12F629, PWRT_ON ;POWER ON TIMER
DEVICE PIC12F629, MCLR_OFF ;GPIO.3 = INPUT
DEVICE PIC12F629, BOD_ON ;BROWNOUT RESET
DEVICE PIC12F629, PROTECT_OFF ;CODE PROTECT
DEVICE PIC12F629, CPD_OFF ;EEPROM PROTECT
endasm

fratello
- 21st April 2009, 09:54
Hi to all !
I use 16F628A in one project ; I try this codes :
@ DEVICE pic16F628A, INTRC_IO, WDT_OFF, PWRT_OFF, BOD_OFF, MCLR_OFF, LVP_OFF, CPD_OFF, PROTECT_OFF 'VAR 1


'asm 'VAR 2
' DEVICE PIC16F628A, INTRC_IO
' DEVICE PIC16F628A, WDT_OFF ;WATCHDOG
' DEVICE PIC16F628A, PWRT_OFF ;POWER ON TIMER
' DEVICE PIC16F628A, MCLR_OFF ;GPIO.3 = INPUT
' DEVICE PIC16F628A, BOD_FF ;BROWNOUT RESET
' DEVICE PIC16F628A, PROTECT_OFF ;CODE PROTECT
' DEVICE PIC16F628A, CPD_OFF ;EEPROM PROTECT
'endasm

but no one don't work ! I receive the message : "Undefined Symbol 'INTRC_IO'".
Please help ! Thanks in advance !

Acetronics
- 21st April 2009, 10:36
Hi, Fratello

Did you had a look to the VERY first post of that thread ???

just " cut and paste " needed !!!

Alain

fratello
- 21st April 2009, 10:50
Even I try this :
@ DEVICE pic16F628, INTRC_IO
the message is still : Undefined symbol 'INTRC_IO' .
All the others line
@ DEVICE pic16F628, WDT_OFF
@ DEVICE pic16F628, PWRT_OFF.... are OK. Just the first one give me error !!!

fratello
- 21st April 2009, 13:01
The correct syntax is :
INTOSC_OSC and not INTRC_IO ! I read in M16F62xA.INC.
Thanks !

quantum
- 26th April 2009, 08:31
Hi
I tried PBP with MPLAB. But there is a problem. HEX file is not becoming. Why?
This is error

OUTPUT

Executing: "C:\PBP246\PBPW.exe" -ampasmwin -oq -z -p12F675 "rew.bas"
PicBasic Pro Compiler 2.46, (c) 1998, 2005 microEngineering Labs, Inc.
All Rights Reserved.
Warning[207] C:\DOCUMENTS AND SETTINGS\ROJHAT\DESKTOP\REW.ASM 78 : Found label after column 1. (device)
Error[122] C:\DOCUMENTS AND SETTINGS\ROJHAT\DESKTOP\REW.ASM 78 : Illegal opcode (pic12F675)
Loaded C:\Documents and Settings\ROJHAT\Desktop\rew.COD.
BUILD SUCCEEDED: Sun Apr 26 09:30:02 2009

wbubel
- 17th July 2009, 17:20
Hello
I am new to this forum, I am a RF Engineer trying to use a 18F1220 with its internal oscillator. So far I have been unsucessfull in doing this. When using MPLAB and a IDC2 in debugger mode the Blink program works fine. When I program the device and run it on its own power it does not work. I think I traced it to the 18f1220.inc file, CONFIG1H fuse.

;************************************************* ***************
;* 18F1220.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 01/27/04 *
;* Version : 2.45 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F1220, r = dec, w = -311, f = inhx32
INCLUDE "P18F1220.INC" ; MPASM Header
__CONFIG _CONFIG1H, _XT_OSC_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8

It sets the oscillator to External. I am not sure what the fuse should be set to. I also beleve the INTRC needs to be reconfigured for 8 MHz. Can anyone assist me? Thank You.

Joe S.
- 17th July 2009, 17:34
Hello
I am new to this forum, I am a RF Engineer trying to use a 18F1220 with its internal oscillator. So far I have been unsucessfull in doing this. When using MPLAB and a IDC2 in debugger mode the Blink program works fine. When I program the device and run it on its own power it does not work. I think I traced it to the 18f1220.inc file, CONFIG1H fuse.

;************************************************* ***************
;* 18F1220.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2004 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 01/27/04 *
;* Version : 2.45 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F1220, r = dec, w = -311, f = inhx32
INCLUDE "P18F1220.INC" ; MPASM Header
__CONFIG _CONFIG1H, _XT_OSC_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_128_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8

It sets the oscillator to External. I am not sure what the fuse should be set to. I also beleve the INTRC needs to be reconfigured for 8 MHz. Can anyone assist me? Thank You.
Hello wbubel, Welcome !
In the MPASM Suite each supported PIC has a file, named for it I. E. P18F1220.inc, in it is listed every valid config and register address. To switch to using MPASM, in MCS click view, compile and program options,click on the tab named assembler, and insert a check in the box "use MPASM", click OK and you are set. Here is what is available for config 1 . . .

;Configuration Byte 1H Options
_IESO_ON_1H EQU H'FF' ; Internal External Oscillator Switch Over mode enabled
_IESO_OFF_1H EQU H'7F' ; Internal External Oscillator Switch Over mode disabled
_FSCM_ON_1H EQU H'FF' ; Fail-Safe Clock Monitor enabled
_FSCM_OFF_1H EQU H'BF' ; Fail-Safe Clock Monitor disabled
_RC_OSC_1H EQU H'FF' ; External RC on OSC1, OSC2 as FOSC/4
_RCIO_OSC_1H EQU H'F7' ; External RC on OSC1, OSC2 as RA6
_LP_OSC_1H EQU H'F0' ; LP Oscillator
_XT_OSC_1H EQU H'F1' ; XT Oscillator
_HS_OSC_1H EQU H'F2' ; HS Oscillator
_HSPLL_OSC_1H EQU H'F6' ; HS + PLL
_EC_OSC_1H EQU H'F4' ; External Clock on OSC1, OSC2 as FOSC/4
_ECIO_OSC_1H EQU H'F5' ; External Clock on OSC1, OSC2 as RA6
_INTIO1_OSC_1H EQU H'F9' ; Internal RC, OSC1 as RA7, OSC2 as FOSC/4
_INTIO2_OSC_1H EQU H'F8' ; Internal RC, OSC1 as RA7, OSC2 as RA6

You can change it in the file you posted or comment them out there and just add the ones you want at the top of your code (my preferred method). Most PICs you use DEFINE OSC 8 , but I won't say all . . .

Bruce
- 17th July 2009, 17:42
_INTIO2_OSC_1H would set it for internal osc with OSC1 & OSC2 pins free to use for I/O.

Look in the P18F1220.INC file in your MPLAB directory for a list of config options.

To select 8MHz internal, look in the 18F1220 data sheet in the Oscillator Configurations
section. It shows the value to write to OSCCON to select various frequencies.

When programming the PIC with the ICD, in inserts a debug kernel, so you may need to
configure the ICD as the programmer before burning the PIC for stand-alone operation.

With the ICD debug kernel programmed into the PIC it needs the PC interface to operate.

wbubel
- 21st July 2009, 15:39
Joe S. and Bruce
Thanks for your valuable help. Sorry its been a while since I've been able to get back to this project. Here is the status. I have set the CONFIG1H fuse to
_INTIO2_OSC_1H as Bruce suggested and OSCCON = %01110000.
I set the ICD as a programmer. When I released the PIC from Reset it runs so slow I thought it was not working. Either I screwed up the OSCCON settings or there is something I am missing.


OSCCON = %01110000 'Define the Osc to 8 MHz
LED2 var PORTB.2 ' LED
cntr var word
FET var PORTA.0
TRISA = %00000000 ' Set PORTA ports 0-4 to input, 5-7 Output
TRISB = %00000000 ' Set PORTB to all output
PORTB = %00000100 ' Clear PORTB
PORTA = %00000000 ' Clear PORTA

cntr = 0
FET = 0

Main:
led2 = 1
pause 100
led2 = 0
pause 100
' cntr = cntr + 1
' if (cntr <= 2) then goto main
' FET = 1
goto main
Stop

Can anyone Help me.

Joe S.
- 21st July 2009, 17:18
I set the ICD as a programmer. When I released the PIC from Reset it runs so slow I thought it was not working. Either I screwed up the OSCCON settings or there is something I am missing.

You should compile NOT using ICD COMPILE, use the one which says compile, only use ICD compile to use the ICD, recompile with the COMPILE for stand alone use. Put a
DEFINE OSC 4
or whatever number is right in you code near the top. The PIC is probably running using the fail safe oscillator .

wbubel
- 30th July 2009, 20:19
This piece of code made it work

DEFINE OSC 4 'Define the Osc to 8 MHz

asm
bsf OSCCON, SCS1 ; 1x = Internal Block
bcf OSCCON, SCS0 ; 00 = Primary Oscillator (20Mhz?)
bsf OSCCON, IRCF2 ; 111=8000 110=4000 101=2000
bsf OSCCON, IRCF1 ; 100=1000 011=0500 010=0250
bcf OSCCON, IRCF0 ; 001=0125 000=0032
MSTABLE010 btfss OSCCON, IOFS
bra MSTABLE010 ; wait until Oscillator is stable
endasm

boroko
- 31st July 2009, 04:02
This doesn't directly apply to your situation this time, but I did run into a sneaky change the other day that took me a while to notice..
I was trying to change the oscillator config on a 18F1320. I had been recently using 18F1330s and just assumed they would be the same since they were so close family wise. Bad assumption. Here are the two together.
;************************************************* ***************
;* 18F1330.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 06/05/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F1330, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F1330.INC" ; MPASM Header
__CONFIG _CONFIG1H, _OSC_INTIO2_1H
; __CONFIG _CONFIG1H, _OSC_XT_1H
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG4L, _XINST_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8

'================================================= =============================
'================================================= =============================

;************************************************* ***************
;* 18F1320.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 06/05/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
"Error: PM does not support this device. Use MPASM."
NOLIST
else
LIST
LIST p = 18F1320, r = dec, w = -311, w = -230, f = inhx32
INCLUDE "P18F1320.INC" ; MPASM Header
__CONFIG _CONFIG1H, _INTIO2_OSC_1H ; this for INT OSC
; __CONFIG _CONFIG1H, _XT_OSC_1H ;was this for XT OSC
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG4L, _LVP_OFF_4L
NOLIST
endif
LIST
EEPROM_START EQU 0F00000h
BLOCK_SIZE EQU 8


the commented out part was my addition, but notice the different syntax for the oscillator statement.
Just hadn't run into that before.
Bo

boroko
- 29th November 2009, 05:18
Hi all,

I have tried to find where the @MyConfig references were without any success. Anyone have them bookmarked?
I still don't have a good handle on changing these without tweaking the .inc files and I'm afraid that's going to bite me someday (even though I do leave the original lines REM'd).

I have seen @MyConfig used, but don't know if there are any caveats.

Thanks
Bo

Joe S.
- 3rd December 2009, 04:57
Hi Bo,
@__Config MyConfig was something Darrel came up with for me, so as to be able to put the config statements on several lines. This was so I could see them without having to scroll across some 100 or so places on the screen. I have MCS set up with large fonts as I have rather poor vision. You still have to comment out the default configs and place the correct configs in your code. It simply allows you to put them on multiple lines. Search for my posts and you will find examples of it's use. If you need examples I can post some Saturday after my new cable internet connection get's hooked up, until then I am not at home while in here.
JS

RussMartin
- 27th January 2010, 04:03
Okay, I've rummaged through the manual, looked at several old threads, and at the "include" files for the device (16F88). I've carefully read through Melanie's post on the subject http://www.picbasic.co.uk/forum/showpost.php?p=2016&postcount=1

Whatever occurs after @_config generates error 122 ("illegal opcode"). It also appears that _INTRC_IO doesn't want to fly. I'm using MPASM.

Maybe I've not found the right thread yet.

<i><b>HELP!</b></i>

Darrel Taylor
- 27th January 2010, 04:54
I don't think it's what's after it, it's the config...

@ __config _CONFIG1, _xxxx
That's @ space two(2) underscores config space "the _CONFIG? word" comma etc...
Only 1 underscore for the config word and options.
<br>

RussMartin
- 27th January 2010, 19:14
Yep, it was the double underscore. Then I commented out the line in the INC file, and everything is peachy-keeno.

Thanks!

brianD
- 9th February 2010, 11:56
HI.

WHAT DO YOU MEAN WITH THE FOLLOWING?

don't forget to comment the PBP default fuse.

mackrackit
- 9th February 2010, 12:51
HI.

WHAT DO YOU MEAN WITH THE FOLLOWING?

don't forget to comment the PBP default fuse.
Did you read the whole thread???