Re: PIC16F886 not running.
Let us see what you have got, and we will help YOU make it work.
read data sheet re:ANSEL ANSELH ADCON0 ADCON1
PICs typically default to analog ports and YOU MUST tell them to do digital.
Re: PIC16F886 not running.
Im not very good at pics yet, but im learning :)
This is what I have. I just want the PIC to light up. I have the LED connected to PORTB.0
I have tried a lot of different examples, but none works.
__________________________________________________ _
TRISB = %11111111
TRISC = %00000000
ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
PORTB = 1
main:
portb=1
pause 100
goto main
__________________________________________________ ___
This works in GCB, but I think that compiler does a lot in the background for me.
Re: PIC16F886 not running.
Updated code
TRISB = %00000000
ADCON0 = %00000000
ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
PORTB = 1
main:
portb=1
pause 100
goto main
Re: PIC16F886 not running.
To make it blink you have to turn it off too
PortB.0 = 0
pause 100
Do you have a config statement.
Don't forget to tell PBP whay Oscillator speed.
DEFINE OSC 4
I have not studied this chip but it has OSCON registers and OSCTUNE registers.
Try OSCCON = %01100000 sets oscon to 4mhz (default)
Re: PIC16F886 not running.
Um........That wouldn't blink the led (which is on PB0?) it would just turn it on permanently.
Your main should be something like...
main:
portb.0 = 1
pause 100
portb.0 = 0
pause 100
goto main
Could also be
main:
portb = 0
pause 100
portb = 1
pause 100
goto main
Hope this helps.
About time I offered some help, instead of just asking for help, for a change.
Re: PIC16F886 not running.
Hi, Peter
Have a Happy new Year !
we also could write it :
Code:
PORTB = 0
TRISB = %00000000
ADCON0 = %00000000
ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
WHILE 1
TOGGLE PortB.0
pause 300 ' just to see something ...
WEND
END
Note PBP+ chip defaults are not shown here ... but [no]don't[/no] NEVER forget they exist !!!
Re: PIC16F886 not running.
Hi everybody and thanks for all the input.
Youre right, it wont blink. I just want to get the LED light up so I see that something is happening. For now, nothing works and no LED lights up. I have connected LEDs to all PORTB, so I can see if anything is going on on the chip.
I have tried all of your suggestions here but still dont work.
I thougt that the CONFIG was in the INC-file in PBP? Do I have to write something in code to make it start?
Re: PIC16F886 not running.
a little scheme ( the real one ... ) would be useful now ... especially for the RESET pin ...
1 Attachment(s)
Re: PIC16F886 not running.
I did a schematic in PCB express and this is exactly how its connected. I just want some LED to light up.
This one works perfect then I use GCB and PICPgm to program the chip. I use PICPgm to program it now too.Attachment 7667
Updated the code to use some LEDS on PORTC too, but no luck...
DEFINE OSC 4
OSCCON = %01100000
PORTB = 0
PORTC = 1
TRISB = %00000000
TRISC = %00000000
ADCON0 = %00000000
ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
WHILE 1
TOGGLE PortB.0
toggle portc.0
toggle portc.1
pause 300 ' just to see something ...
WEND
END
Re: PIC16F886 not running.
Re: PIC16F886 not running.
default pbp3 fuse config
Quote:
__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
yet you have no pull up resistor on mclre_pin (1)
no vss on pin 8
no current limiting resistors for leds ( will cause rmw issues)
what is that unspecified thing between portb7 and mclre ?
Re: PIC16F886 not running.
LilleJung,
PLEASE ....
open your Datasheet and begin by the supply circuit, then the Reset (MCLR) wiring ... one more trail from those, and your '886 is fried ...
Alain
PS:@ Skimask: ... the well known guy ???
Re: PIC16F886 not running.
Quote:
Originally Posted by
Acetronics2
PS:@ Skimask: ... the well known guy ???
http://www.picbasic.co.uk/forum/show...436#post130436
Re: PIC16F886 not running.
YEAH!!!, almost.....
The config statement helped a bit, now the LEDs on PORTC blinks. But nothing on PORTB.
I set MCLRE_OFF instead of MCLRE_ON and now I even can have the programmer connected and the chip works.
I have a pull-up resistor on MCLR also, but it works without it too. And current limiting resistors on the LEDs.
Now all I want is to get PORB to blink, then im up and running. I really want to migrate to PBP. GCB was great, but a little too many bugs for me.
PORTB.6 and PROB.7 is always connected to the programmer circuit (a homemade AN589 programmer).
The thing is that when I used the original circuit and wrote the code in GCB, everything worked...
New code...
_______________________________________
#config
__config _CONFIG1, _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_ON & _LVP_OFF & _CP_OFF
#endconfig
DEFINE OSC 4
OSCCON = %01100001
PORTB = 0
PORTC = 1
TRISB = %00000000
TRISC = %00000000
ADCON0 = %00000000
ANSEL = %00000000 ' Make AN0-AN7 digital
ANSELH= %00000000 ' Make AN8-AN13 digital
WHILE 1
TOGGLE PortB.0
toggle portc.0
toggle portc.1
pause 300 ' just to see something ...
WEND
END
_____________________________
Re: PIC16F886 not running.
Your schematic also is not showing a connection between the programmer and negative power (Vss)
I imagine that should be the spare terminal on the program connector?
Which programmer are you using?
Re: PIC16F886 not running.
Quit using TOGGLE. It's a R/M/W instruction. Set it high, pause, set it low, pause, loop.
Re: PIC16F886 not running.
Suggest reading the first few chapters of PBP manual.
Robert
Re: PIC16F886 not running.
The circuit works. If i do the same thing in GCB, I have no problem. Its just to get PBP to do the same thing. But the config solved most of it. just a few things left, like make the analog to digitla outputs. But I hope to solve that tonight.
Im using a AN589 programmer, and its works great with code from GCB.
I did read the first chapters, but I just couldnt get the PIC started.
Somehow the portb is solved too. I changed PortB to portb, programmed it, and now, for some undefined reason. it works....
After that, I can use PortB (with caps) again and it works!!!
Dont know why, dont care for the moment, im up and running...
Thank you all for all the help.
Ill be back if something else wont work for me.. :-)
Re: PIC16F886 not running.
Search the forum for ALLDIGITAL. It will help you determine what you need to make all pins digital.
Robert