PIC16F886 not running.


Closed Thread
Results 1 to 20 of 20
  1. #1
    Join Date
    Jan 2015
    Posts
    9

    Default PIC16F886 not running.

    Hello everybody.
    I need help. I just cant get a simple blink-program to work with picbasic pro. I have tried the same (almost) program in GCB, and the chip works.
    No problem when I compile.
    Is there any kind soul out there who can help me getting started with PBP3, so I can blink the d***m LED??

  2. #2
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default 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.
    Last edited by Archangel; - 4th January 2015 at 19:30.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  3. #3
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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.

  4. #4
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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
    Last edited by Lilleljung; - 4th January 2015 at 20:45.

  5. #5
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default 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)
    Last edited by Archangel; - 5th January 2015 at 00:57.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  6. #6
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    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.
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  7. #7
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default 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 !!!
    Last edited by Acetronics2; - 5th January 2015 at 18:58.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  8. #8
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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?

  9. #9
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    a little scheme ( the real one ... ) would be useful now ... especially for the RESET pin ...
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  10. #10
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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.Name:  scheme.jpg
Views: 588
Size:  103.4 KB

    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

  11. #11
    Join Date
    Dec 2014
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    Osccon = %01100001

  12. #12
    Join Date
    May 2013
    Location
    australia
    Posts
    2,386


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    default pbp3 fuse config
    __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 ?

  13. #13
    Join Date
    May 2004
    Location
    NW France
    Posts
    3,614


    Did you find this post helpful? Yes | No

    Default 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 ???
    Last edited by Acetronics2; - 6th January 2015 at 07:04.
    ************************************************** ***********************
    Why insist on using 32 Bits when you're not even able to deal with the first 8 ones ??? ehhhhhh ...
    ************************************************** ***********************
    IF there is the word "Problem" in your question ...
    certainly the answer is " RTFM " or " RTFDataSheet " !!!
    *****************************************

  14. #14
    Join Date
    May 2007
    Posts
    604


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    Quote Originally Posted by Acetronics2 View Post

    PS:@ Skimask: ... the well known guy ???
    http://www.picbasic.co.uk/forum/show...436#post130436
    Why pay for overpriced toys when you can have
    professional grade tools for FREE!!!

  15. #15
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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
    _____________________________
    Last edited by Lilleljung; - 6th January 2015 at 10:19.

  16. #16
    Join Date
    Jun 2005
    Location
    Up the bush, Western Plains, NSW Au
    Posts
    216


    Did you find this post helpful? Yes | No

    Default 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?
    Peter Moritz.
    Up the bush, Western Plains,
    New South Wales,
    Australia.

  17. #17
    Join Date
    Dec 2014
    Posts
    7


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    Quit using TOGGLE. It's a R/M/W instruction. Set it high, pause, set it low, pause, loop.

  18. #18
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    Suggest reading the first few chapters of PBP manual.

    Robert

  19. #19
    Join Date
    Jan 2015
    Posts
    9


    Did you find this post helpful? Yes | No

    Default 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.. :-)

  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,597


    Did you find this post helpful? Yes | No

    Default Re: PIC16F886 not running.

    Search the forum for ALLDIGITAL. It will help you determine what you need to make all pins digital.

    Robert

Similar Threads

  1. Replies: 8
    Last Post: - 28th January 2014, 14:21
  2. Config problem PIC16F886
    By Bosse in forum mel PIC BASIC Pro
    Replies: 55
    Last Post: - 2nd January 2014, 06:24
  3. pic16f886
    By NURULHAIZA in forum General
    Replies: 5
    Last Post: - 21st May 2010, 08:09
  4. PIC16F886 Register Settings
    By aherrera in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 29th July 2009, 17:52
  5. Pic16f886
    By Larry in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th October 2008, 22:40

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts