PDA

View Full Version : Need help with config



Darrenmac
- 19th February 2008, 10:54
I am trying to set up internal asc and MCLr options in the config of my code for a 16f688. The data sheet has the config bits for all of this on page 100. Is there an easy way of setting this? I tried config=%11001111000100 nut this did not work. I got a syntax error. The posts that I have read seem to set each function in the config individualy. Can some one point me in the right direction.
Thanks

Rob
- 19th February 2008, 14:49
Hi,

I may have mis-understood your post but if you're just trying to set the configuration bits try:

for PM Assembler:


@ device INT_OSC, MCLR_OFF


Is this what you're after?

Kind regards

Rob

Archangel
- 19th February 2008, 17:34
Hi Darrenmac,
see this thread for configs.
http://www.picbasic.co.uk/forum/showthread.php?t=543

Rob
- 19th February 2008, 18:53
Hi Darrenmac,
see this thread for configs.
http://www.picbasic.co.uk/forum/showthread.php?t=543

Yeah, that's a good thread - should've posted a link to it myself!

Darrenmac
- 20th February 2008, 02:03
I have read the suggested post again. All examples in this post appear to set each option in the config seperatly, ie pic type, mclr, pwrt as seperate comands but the datasheet for the 16f688 shows a config register called 11.1 (page 100) with each option as seperate bits either set or cleared. Can I just send this as a binary string (or hex equivelent)? if so how?

Archangel
- 20th February 2008, 02:56
Can I just send this as a binary string (or hex equivelent)? if so how?
It never worked that way for me, every newbie reads that and tries it,(I did) and it has never worked that I heard of. You can string the commands together though, like so:


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

The data sheet shows you what happens in those registers, but you can access them only at program time and require you to use the proper syntax as shown in Melanies post.

Darrenmac
- 20th February 2008, 04:23
Ok that clears that up a bit. I guess its more reading and experementing. Thanks

Darrenmac
- 20th February 2008, 08:00
I have tried some of the examples in the suggested post but I get compile errors.
Here are some of what I have tried

@ CONFIG FOSC = HS
opcode expected instead of config

ASM
CONFIG OSCS=OFF ; Oscillator switch OFF
ENDASM
Same error

@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
Same error

I am using Picbasicpro with microcode studios

Melanie
- 20th February 2008, 19:21
Looks like you're still stuck...

I need some information... are you using Microchip's MPASM or MeLab's PM as the Assembler? or don't you know?

If you don't know, then I'll have to install MicroCode Studio which I don't ever use and see what the default's are when trying to compile for this chip.

Oh, finally, what version of PBP are you running?

Darrenmac
- 20th February 2008, 19:49
I thought that MElabs PBP was the compiler. I have ver 2.5.

Acetronics2
- 20th February 2008, 19:51
IF you use MPASM as assembler,

The Config. fuses ***NAMES*** FOR THE '688 are:

( do not care of the EQU H" xxxx" )




;================================================= =========================
;
; Configuration Bits
;
;================================================= =========================

_FCMEN_ON EQU H'3FFF'
_FCMEN_OFF EQU H'37FF'
_IESO_ON EQU H'3FFF'
_IESO_OFF EQU H'3BFF'
_BOD_ON EQU H'3FFF'
_BOD_NSLEEP EQU H'3EFF'
_BOD_SBODEN EQU H'3DFF'
_BOD_OFF EQU H'3CFF'
_CPD_ON EQU H'3F7F'
_CPD_OFF EQU H'3FFF'
_CP_ON EQU H'3FBF'
_CP_OFF EQU H'3FFF'
_MCLRE_ON EQU H'3FFF'
_MCLRE_OFF EQU H'3FDF'
_PWRTE_OFF EQU H'3FFF'
_PWRTE_ON EQU H'3FEF'
_WDT_ON EQU H'3FFF'
_WDT_OFF EQU H'3FF7'
_LP_OSC EQU H'3FF8'
_XT_OSC EQU H'3FF9'
_HS_OSC EQU H'3FFA'
_EC_OSC EQU H'3FFB'
_INTRC_OSC_NOCLKOUT EQU H'3FFC'
_INTRC_OSC_CLKOUT EQU H'3FFD'
_EXTRC_OSC_NOCLKOUT EQU H'3FFE'
_EXTRC_OSC_CLKOUT EQU H'3FFF'
_INTOSCIO EQU H'3FFC'
_INTOSC EQU H'3FFD'
_EXTRCIO EQU H'3FFE'
_EXTRC EQU H'3FFF'



IF Using PM assembler they are :




