• AVR Freaks

Hot!Having problems with code not working when pic chip programed

Page: 12 > Showing page 1 of 2
Author
Picmad
New Member
  • Total Posts : 20
  • Reward points : 0
  • Joined: 2018/01/24 23:52:28
  • Location: 0
  • Status: offline
2019/06/11 05:47:44 (permalink)
0

Having problems with code not working when pic chip programed

Having problems with code not working when pic chip programed pic16f886
I have programing it with some code just making port pins out outputs on high I know has worked in with pic chip  16f690 and it works but not in pic16f886 it programmes ok no errors when programing I have tried changing config bit and also added crystal  not made any difference can any body help or is the chip broke ?
bought chip off somebody on ebay supposed to be new .
#1

25 Replies Related Threads

    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 09:11:02 (permalink)
    0
    this is the code
     
    #define _LEGACY_HEADERS
    #include <htc.h>
     
    unsigned int counter;
    main()
    {
     ANSEL = 0;
     ANSELH = 0;
        CM1CON0 = 0; //Comparators Shut off
     CM2CON0 = 0;
     INTCON=0; // purpose of disabling the interrupts
     //PORTB = 0x00;
     TRISB = 0x00;
     PORTB = 0xFF;  // added this line to test port output
    while(1==1)     //loop forever
    {
     //PORTC = 0b00000000;
     //RB0 = 1;           // Turn on RC0 LED
     counter = 65535;  // Preset counter to 65535
      do
      { 
      counter = counter - 1; // Decrement count by one
      } 
      while (counter > 0);  // Loop until counter = 0 for delay time
     //PORTC = 0b00000001;
       //RB0 = 0;          // Turn off RC0 LED
     counter = 65535;  // Preset counter to 65535
      do
      { 
      counter = counter - 1; // Decrement count by one
      }
      while (counter > 0);  // Loop until counter = 0 for delay time
    } //End while
    } //end main
    #2
    NKurzman
    A Guy on the Net
    • Total Posts : 17361
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 10:15:22 (permalink)
    0
    Are you Configuration Bits correct?
    #3
    davea
    Senior Member
    • Total Posts : 121
    • Reward points : 0
    • Joined: 2016/01/28 13:12:13
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 10:33:44 (permalink)
    0
    CONFIG1: CONFIGURATION WORD REGISTER 1
    look at datasheet
    #4
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 10:43:39 (permalink)
    0
    ive just added this line of code didn't change
    __CONFIG (HS & WDTDIS & MCLREN & UNPROTECT & LVPDIS & IESODIS & FCMDIS);
     
     
     
     
     
    using mplab ide 8.92
    hitech c complier 9.82
    #5
    NKurzman
    A Guy on the Net
    • Total Posts : 17361
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 11:20:06 (permalink)
    0
    What frequency is your crystal? Are it’s capacitors the correct value?
    #6
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 11:37:47 (permalink)
    0
    16mhz crystal and 20pf capacitors which I've taken from circuit diagram out of a book called beginners guide to embedded c programing volume 3
     
    #7
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 11:41:13 (permalink)
    0
    Try this config1 word:
    __CONFIG (INTOSC & WDTDIS & MCLREN & UNPROTECT & LVPDIS & IESODIS & FCMDIS);
    #8
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 11:44:36 (permalink)
    0
    build failed
     
    HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode)  V9.82
    Copyright (C) 2011 Microchip Technology Inc.
    (1273) Omniscient Code Generation not available in Lite mode (warning)
    Error   [800] Proj1.as; 45. undefined symbol "INTOSC"
    ********** Build failed! **********
    #9
    jack@kksound
    code tags!
    • Total Posts : 3188
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 11:52:28 (permalink)
    +1 (1)
    INTOSC is probably not the correct spelling. try INTRC_CLKOUT instead.
    #10
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 14:17:42 (permalink)
    0
    I've tried it didn't compile either will do a search on internet see what other config wordings I can find thanks for your help
    #11
    NKurzman
    A Guy on the Net
    • Total Posts : 17361
    • Reward points : 0
    • Joined: 2008/01/16 19:33:48
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 14:28:13 (permalink)
    +2 (2)
    Search in the Compiler Folder for the header file for you PIC.  The Config bits should be defined there.
    #12
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 14:41:08 (permalink)
    0
    I used mplabx and used the config bit tool then  complied it and it failed but removed the line
     
    #define _LEGACY_HEADERS
    and it complied but still does work in chip ?
     
     
    __CONFIG(FOSC_INTRC_CLKOUT & WDTE_OFF & PWRTE_OFF & MCLRE_ON & CP_OFF & CPD_OFF & BOREN_ON & IESO_ON & FCMEN_ON & LVP_ON);
    __CONFIG(BOR4V_BOR40V & WRT_OFF);
     
     
     
    HI-TECH C Compiler for PIC10/12/16 MCUs (Lite Mode)  V9.82
    Copyright (C) 2011 Microchip Technology Inc.
    (1273) Omniscient Code Generation not available in Lite mode (warning)
    Memory Summary:
        Program space        used    45h (    69) of  2000h words   (  0.8%)
        Data space           used     4h (     4) of   170h bytes   (  1.1%)
        EEPROM space         used     0h (     0) of   100h bytes   (  0.0%)
        Configuration bits   used     2h (     2) of     2h words   (100.0%)
        ID Location space    used     0h (     0) of     4h bytes   (  0.0%)

    Running this compiler in PRO mode, with Omniscient Code Generation enabled,
    produces code which is typically 40% smaller than in Lite mode.
    See http://microchip.htsoft.com/portal/pic_pro for more information.
    Loaded E:\Mchipandstuff\MyProjects\16F\16f886\cbook3files\Chapter4\Proj1\Proj1.cof.
    ********** Build successful! **********
     
    #13
    ric
    Super Member
    • Total Posts : 22361
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 15:24:09 (permalink)
    +1 (1)
    Don't use "LVP_ON", change that to "LVP_OFF".
    When it is on, you MUST tie the RB3/PGM pin high low, or the chip will spontaneously fall into programming mode if that pin is floating.
    post edited by ric - 2019/06/11 17:48:42

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #14
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 15:29:22 (permalink)
    0
    I have just tried it still no work ,I want to say it also makes the led I have connected to pin 11 on 16f886 flicker when I program the chip
    #15
    1and0
    Access is Denied
    • Total Posts : 9252
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/11 17:44:26 (permalink)
    +1 (1)
    Pin number without the package is useless. ;)  Best to specify the pin by its name, such as RC0 pin.
     
    Is the MCLR pin pulled up to Vdd?
    Are the LEDs connected correctly to the PIC?
     
     
    #16
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/11 19:46:50 (permalink)
    +1 (1)
    Picmad
    16mhz crystal and 20pf capacitors which I've taken from circuit diagram out of a book called beginners guide to embedded c programing volume 3 

    How are these connected?

    For example:
    a) Soldered to a PCB right next to the chip?
    Or
    b) On a breadboard with 6 inch long flying leads connecting everything?

    Here is a well connected breadboard and crystal. All wires kept as short as absolutely possible. (Although the micro could have done with a decoupling cap on the power supply pins).

    And here is an example (although not the worst I have seen, it’s still fairly bad) of how NOT to do it.
    #17
    Picmad
    New Member
    • Total Posts : 20
    • Reward points : 0
    • Joined: 2018/01/24 23:52:28
    • Location: 0
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/12 02:52:21 (permalink)
    0
    the chip is in a socket on a pcb and the led is only an inch away from the port RC0
    #18
    pcbbc
    Super Member
    • Total Posts : 1011
    • Reward points : 0
    • Joined: 2014/03/27 07:04:41
    • Location: 0
    • Status: online
    Re: Having problems with code not working when pic chip programed 2019/06/12 04:56:02 (permalink)
    +1 (1)
    Picmad
    the chip is in a socket on a pcb and the led is only an inch away from the port RC0

    But where is the crystal?  Also on the PCB?  Or somewhere else?
    Only the other month we had someone with chip on a PCB and crystal on a breadboard 20cm away connected with Dupont leads!
    #19
    1and0
    Access is Denied
    • Total Posts : 9252
    • Reward points : 0
    • Joined: 2007/05/06 12:03:20
    • Location: Harry's Gray Matter
    • Status: offline
    Re: Having problems with code not working when pic chip programed 2019/06/12 05:32:21 (permalink)
    +1 (1)
    Picmad
    the chip is in a socket on a pcb and the led is only an inch away from the port RC0

    Ignoring the other questions is not going to help you faster.
    #20
    Page: 12 > Showing page 1 of 2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5