View Full Version : Config problem PIC16F886
Bosse
- 22nd August 2008, 14:13
Can anyone please help me with configuration with PIC16F886- Want to run INTERNAL OSC 8 MHZ - ALL DIGITAL.
Bosse
Darrel Taylor
- 22nd August 2008, 18:20
You'll need to have PBP 2.50 for this series of chips.
OSCCON = %01110001 ; Internal 8 mhz Osc
ANSEL = 0 ; All Digital
ANSELH = 0
Bosse
- 22nd August 2008, 18:34
Thank you Darrel,
I have PBP 2.47 - in Microengineering labs homesite they declare that PBP 2.47 can compile F886 ???
Have used PIC16F88, but need more I/O so decided to try F886 but have real problem with config word
@ DEVICE PIC16F886, INTOSCIO,WDT_OFF,MCLR_OFF,LVP_OFF,PROTECT_OFF,BOD_ OFF,CPD_OFF,IESO_OFF,FCMEN_OFF,PWRT_OFF
So I have to update to PBP 2.50 - will do that soonest possible.
Can I compile in MPASM and then use the file?
Thanks again
Darrel Taylor
- 22nd August 2008, 19:07
Oh, oops. Yes 2.47 will do.
What kind of problem are you having with the config? Looks ok to me.
<br>
Bosse
- 25th August 2008, 17:36
Hi Darrel,
Always get a lot of messages that the config is not correct.
Now I have decided to use Crystal and will be very greatful for help with configuration word(s)
Have used a PIC16F876A before without any problem, think it can be that the F886 have 2 config words????
Darrel Taylor
- 25th August 2008, 21:14
Are you using the default PM assembler, or MPASM?
For PM, the CONFIG2 word is set using the DEVICE2 pseudo-op. But not setting config2 will not cause an error. And your DEVICE line above looks OK (if using PM).
If you are using MPASM then it would be ...
@ __config _CONFIG1, _INTOSCIO & _WDT_OFF & _MCLRE_OFF & _LVP_OFF & _CPD_OFF & _FCMEN_OFF & _IESO_OFF
Of if you're using a crystal now, replace _INTOSCIO with _XT_OSC or _HS_OSC.
Don't forget to comment the config line in the 16F886.inc file in your PBP folder.
<br>
Ruben Pena
- 26th August 2008, 03:50
Hi Bosse:
If you are using the port A as digital, you will need to disable too the
comparators.
CM1CON0 = 0
CM2CON0 = 0
Greetings...
Ruben de la Pena V.
Bosse
- 27th August 2008, 20:30
Thank you very much Darrel and Ruben,
I use PM assembler. Have decided to use a ceramic resonator (20 MHz)
Wants ALL DIGITAL if possible.
Will try your configuration recommendations
Thanks again
Bosse
Bosse
- 7th September 2008, 20:13
Hi,
Now I have done something ?????
Get the error: Error 16F886.INC 15 : [201] ''' expected
Have changed the INC file, but changed it back to original again, so now when I try to compile get this error.
Use PM and PicBasic Pro with MicroCode Studio Pro.
Please is there anybody how can help me solve the problem
Bosse
Archangel
- 7th September 2008, 21:38
Hi,
Now I have done something ?????
Get the error: Error 16F886.INC 15 : [201] ''' expected
Have changed the INC file, but changed it back to original again, so now when I try to compile get this error.
Use PM and PicBasic Pro with MicroCode Studio Pro.
Please is there anybody how can help me solve the problem
Bosse
Hi Bosse,
Can you post your .inc file, at least the area where you been pokin' around ? Also post the first say 8 - 10 lines of the code you are trying to get to work?
Bosse
- 7th September 2008, 23:24
Hi Joe,
First I tries to get Config O.K. so have only a small program for testing config words. Wants ALL digital. Working with a project with MAXIMS iButton chips, works perfect with 16F88.
;************************************************* ***************
;* 16F886.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 05/26/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
device pic16F886, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F886, r = dec, w = -302
INCLUDE "P16F886.INC" ; MPASM Header
__config _CONFIG1, _XT_OSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
Think the INC file is O.K - But can not understand why it stops working????
'@ DEVICE PIC16F886, INTOSCIO, WDT_ON,MCLR_OFF,LVP_OFF,PROTECT_OFF,BOD_OFF,CPD_OF F,IESO_OFF,FCMEN_OFF,PWRT_ON
'DEFINE OSC 8
OSCCON = %01110001 ' Internal 8 mhz Osc
ANSEL = 0 ' All Digital
ANSELH = 0
'ADCON1 = $0F
'ADCON0 = 0
TRISC = 0
RUN:
PORTC.0 = 1
pause 1000
PORTC.0 = 0
PAUSE 1000
goto RUN
END
Do you recomend to use MPASM assembler? Have now tried more than 2 weeks with this problem.
PORTA is reserved for furure use - PORTA.1 = Input
PORTB %??001111 - RB6 and RB7connected to progsocket for PicKit2.
PORTC %11100100 - RC3 = SCK - RC4 = SDA 24LC256
Would be very great ful for all help and advices
Thanks in advance
Bosse
Bosse
- 7th September 2008, 23:32
Hi Joe,
Forget to tell you the Warning from PicKit2.
Warning: Some configuration words not in hex file.
Ensure default values above right are acceptable.
Configuration 2FF9 0700
Bosse
skimask
- 7th September 2008, 23:41
http://www.picbasic.co.uk/forum/showthread.php?t=543
What it boils down to....
Method one:
Comment out the config settings in the inc file, put the actual config settings in your source code prefixed by either an @ or inside an ASM block. Use this method if you frequently change this setting or that setting a lot.
Method two:
Comment out the original config settings in the inc file, add in your own config settings to that same inc file in the same place. I use this method since I almost always use the PICs in the same way (i.e. HS_PLL for the 18F, MCLR on, and so on and so on)
Method three (and others)...
Lots of different methods for doing this sort of thing. The 2 above are the 2 that I use.
Check the particular PICs .INC file in the MPASM directory for your particular PICs various options...
Bosse
- 8th September 2008, 02:02
Hi Skimask,
Thank you !
Now it starts working, have changed the config in the 16F886.INC file and moved the configuration over to the real program. But still have the warning from PicKit2.
Have to work on and make some small changes and see if the warnings will go away.
I'm not proffessional, but have learned very much from this forum and are very greatful for all your help.
Thank you ALL
Bosse
skimask
- 8th September 2008, 02:10
Now it starts working, have changed the config in the 16F886.INC file and moved the configuration over to the real program. But still have the warning from PicKit2.
Probably means that you typed something in wrong, missing a space here or there, have an extra ' character, maybe a " character in there somewhere that shouldn't be...
Post the real CONFIG part that you're using. We can guess at your problem all day. Could be that the tire pressure is low...we'll never know...
Bosse
- 8th September 2008, 03:20
Hi skimask,
Have changed to INTOSCIO in 16F886.INC and have the following config in program
OSCCON = %01110001 '; Internal 8 mhz Osc
'OSCCON = %01100000
ANSEL = 0 '; All Digital
ANSELH = 0
CM1CON0 = 0
CM2CON0 = 0
ADCON1 = $0F
ADCON0 = 0
TRISA = %00000010
TRISB = %00001111
TRISC = %11100100
The program will not work perfect yet ???
Bosse
skimask
- 8th September 2008, 03:22
That's the register setup, not the CONFIG fuse setup
skimask
- 8th September 2008, 03:30
Hi Joe,
Forget to tell you the Warning from PicKit2.
Warning: Some configuration words not in hex file.
Ensure default values above right are acceptable.
Configuration 2FF9 0700
Bosse
According to that CONFIG word, and according to the PIC16F886 datasheet, this is your configuration:
DEBUG mode is OFF
RB3 is I/O
Fail Safe Clock is ON
Int/Ext Clock Switching is ON
BOR is ON
CPD is OFF
CP is OFF
RE3/MCLR is MCLR
PWRT is OFF
WDT is ON
Oscillator mode is INTRC, ClkOut on OSC2, R/C input on OSC1
All Write Protects are Off
What's not right?
I'd be betting it's your spelling of INTRC. Check the 16F886 INC file in the MPASM directory to figure out how to spell it so the assembler is happy.
Bosse
- 8th September 2008, 03:32
Hi again skimask,
Have also changed to MPASM assembler and it works better now
Bosse
Archangel
- 8th September 2008, 05:51
Probably means that you typed something in wrong, missing a space here or there, have an extra ' character, maybe a " character in there somewhere that shouldn't be...
Just got back from dinner . . . That is why I asked him to post the .inc file and first 8 lines or so, to see if he introduced an extra character . . .
Post the real CONFIG part that you're using. We can guess at your problem all day. Could be that the tire pressure is low...we'll never know...
we can hope . . .
Bosse
- 8th September 2008, 16:39
Hi skimask, Joe and Darrel
Can not find out how to find out about the CONFIG word. Have comment out the CONFIG word in the program. using MPASM assembler. Now I'm really confused. Have been lucky with my other programs for other Controllers, that I can see now.
Really wants to find out how to configure CONFIG word for 16F886.
;************************************************* ***************
;* 16F886.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 05/26/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
device pic16F886, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F886, r = dec, w = -302
INCLUDE "P16F886.INC" ; MPASM Header
__config _CONFIG1, _INTOSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
NOLIST
endif
LIST
I wants to have 8 MHz Internal Oscillator, my PCB have 4k7 resistor to MCLR pin so think MCLR have to be ON?
Also want ALL I/O to be DIGITAL.
Have printed out the INC file from the MPASM directory and the PDF file for 16F886 from MicroChip. Have much to read, but if I understand all???
What can I do to get it work?
Include a short version of the program.
All the Best
Bosse
skimask
- 8th September 2008, 16:51
Can not find out how to find out about the CONFIG word.
The config fuses are explained in the 16F886 datasheet in the 'Special Features of the CPU' section.
Have comment out the CONFIG word in the program. using MPASM assembler.
If you comment them out in the 16F886.INC file in the PBP folder, you need to put them in your main program.
If you don't put them in your main program, you can temporarily/permanently set them in the 16F886.INC file in the PBP folder.
Really wants to find out how to configure CONFIG word for 16F886.
And again...if you read, and re-read, and re-read, and heed, this thread:
http://www.picbasic.co.uk/forum/showthread.php?t=543&highlight=presetting
You will understand what needs to go where...
Get the list of available/recognized config fuses settings from the 16F886.INC file in the MPASM folder...just like the thread says to do...
;************************************************* ***************
;* 16F886.INC *
;* *
;* By : Leonard Zerman, Jeff Schmoyer *
;* Notice : Copyright (c) 2006 microEngineering Labs, Inc. *
;* All Rights Reserved *
;* Date : 05/26/06 *
;* Version : 2.47 *
;* Notes : *
;************************************************* ***************
NOLIST
ifdef PM_USED
LIST
include 'M16F88x.INC' ; PM header
device pic16F886, xt_osc, wdt_on, mclr_on, lvp_off, protect_off
XALL
NOLIST
else
LIST
LIST p = 16F886, r = dec, w = -302
INCLUDE "P16F886.INC" ; MPASM Header
__config _CONFIG1, _INTOSC & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
If you're going to put the config fuses in your program, comment out the above line
If you're going to make the config fuses temporarily/permanent, change the above line to what you need using the available settings in the 16F886.INC in the MPASM folder
NOLIST
endif
LIST
Bosse
- 8th September 2008, 19:54
Hi skimask,
Thank you very much for all your help, now I will change the config in the INC file.
Wish you all the best
Bosse
Archangel
- 8th September 2008, 19:57
HI BOSSE,
Time to ask, what is / is not working? Your file compiles nicely here, only changes I see are as follows: add, OSCTUNE = %00000000 ' SET OSC TO CALIBRATED VALUE
VRCON = 0 and change to OSCCON = %01110101 , these may in fact do nothing differently, but I would try them. Does your circuit come alive and do anything ? Have you tried adding a heartbeat code just so you can see if life exists? Simple LED works wonders.
Archangel
- 8th September 2008, 20:02
Hi skimask,
Thank you very much for all your help, now I will change the config in the INC file.
Wish you all the best
Bosse
Ya Know, I would only add an <b><font color=red> ; </b></font color> there. What I would do is save the configs you want saved as a file, call it 16F886 Setup and open it for each new project, then when you get ready to compile just save it as your new project's name: MyNewProject.BAS
Bosse
- 9th September 2008, 00:14
Hi Joe,
Thank you for your help. Was working yesterday to 06.30 in the morning, so today I have not tried out the new settings. Will do it tomorrow and belive it will work now. Have tried with LEDs and sometimes 2 LEDs lights when only one should. Will send you info about my progress tomorrow.
Many thanks again ALL of you
Bosse
Bosse
- 9th September 2008, 15:53
Hi everybody - especially you how have helped me, MANY THANKS!!
Now it is running nice - still a warning from PicKit2 - Configuration 23EC 0700
But can not see any problem when program runs - have hardtested all functions and NO problem to see.
All the Best to you all
Bosse
skimask
- 9th September 2008, 18:44
Now it is running nice - still a warning from PicKit2 - Configuration 23EC 0700
I think, but I'm not sure...
The datasheet says that the upper 2 bits of the CONFIG1 register should read as 1's (even though they're not used), and the same thing for most of CONFIG2.
This leads me to believe that your config word should be $E3ECFFFF when read back off the chip.
Have you got the latest versions of MPLAB, PICKIT2 firmware and software loaded up?
Bosse
- 9th September 2008, 19:12
Hi,
Yes, have MPLAB Ver. 8.00.00.00 and updated PicKit2
Shall read bak and see
skimask
- 9th September 2008, 19:18
Hi,
Yes, have MPLAB Ver. 8.00.00.00 and updated PicKit2
Shall read bak and see
MPLAB is up to 8.14.
PicKit2...check the website for the latest.
Bosse
- 9th September 2008, 20:17
Hi again skimask,
This is my configuration now, will move it to the INC file when there is no warnings.
@ __CONFIG _CONFIG1, _INTOSCIO & _WDT_ON & _PWRTE_ON &_MCLRE_ON & _LVP_OFF & _CPD_OFF & _FCMEN_OFF & _IESO_OFF
Define OSC 8 ' Set Xtal Frequency
OSCCON = %01110001 ' Internal 8 mhz Osc
ANSEL = 0 ' All Digital
ANSELH = 0
CM1CON0 = 0 ' Think ? don't need
CM2CON0 = 0 ' Think ? don't need
ADCON0 = 0
ADCON1 = $0F ' Think ? don't need
Have to try change bit by bit until no warnings from PicKit2
skimask
- 9th September 2008, 20:27
@ __CONFIG _CONFIG1, _INTOSCIO & _WDT_ON & _PWRTE_ON &_MCLRE_ON & _LVP_OFF & _CPD_OFF & _FCMEN_OFF & _IESO_OFF
Anything below this line isn't going to have an effect on your CONFIG fuses.
They are 2 separate entities...
And when I said read back, I meant the actual config word data as read back using the PICKIT2, not the data you are trying to push out to the PIC using the programmer.
EDIT: Just checked your CONFIG against the '886/887 datasheet. When reading back the PIC after programming the config word, you should readback $E3ECFFFF, if it's actually being programmed to those values.
Bosse
- 9th September 2008, 23:04
Have Updated MPLAB to 8.14 and PicKit to 2.52
Reading back 23EC 3FFF
skimask
- 10th September 2008, 00:38
Have Updated MPLAB to 8.14 and PicKit to 2.52
Reading back 23EC 3FFF
If I had an '886, I'd try it to see what I get.
Oh...wait...I've got the demo board with an '887 on it.
When I get a chance, I'll see what it reads...
Bosse
- 10th September 2008, 01:09
Will be very greatful for your help, can see that 16F887 have exact the same CONFIG words.
Have used 16F876A before without problems, but they dont have internal oscillator.
skimask
- 10th September 2008, 01:11
Do you have the actual PICKIT2 or a knockoff?
Bosse
- 10th September 2008, 01:13
From Microchip, 3 months old
skimask
- 10th September 2008, 01:14
From Microchip, 3 months old
Forgot to add...did you get the demo version with the demo board with the '887 (or maybe '917) on it?
Bosse
- 10th September 2008, 01:21
Have 2 demo board - one with 16F688 and one with 16F887
Clock is now 02.30 in the morning here in Norway, so have to go to sleep
skimask
- 10th September 2008, 02:20
Have 2 demo board - one with 16F688 and one with 16F887
Clock is now 02.30 in the morning here in Norway, so have to go to sleep
Hook the PICKIT2 directly to those boards, set up a program to change the CONFIG fuse values, program them, read them back, see what happens.
Bosse
- 10th September 2008, 11:46
Hi everybody,
Now I have the CONFIG word without warnings - tested with the demo board 887
@ __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
@ __CONFIG _CONFIG2, _WRT_OFF & _BOR21V
Config from read back: 20E4 0600
Thanks again for all your help
skimask
- 10th September 2008, 13:50
Hi everybody,
Now I have the CONFIG word without warnings - tested with the demo board 887
@ __CONFIG _CONFIG1, _LVP_OFF & _FCMEN_OFF & _IESO_OFF & _BOR_OFF & _CPD_OFF & _CP_OFF & _MCLRE_ON & _PWRTE_ON & _WDT_OFF & _INTRC_OSC_NOCLKOUT
@ __CONFIG _CONFIG2, _WRT_OFF & _BOR21V
Config from read back: 20E4 0600
Thanks again for all your help
Any idea which config item in particular was causing the problem?
Bosse
- 12th September 2008, 07:06
Will check and come back - have study exampel files from Microchip where I found some CONFIG words.
skimask
- 12th September 2008, 07:28
Will check and come back - have study exampel files from Microchip where I found some CONFIG words.
Just remove the CONFIG items one by one until the problem goes away...
Bosse
- 20th September 2008, 22:46
Hi Skimask,
First thank you for your earlier info
Can you tell me how to find out wich configuration I have - how to calculate or find out in another way.
My code runs with internal OSC 8 MHz (I hope) but after leaving the PCB for some hours, it need time to start normal. Reading DS1990A and first time touching the probe nothing happens, second time all O.K - after about 10 sec all works normal and it also works if you touch direct after each other - touching of course allways with different DS1990A and after each reading the variable holding the code resets.
Config word: 20E4 0600
skimask
- 20th September 2008, 22:55
Hi Skimask,
First thank you for your earlier info
Can you tell me how to find out wich configuration I have - how to calculate or find out in another way.
You've already been given all the information you need during the course of this thread to figure that out for yourself. Go back and read and re-read and re-read and repeat...
My code runs with internal OSC 8 MHz (I hope) but after leaving the PCB for some hours, it need time to start normal. Reading DS1990A and first time touching the probe nothing happens, second time all O.K - after about 10 sec all works normal and it also works if you touch direct after each other - touching of course allways with different DS1990A and after each reading the variable holding the code resets.
Rephrase the sentences above. They aren't making a lot of sense to me...might to somebody else, but the grammar just isn't quite working out...
The way I read it...The program runs, then it stops, then you touch something, it runs, restart it, doesn't want to restart, but will after a few seconds, then the code resets?
Bosse
- 20th September 2008, 23:12
Have a code how runs nice on a F88 - thats why I think something is wrong with configuration word for the F886. It seems that I need to touch the probe 2-3 times or reading in more than one time before it reads correct. After one good reading all works, looks that it stops up and needs to wake up before it works????
skimask
- 21st September 2008, 06:18
Have a code how runs nice on a F88 - thats why I think something is wrong with configuration word for the F886. It seems that I need to touch the probe 2-3 times or reading in more than one time before it reads correct. After one good reading all works, looks that it stops up and needs to wake up before it works????
Since an F88 is an 18 pin device and an F886 is a 28 pin device, it sounds to me like you've got a hardware problem, a grounding problem most likely since you have to actually touch (ground) the device to get it to work for you.
What are you building this circuitry on?
Bosse
- 21st September 2008, 18:24
Have ordered some PCB's for prototype testing from PCBCart China - have checked if there is any grounding problem and all looks O.K. Have now changed the code so all variables are reset in the beginning of the code and used the same code from F88 except CONFIGURATION word and now it runs nice. Will test same days then I know for sure.
Thanks again from an old Swede trying to learn
kolega35
- 29th December 2013, 20:02
Hi! 16f886 to write to the configuration settings of the pbp?
Demon
- 30th December 2013, 00:59
Hi! 16f886 to write to the configuration settings of the pbp?
Hi, which PBP version are you using, and which assembler are you trying to use with that, PM or MPASM?
Robert
kolega35
- 31st December 2013, 15:19
Hi! I am using Microcode Studio version 4.0.0.0 . pbp version is 2.47 . Thanks.
Demon
- 31st December 2013, 16:20
Which Assembler, PM or MPASM?
Robert
kolega35
- 1st January 2014, 01:57
PM Assembler.
Archangel
- 1st January 2014, 18:53
Your answer is likely in this thread: http://www.picbasic.co.uk/forum/showthread.php?t=543
kolega35
- 2nd January 2014, 06:24
I will reading this thread. Thanks.
Powered by vBulletin® Version 4.1.7 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.