PDA

View Full Version : PIC16F887 fuse config statements for PBP anyone?



CuriousOne
- 5th May 2014, 17:23
Hello.

Due to project complexity, I have to switch to PIC16F887.

I have two programmers, DIY K-149BC, which does not supports that IC, and I also have Microchips Pickit 2 device, which supports this chip, but has no config window for fuzes. So I want to know how to set MCLR=DISABLE, enable internal oscillator and so on.

Any ideas?

Darrel Taylor
- 5th May 2014, 18:54
http://support.melabs.com/content/563-meCONFIG

CuriousOne
- 6th May 2014, 05:08
Wow thanks!

Will try it today.

CuriousOne
- 6th May 2014, 05:43
A little question, how to set frequency of internal oscillator?

There's no such setting under FOSC tab.

HenrikOlsson
- 6th May 2014, 06:17
Hi,
It's not in meConfig because setting the oscillator frequency is not done via the CONFIG words, you need to write the appropriate value to the OSCCON register.

/Henrik.

CuriousOne
- 6th May 2014, 07:46
Yes I understand but why not?

They have done such nice utility, why not finish it properly? :)

CuriousOne
- 6th May 2014, 07:58
here's sample code, it flashes and verifies ok, but does not works (led does not blink)



;----[16F887 Hardware Configuration]--------------------------------------------
#IF __PROCESSOR__ = "16F887"
#DEFINE MCU_FOUND 1
#CONFIG
cfg1 = _INTRC_OSC_NOCLKOUT ; INTOSCIO oscillator: I/O function on RA6/OSC2/CLKOUT pin, I/O function on RA7/OSC1/CLKIN
cfg1&= _WDT_ON ; WDT enabled
cfg1&= _PWRTE_OFF ; PWRT disabled
cfg1&= _MCLRE_OFF ; RE3/MCLR pin function is digital input, MCLR internally tied to VDD
cfg1&= _CP_OFF ; Program memory code protection is disabled
cfg1&= _CPD_OFF ; Data memory code protection is disabled
cfg1&= _BOR_ON ; BOR enabled
cfg1&= _IESO_ON ; Internal/External Switchover mode is enabled
cfg1&= _FCMEN_ON ; Fail-Safe Clock Monitor is enabled
cfg1&= _LVP_OFF ; RB3 pin has digital I/O, HV on MCLR must be used for programming
cfg1&= _DEBUG_ON ; In_Circuit Debugger enabled, RB6/ICSPCLK and RB7/ICSPDAT are dedicated to the debugger
__CONFIG _CONFIG1, cfg1

cfg2 = _BOR40V ; Brown-out Reset set to 4.0V
cfg2&= _WRT_OFF ; Write protection off
__CONFIG _CONFIG2, cfg2

#ENDCONFIG

#ENDIF

;----[Verify Configs have been specified for Selected Processor]----------------
; Note: Only include this routine once, after all #CONFIG blocks
#IFNDEF MCU_FOUND
#ERROR "No CONFIGs found for [" + __PROCESSOR__ +"]"
#ENDIF
define osc 4
OSCCON=%01100111


kikli:
high portc.5
pause 500
low portc.5
pause 500
goto kikli

HenrikOlsson
- 6th May 2014, 08:07
Hi,
Because (and this is of course my opinion, I can't speak for Darrel or meLabs), it's a utility designed for producing code (not actual code but rather directives to the compiler/assembler) that sets the CONFIG fuses correctly - and that's what it does. CONFIG is part of flash memory, it is being set when the device is programmed. OSCCON is SFR (RAM) and is set at runtime.

If OSCCON, why not ADCON, ANSEL, TRIS, CMCON, TMR, BAUDCTL, SSPCON, INTCON, EECON, PIR, PCON, CCPR, WRCON, WPUB, OPTION_REG, SR_CON.....?

/Henrik.

HenrikOlsson
- 6th May 2014, 08:54
Hi,
What's your powersupply voltage? You have BOR enabled @4V so anything below that will hold the chip in reset.
Try leaving OSCCON.0 = 0.

Finally, and this doesn't matter in THIS particular case, all define statements are case sensitive and all PBP defines are defined UPPER CASE so it must be define OSC xx or it'll behave as it wasn't even there.

/Henrik.

AvionicsMaster1
- 6th May 2014, 13:59
You could try ANSEL=0 to set your ports digital which could prevent the LED from turning on.