Connect with us

Pickit 2 - won't write.

Discussion in 'Microcontrollers, Programming and IoT' started by Devnode, Mar 16, 2016.

Scroll to continue with content
  1. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, everyone. It's been quite some since i last posted. Im having a problem with writing to a 16f877a with pickit2. I tried to load a code from a previous project but it would not write. It did not erase the config bits from before so i performed a bulk erase. I imported the hex from mplab v8 and tried to write several times but in vain. I'll try to upload a picture of it for any help. Thanks in advance.
     

    Attached Files:

  2. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    The pic shows a blank program memory. Are you sure you successfully imported it?

    Bob
     
  3. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Bob. Thanx for the speedy response. The pickit says hex import and then programming was succesfull.
     
    Last edited by a moderator: Mar 17, 2016
  4. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Bob. I think may pics ( 877a & 628a ) may have been faulty. However, i tried a 627 and i says it programmed ok, even shows on the pickit window. When connect it on my breadboard it does simply nothing. Here is my circuit and photo of pickit output. Config bits are osc_intrc clkout, wdt_off, mclr_off, pwrte_on, boden_on, lvp_off, cp_off. Anything that i've fone wrong? Thankyou so much for your advice so far. Devnode. Ps. Mclr is not conncted to anything. I've the schematic wrong by showing its connected to Vss.
     

    Attached Files:

    Last edited: Mar 21, 2016
  5. Colin Mitchell

    Colin Mitchell

    1,416
    313
    Aug 31, 2014
    Sometimes the chips will not program.
    I have a second clone and it works with all those chips that fail to program with a PICkit-2

    That's why I use the clone all the time, now.
     
  6. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Voll
    Hi, Colin. Thanx for responding so soon. What i don't understand is that the code is loaded now but the circuit does nothing.
     
  7. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Colin. My leds are all on except for two outputs pin 3 (RA4, CMP2) and pin 4 (RA5, MCLR). I did disable comparators and mclr is disabled in my config bits. Any suggestions?
     
  8. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Your PIC is running just fine. You are blinking the LEDs at a rate way to fast to see them blink, thus they look like they are on all the time.

    The one connected to pin 4 will not work because the pin assigned to MCLR cannot be made an output. Not sure why the RA5 one is not working. Check the datasheet on initialization of PORTA, you might need to disable some other function. Or, it might be wired wrong, or bad LED or backwards LED. Check it with a multimeter. It should read about 1/2 Vdd if it is actually switching.

    Bob
     
  9. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    T
    Thanks, Bob. Will check and get back to you.
     
  10. max_torch

    max_torch

    111
    1
    Feb 9, 2014
    Try to simulate the circuit with the program loaded into a simulated microcontroller in the computer before doing it on an actual circuit. In the simulation, make sure that the proper clock speed is specified

    If you post the .asm file i can test it.
    Also, i noticed it that you are configuring the PIC manually rather than in-code.
    It is more reliable, especially when programming with the pickit2 or clones, to specify the configuration in code.
    You have to use the __CONFIG directive.
    Also, double check whether the way to configure CMCON for the 16F627 correct, since it can be different between models, this one of the down sides of porting between devices in assembly.
     
  11. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    H
    I, Max. Will have to try out your advice tomorrow. Im doing nightshift. Thanks anyway for all youve done so far.
     
  12. BobK

    BobK

    7,682
    1,688
    Jan 5, 2010
    Put a delay after turning the LEDs on and one after turning them off, about 1/4 second or so, and you will see them blink.

    Bob
     
  13. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Bob. I did check for a bad led or connection and found nothing wrong. Also i found that the pin isnt switching so i changed to port b and all my leds are on. THANKS MAN!! Before i insert that delay, im gonna have to take a nap, coming off nightshift. I'll let you guys know. Thanks again.
     
  14. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Bob. I did put that delay in the code and it simulated okay. However i get a " stack overflow error " message in mplab sim. Can i go ahead and load it or does is mean something is wrong?
     
  15. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi
    Hi, Max. I do simulate before i load the code but i do not note clock speed as such. Im still a newbie, mind you. As for the config bits, i tried the _config way but when i try to build i get an illegal opcode error message. So i have to remove the whole line and than just set it in the configure menu or the file export options after i try to import it to pickit. Im yet to learn some other way to do it.
     
  16. max_torch

    max_torch

    111
    1
    Feb 9, 2014
    You shouldnt go ahead if there is a stack overflow. It means that somewhere in the code you keep on executing calls but are not executing a return for each call. The 'stack' is actually the amount of calls you can stack before the pic forgets where the first one was supposed to return to. Probably the stack of pic16 is 7 calls. For a start, i'd suggest to make sure you do a return before you do any other calls, keep the stack at 1 or 2 only.
    Also, its okay that you feel you are a newbie, i commend you for learning this devnode. You soon wont feel like a noob.
    With regards to the __CONFIG way, follow this: http://ww1.microchip.com/downloads/en/DeviceDoc/PIC Config bit Format_Syntax_AndDefinitions.pdf
    make sure that its two underscores before the word config and not just one underscore, i made that mistake before..
     
  17. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Max. Thanks for the advice on the config bits.I 've downloaded the pdf and will learn it. I never even noticed the two underscores. Probably never would ve by myself. As for the calls, i have only two in the code, at least that i know of. I'll try to post the code later today for you to check if its okay with you. Thanks for your help so far. I appreciate it very much.
     
  18. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Max. Here is the code:
    LIST p = 16F627
    include "P16F627.inc"

    cblock 0x20
    HI, Max. here is my code as promised. I'm trying to figure out where to insert the "return" command.
    Hi, Max. Im sorry to report back only now. Ive had no chance to do so yesterday. I tried to upload my code but without success so i inserted the return command right after each of my two call instructions and it seems to work for there is no stack overflow error messages. Ive learned something from you that i never understood. Now all i im gonna do is load the code and see what happens. Let you know. Thankyou so much!!!
     
  19. max_torch

    max_torch

    111
    1
    Feb 9, 2014
    To provide your code, all you have to do is click the 'upload file' button, which is right beside the 'post reply' button here in this thread. Then look for the .asm file of your program and press OK.
     
  20. Devnode

    Devnode

    94
    7
    Jul 13, 2015
    Hi, Max.
    LIST p = 16F627
    include "P16F627.inc"

    cblock 0x20
    Delay:
    count1
    countA
    countB
    endc
    org 0x000
    movlw 0x07
    movwf CMCON

    bsf STATUS, RP0
    movlw b'00000000'
    movwf TRISB
    movwf TRISA
    bcf STATUS, RP0

    Loop
    movlw 0xff
    movwf PORTA
    movwf PORTB
    nop
    nop
    call Delay
    return
    movlw 0x00
    movwf PORTA
    movwf PORTB
    call Delay
    return
    goto Loop

    end

    Delay movlw d'250'
    movwf count1
    d1 movlw 0xc7
    movwf countA
    movlw0x01
    movwf countB
    Delay_0
    decfsz countA, f
    goto $+2
    decfsz countB, f
    goto Delay_0

    decfsz count1, f
    goto d1
    retlw 0x00

    end
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-