; *** DEVICE Fuses Definitions
EXTRC equ 3FF80007h ; XX XXXX XXXX X111
EXTRC_OSC_CLKOUT equ 3FF80007h ; XX XXXX XXXX X111
EXTRCIO equ 3FF80006h ; XX XXXX XXXX X110
EXTRC_OSC_NOCLKOUT equ 3FF80006h ; XX XXXX XXXX X110
EXTRC_OSC equ 3FF80006h ; XX XXXX XXXX X110
INTOSC equ 3FF80005h ; XX XXXX XXXX X101
INTRC_OSC_CLKOUT equ 3FF80005h ; XX XXXX XXXX X101
INTOSCIO equ 3FF80004h ; XX XXXX XXXX X100
INTRC_OSC_NOCLKOUT equ 3FF80004h ; XX XXXX XXXX X100
INTRC_OSC equ 3FF80004h ; XX XXXX XXXX X100
EC_OSC equ 3FF80003h ; XX XXXX XXXX X011
HS_OSC equ 3FF80002h ; XX XXXX XXXX X010
XT_OSC equ 3FF80001h ; XX XXXX XXXX X001
LP_OSC equ 3FF80000h ; XX XXXX XXXX X000
WDT_ON equ 3FF70008h ; XX XXXX XXXX 1XXX
WDT_OFF equ 3FF70000h ; XX XXXX XXXX 0XXX
PWRT_OFF equ 3FEF0010h ; XX XXXX XXX1 XXXX
PWRT_ON equ 3FEF0000h ; XX XXXX XXX0 XXXX
MCLR_ON equ 3FDF0020h ; XX XXXX XX1X XXXX
MCLR_OFF equ 3FDF0000h ; XX XXXX XX0X XXXX
PROTECT_ON equ 3FBF0000h ; XX XXXX X0XX XXXX
PROTECT_OFF equ 3FBF0040h ; XX XXXX X1XX XXXX
CPD_ON equ 3F7F0000h ; XX XXXX 0XXX XXXX
CPD_OFF equ 3F7F0080h ; XX XXXX 1XXX XXXX
BOD_ON equ 3CFF0300h ; XX XX11 XXXX XXXX
BOD_NSLEEP equ 3CFF0200h ; XX XX10 XXXX XXXX
BOD_SBODEN equ 3CFF0100h ; XX XX01 XXXX XXXX
BOD_OFF equ 3CFF0000h ; XX XX00 XXXX XXXX
IESO_ON equ 3BFF0400h ; XX X1XX XXXX XXXX
IESO_OFF equ 3BFF0000h ; XX X0XX XXXX XXXX
FCMEN_ON equ 37FF0800h ; XX 1XXX XXXX XXXX
FCMEN_OFF equ 37FF0000h ; XX 0XXX XXXX XXXX



These sets of fuse NAMES are particular to the Pic you use ...

SO ...

THIS


@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H


doesn't mean ANYTHING with a 16F688 ...

Capito ???

Alain

Darrenmac
- 20th February 2008, 20:36
Does this need to be in assembler or in straight basic

Archangel
- 21st February 2008, 07:26
Hi Darrenmac,
Microcode Studio defaults to using the PM assembler, to use MPASM you have to tell it to, here is how: 1.start micro code studio 2. click on the word VIEW at the very top left. 3. Click on Compile and Program Options, and it will open a box which has at it's top, 3 tabs, notice on the first tab an empty box which says use PBL, but do not put a check there, click the center tab marked assembler. You will see an empty box marked: USE MPASM. Put a check mark there and close the box. You are now using MPASM as the assembler.
JS

Darrenmac
- 21st February 2008, 07:56
So do I use
@ MCLR_OFF
or
MCLR_OFF

Rob
- 21st February 2008, 08:17
So do I use
@ MCLR_OFF
or
MCLR_OFF

Hi Darrenmac,

If you have not changed your settings as per Joe S's last post then you are using the PM assembler as this is what Microcode Studio defaults to. In this case see Post#2 in this thread.

If you have changed your settings as per Joe's last post then you need to use:



@ __CONFIG _INTOSC & _MCLRE_OFF


Cheers

Rob

Archangel
- 21st February 2008, 11:45
Hi Darrenmac,
Now after you do all this you will get a compile error telling you you are overwriting the configs . . . that's because you are. In your PBP directory you will have many files with the suffix .inc and the filename will be the number of your PIC. Open it and you will see the following code:


__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

just put a semi colon at the beginning like this:


;__config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _CP_OFF

save the file and then no more error. This config is the " DEFAULT" config setting in case you forget to put in any config so your program will still work sometimes.<br>
Now, why go through all of this? Well suppose you DO NOT want to use the internal oscillator? The DEFAULT configs will not work with a crystal or resonator or EXT oscillator, so do it now and get used to setting the fuses early into your adventure into PIC Magic:)

Darrenmac
- 25th February 2008, 00:04
Still having issues, I think that I am going to be better off by setting them in the programmer. At least I can get it to work. Thanks for every one who has tried to help

nomad
- 25th February 2008, 06:28
Setting them in the programmer works. but if you ever want to just program a chip from a saved hex file, your going to get bit in the behind if you don't remember what settings you used in the programmer. its really a two step operation. PBP is the basic compiler, it creates an assembler file. then either pm or msasm compiler assembles that into your hex file that gets programmed into the chip. the fuse names/settings are written into your basic program but are dependant upon which assembler you use. The assembler is what uses these config commands. PBP passes these to the assembler with the @. so your line would be either
@_config MCLR OFF or
@_config MCLRE OFF depending on if pm or msasm is used.

nomad
- 25th February 2008, 06:57
thats actually
@_config _MCLR_OFF or
@_config MCLRE_OFF the hs osc you were trying should be
@_config _HS_OSC or
@_config HS_OSC someone please check my writing, i can't see the _'s during preview on here. (not at home and using my phone lol)