Cant get my PIC running


Closed Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Aug 2008
    Posts
    13

    Default Cant get my PIC running

    Hello,

    I have problem with my new PIC 16f877 controller. I was searching answer to the problem with google and found this site with very friendly people on it so i decided to ask help here even the problem is not picbasic relative. However im going to use picbasic after this problem is fixed.

    Backround:
    Im totally new to microcontrollers and there migth be something obvious that i have missed, so easy suggestions are important too. I have bougth PIC 16f877 controller and made circuit for it. As programmer i use a LVP circuit that seems to work as i can tell: writing a program to it result no errors and when reading the controllers memory, i can see changes in the hex file downloaded.

    Problem:
    As the programming seems to work, next thing i have tried to do is to see if there is some life when i turn power on. For this, i have programmed a assembler program to put a voltage to a pin to measure it with voltage meter or to see connected LED to ligth up.
    (MPLAB)
    LIST p=16f877
    INCLUDE "p16f877.inc"

    __CONFIG _PWRTE_ON & _HS_OSC & _WDT_OFF & _BODEN_OFF

    ORG 0x00
    goto Main

    ORG 0x04
    goto Main

    Main
    BANKSEL TRISB
    bcf TRISB,5 ; i also have tried clrf TRISB without success
    BANKSEL PORTB
    bsf PORTB,5

    Loop NOP
    goto Loop

    end

    No voltage appears on the pin (tried some other pins too). Here is the circuit: http://kuvaton.com/k/Q8m.jpg edit: from RB3 there goes a wire to ground

    I have tested the circuit also with computer powersupply +5V and ground to points A and B in the link above with no success. When tried that, i disconnected stabilization capacitors and the ground pin in the regulator to avoid them to interference.

    I saw some circuits in the web where ceramic capacitors where used in some parts of the circuit. In my circuit all the capacitors are electrolyte capacitors, does this make a difference? Unfortunately i dont have any ceramic versions to test.

    I will be thankful for any suggestion.
    Last edited by Viberer; - 28th August 2008 at 00:32.

  2. #2
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Welcome,

    My assembly is really bad, but this might be the problem.
    Code:
    Loop NOP
    goto Loop
    I think it is stuck in a NOP loop.

    Try the PB demo
    http://www.melabs.com/pbpdemo.htm
    Dave
    Always wear safety glasses while programming.

  3. #3
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Thanks for reply, i tried it but it didnt work In some samples i have seen this kind of infinite loop being used, i dont know why it is there.

  4. #4
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    With LVP enabled you need to ground RB3 for normal operation. If this pin is left floating or
    high it thinks the PIC is in programming mode, and will not execute your code.

    Read section 12.17 in your data sheet and look at note 4 in the grey area.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  5. #5
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default Still not working

    Quote Originally Posted by Bruce View Post
    With LVP enabled you need to ground RB3 for normal operation. If this pin is left floating or
    high it thinks the PIC is in programming mode, and will not execute your code.

    Read section 12.17 in your data sheet and look at note 4 in the grey area.
    Oh yes, i remember reading that. I tried grounding it then and i forgot it when it didnt help. Now it is grounded again and will be that way but i got still no life from it Thanks for notification

    Im really starting to lose my mind with this chip

  6. #6
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    It can definitely be frustrating, but hang-in there...;O}

    Which device programmer are you using?

    Have you programmed another PIC succesfully with this programmer?

    Have you checked every single connection with a volt-meter?

    Have you tried another oscillator?

    A LOT of factors are involved. Even with a simple program like yours just
    making a pin high.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  7. #7
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Bruce View Post
    It can definitely be frustrating, but hang-in there...;O}
    Thanks

    The programmer is designed by engineers of a finnish IT magazine, which they released to the magazine and to the web. So it is not any common model. The program that uses the programmer is too written by them. http://www.mbnet.fi/nettijatkot/2002/03/rakentelu/

    first link under "Kopioitavat tiedostot" leads to circuit board model with EAGLE. The third is for Visual basic source code.

    In the program you can define only if watchdog is on, choose to verify written data and repair errors and choice of oscillator.

    This is first chip im trying to program and i have checked connections with multimeter.
    Unfortunately i dont have another oscillator.. and theres not oscilloscope to test it. One thing pops to my mind: the wires to oscillator are about 6cm long, could it be bad? As a poor student i have kind of home made breadboard and it is not too easy to solder close to the PIC.

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


    Did you find this post helpful? Yes | No

    Default

    Hi Viberer,
    I do not use LVP, I have a six dollar JDM clone from Bulgaria I bought on eBay, and I use ICPROG a freeware programming software. Recently I began programming 16F88 for the first time, and my programmer balked and complained and refused to verify the chips, of coarse I thought, darned sample chips, darned cheap programmer . . . What I found works is to power the PIC from a 5 volt supply while programming and viola' it programs fine.
    HTH
    JS
    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.

  9. #9
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    Try the attached HEX file. If it works your programmer is probably OK. If not, check everything else.

    Note this will blink an LED on RB0.
    Attached Files Attached Files
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

  10. #10
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    Hi Viberer,
    I do not use LVP, I have a six dollar JDM clone from Bulgaria I bought on eBay, and I use ICPROG a freeware programming software. Recently I began programming 16F88 for the first time, and my programmer balked and complained and refused to verify the chips, of coarse I thought, darned sample chips, darned cheap programmer . . . What I found works is to power the PIC from a 5 volt supply while programming and viola' it programs fine.
    HTH
    JS
    Oh, that is cheap! I ordered the components and circuit board separately and it cost about 25 euros. Im not really sure what you mean by "power the PIC from a 5 volt supply while programming" but this has to do something with not using LVP?


    Quote Originally Posted by Bruce View Post
    Try the attached HEX file. If it works your programmer is probably OK. If not, check everything else.

    Note this will blink an LED on RB0.
    I tried the code, it uploaded to the chip and program said it was successfull, like before. But that damn LED didnt ligth up and no sign of life there. Now i tried to read the memory from chip with programmer, it looks like this:

    :1000000000000000FF3FFF3FFF3F8F3FFF3FFF3FEC
    :10001000280EF23F060883169F00831206089F00F1
    :100020000608840087018801890106088600060801
    :1000300085000608650006088316870083120608F7
    :1000400083168800FF3FFF3FFF3FFF3FFF3FFF3F1B
    :10005000FF3F0800FF3FFF3FFF3FFF3FFF3FFF3FE6
    :10006000FF3F8312FF3FFF3FFF3FFF3FFF3FFF3F49
    :10007000FF3F0610FF3FFF3FFF3FFF3FFF3FFF3FB8
    :10008000FF3F2C28FF3FFF3F4028FF3FFF3FFF3F40
    :10009000FF3FFF3FFF3FFF3FFF3FFF3FFF3FFF3F70
    :1000A000FF3F0A12FF3FFF3FFF3FFF3FFF3FFF3F82
    :1000B000FF3F0A12FF3FFF3FFF3FFF3FFF3FFF3F72
    :1000C000FF3F2108FF3FFF3FFF3FFF3FFF3FFF3F55
    :1000D000FF3F0800000000000000000000000000DA
    :1000E0000000000000000000000000000000000010
    :1000F0000000000000000000000000000000000000
    :1001000000000000000000000000000000000000EF
    :1001100000000000000000000000000000000000DF
    :1001200000000000000000000000000000000000CF

    Theres a quite a few 3FF:s that seems suspicious. Here is the viberer.hex:

    :100000002828A301A200FF30A207031CA307031C9A
    :1000100023280330A100DF300F200328A101E83E90
    :10002000A000A109FC30031C1828A00703181528FC
    :10003000A0076400A10F152820181E28A01C222844
    :1000400000002228080083130313831264000800B1
    :100050008601831686018312061483160610831206
    :100060000330A300E8308A01022006108316061030
    :1000700083120330A300E8308A0102208A012C2871
    :0600800063008A01402824
    :02400E00F23F7F
    :00000001FF

    I assume that the codes are not supposed to be clone of each other, but can you say from this if it is corrupted?

    Another assume i made is that if i upload a longer program to the chip and then a shorter one, part of the longer program still remains in the memory but this is not issue since the new shorter code has its end coded or a infinite loop at the end. Is this rigth?

    I assumed this becouse there are no option to empty the memory in the program. If i want to "clear the memory" is it ok to program this kind of .hex to the chip:

    :1000000000000000000000000000000000000000F0
    :1000100000000000000000000000000000000000E0
    :1000200000000000000000000000000000000000D0
    :1000300000000000000000000000000000000000C0
    :1000400000000000000000000000000000000000B0
    :1000500000000000000000000000000000000000A0
    :100060000000000000000000000000000000000090
    :100070000000000000000000000000000000000080
    :100080000000000000000000000000000000000070
    :100090000000000000000000000000000000000060
    :1000A0000000000000000000000000000000000050
    :1000B0000000000000000000000000000000000040
    :1000C0000000000000000000000000000000000030
    :1000D0000000000000000000000000000000000020
    :1000E0000000000000000000000000000000000010
    :1000F0000000000000000000000000000000000000
    :1001000000000000000000000000000000000000EF
    :1001100000000000000000000000000000000000DF
    :1001200000000000000000000000000000000000CF
    :1001300000000000000000000000000000000000BF
    :1001400000000000000000000000000000000000AF
    :10015000000000000000000000000000000000009F
    :10016000000000000000000000000000000000008F
    :10017000000000000000000000000000000000007F
    :10018000000000000000000000000000000000006F
    :10019000000000000000000000000000000000005F
    :1001A000000000000000000000000000000000004F
    ................ and so?

  11. #11
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    Another assume i made is that if i upload a longer program to the chip and then a shorter one, part of the longer program still remains in the memory but this is not issue since the new shorter code has its end coded or a infinite loop at the end. Is this rigth?

    I assumed this becouse there are no option to empty the memory in the program.
    I am not sure if it will cause a problem, but I think it will if the chip is not erased.

    In MPLAB on the toolbar, configure, settingins, and the the Program Loading tab. Clear everything.
    Dave
    Always wear safety glasses while programming.

  12. #12
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    I am not sure if it will cause a problem, but I think it will if the chip is not erased.

    In MPLAB on the toolbar, configure, settingins, and the the Program Loading tab. Clear everything.
    Oh, but there is only one problem: My programmer is not a standard model and mplab doesnt support it :/ , so im unfortunately not able to do it that way

  13. #13
    Join Date
    Nov 2003
    Location
    Wellton, U.S.A.
    Posts
    5,924


    Did you find this post helpful? Yes | No

    Default

    OOPS, I thought you were using MPLAB.
    Now I read closer and see the link you provided. The link does not work.

    A hex from a blank chip will have FFFFFFF not 0000000 as you example.

    And you might try ICPROG for the program to load the chip. It might work with your programmer (it works with several)and I think it has an erase feature.
    Dave
    Always wear safety glasses while programming.

  14. #14
    Join Date
    Aug 2008
    Posts
    13


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mackrackit View Post
    OOPS, I thought you were using MPLAB.
    Now I read closer and see the link you provided. The link does not work.

    A hex from a blank chip will have FFFFFFF not 0000000 as you example.

    And you might try ICPROG for the program to load the chip. It might work with your programmer (it works with several)and I think it has an erase feature.
    Strange, it works for me :S

    When i read the chip, i will get 00000 not FFFFF, there is possibility that programmer or program converts the bits? sounds wierd, are you sure about this? And after writing program and reading I will get hex like this:
    :1000000000000000FF3FFF3FFF3F8F3FFF3FFF3FEC
    :10001000280EF23F060883169F00831206089F00F1
    :100020000608840087018801890106088600060801
    :1000300085000608650006088316870083120608F7
    :1000400083168800FF3FFF3FFF3FFF3FFF3FFF3F1B
    :10005000FF3F0800FF3FFF3FFF3FFF3FFF3FFF3FE6
    :10006000FF3F8312FF3FFF3FFF3FFF3FFF3FFF3F49
    :10007000FF3F0610FF3FFF3FFF3FFF3FFF3FFF3FB8
    :10008000FF3F2C28FF3FFF3F4028FF3FFF3FFF3F40
    :10009000FF3FFF3FFF3FFF3FFF3FFF3FFF3FFF3F70
    :1000A000FF3F0A12FF3FFF3FFF3FFF3FFF3FFF3F82
    :1000B000FF3F0A12FF3FFF3FFF3FFF3FFF3FFF3F72
    :1000C000FF3F2108FF3FFF3FFF3FFF3FFF3FFF3F55
    :1000D000FF3F0800000000000000000000000000DA
    :1000E0000000000000000000000000000000000010
    :1000F0000000000000000000000000000000000000
    :1001000000000000000000000000000000000000EF
    :1001100000000000000000000000000000000000DF
    :1001200000000000000000000000000000000000CF

    as i earlier said. the remaining space is filled with zeros like those in the last lines above, is this normal? Should those zeros be F's too?


    ICPROG unfortunately doesnt work with my programmer, however i found out that writing a new code to the chip "automaticly" erases the old one, so that should not be problem then.
    Last edited by Viberer; - 29th August 2008 at 20:13.

Similar Threads

  1. pic first build test board not running
    By comwarrior in forum Schematics
    Replies: 11
    Last Post: - 29th June 2009, 16:48
  2. pic to pic ir link versus wired link : help please anyone
    By xnihilo in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 30th May 2008, 21:01
  3. Crystal osc running but PIC not using it
    By p15218 in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 18th February 2007, 22:33
  4. Pic 16f628a running at lower than 4.5V
    By MegaADY in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th April 2005, 18:40
  5. Serial Pic to Pic using HSER
    By Chadhammer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 11th March 2005, 23:14

Members who have read this thread : 0

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