PDA

View Full Version : setting config fuses not working



queenidog
- 21st April 2012, 00:35
Okay guys, stop rolling your eyes... another fuse configuration not working.

I'm using a PIC16F628A and I need pins RA6 and RA7 for I/O so will use the internal oscillator. The config fuse (with assembler directive) for this using MPASM for the assembler is:

@__CONFIG_INTRC_OSC_NOCLKOUT
@__CONFIG_INTOSC_OSC_NOCLKOUT

Alas, this does not work. So, using the MeLabs programmer bit configurator, I select INTOSCIO. Then it works.

I do select "Update configuration from file" and "Reread file before programming".
Using PBP3.0 and Microcode Studio 5.0

Your help to newbie is appreciated.

ScaleRobotics
- 21st April 2012, 07:16
The new PBP3.0 is setup for #config statements. Details here: http://www.picbasic.co.uk/forum/showthread.php?t=543&p=110963#post110963

With the assembly statements, it will see a fight between the .pbpinc configs which are preset in the default configs, and the ones you are trying to set inside your code. It errors out, showing you one trying to overwrite the other. When you use the #config statement, it knows you want to over ride the default configs.

Try putting it in the context (page 100 of the manual):



#CONFIG
__CONFIG _INTOSC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_OFF & _LVP_OFF & _CP_OFF
#ENDCONFIG

queenidog
- 21st April 2012, 17:48
Thanks, I did find that in the manual on page 97 while I was waiting for a reply.
This is what I've got: (space in column 1)
#config
__CONFIG _INTRC_OSC_NOCLKOUT
__CONFIG _INTOSC_OSC_NOCLKOUT
#endconfig

I don't get compile errors with this syntax, but I get an ASM error "Overwriting previous address contents". As a result the Meprog programmer menu doesn't open (because of the error). I open the programmer manually and program. All is well...except the program doesn't work. It's at this point where I can change the bits in the programmer configuration menu to INTOSCIO and the program does work.

ScaleRobotics
- 21st April 2012, 18:22
Hi queenidog.

You will have to pick either one, but not both.

Either use

#config
__CONFIG _INTRC_OSC_NOCLKOUT
#endconfig

or

#config
__CONFIG _INTOSC_OSC_NOCLKOUT
#endconfig

Depending on which one you want to use, probably INTOSC.

The options Are:

; __CONFIG labels for PIC16F628A:
;
;CONFIG Options
;
; Oscillator Selection bits
; _RC_OSC_CLKOUT ;RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
; _ER_OSC_CLKOUT ;RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
; _RC_OSC_NOCLKOUT ;RC oscillator: I/O function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
; _ER_OSC_NOCLKOUT ;RC oscillator: I/O function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
; _INTOSC_OSC_CLKOUT ;INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
; _INTRC_OSC_CLKOUT ;INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
; _INTOSC_OSC_NOCLKOUT ;INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
; _INTRC_OSC_NOCLKOUT ;INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
; _EXTCLK_OSC ;EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN
; _HS_OSC ;HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
; _XT_OSC ;XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
; _LP_OSC ;LP oscillator: Low-power crystal on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN

queenidog
- 22nd April 2012, 13:35
Well hot damn, it this didn't work! Thanks.

I guess I didn't understand the difference between the two so picking both was a good thing. (I did this with two girlfriends once when I was in grade IV, they both ended up hating me).

So what is the difference? I used intosc.

ScaleRobotics
- 22nd April 2012, 16:03
You raise a good question. Looking into it further, there is no difference. I looked at the data sheet, and it says you have 8 options:


111 = RC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
110 = RC oscillator: I/O function on RA6/OSC2/CLKOUT pin, Resistor and Capacitor on RA7/OSC1/CLKIN
101 = INTOSC oscillator: CLKOUT function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
100 = INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
011 = EC: I/O function on RA6/OSC2/CLKOUT pin, CLKIN on RA7/OSC1/CLKIN
010 = HS oscillator: High-speed crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
001 = XT oscillator: Crystal/resonator on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN
000 = LP oscillator: Low-power crystal on RA6/OSC2/CLKOUT and RA7/OSC1/CLKIN


Then looking at the .info file, it shows 20 options, which doesn't quite make sense. Looking closer, we have to look into the microchip .inc files, located here: C:\Program Files (x86)\Microchip\MPASM Suite\P16F628A.inc

Here there are 3 internal options with no clockout which all have the same EQU number.


_FOSC_INTOSCIO EQU H'3FFC' ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
_INTOSC_OSC_NOCLKOUT EQU H'3FFC' ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
_INTRC_OSC_NOCLKOUT EQU H'3FFC' ; INTOSC oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN


So, I guess you can use any one of the above and get the same result.

queenidog
- 23rd April 2012, 14:30
More info:

You said to "use either but not both" and that's good advice because if I use EITHER, it works. If I use both, it don't work!

I used INTOSC because it was more "intuitive" in the language. I think the INTRC is an older term that was "deprecated" as they say, but still works for compatibility.

Either one works, but not at the same time.