Maker Pro
Maker Pro

Pickit 2 - won't write.

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
 

Attachments

  • WP_20160316_20_39_44_Pro.jpg
    WP_20160316_20_39_44_Pro.jpg
    179.4 KB · Views: 127

BobK

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

Bob
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
The pic shows a blank program memory. Are you sure you successfully imported it?

Bob
Hi, Bob. Thanx for the speedy response. The pickit says hex import and then programming was succesfull.
 
Last edited by a moderator:

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
Hi, Bob. Thanx for the speedy response. The pickit says hex import and then programming was succesfull.
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.
 

Attachments

  • WP_20160321_10_43_51_Pro.jpg
    WP_20160321_10_43_51_Pro.jpg
    123.7 KB · Views: 74
  • WP_20160321_11_27_19_Pro.jpg
    WP_20160321_11_27_19_Pro.jpg
    177 KB · Views: 128
  • WP_20160321_11_27_42_Pro.jpg
    WP_20160321_11_27_42_Pro.jpg
    216.6 KB · Views: 89
Last edited:

Colin Mitchell

Aug 31, 2014
1,416
Joined
Aug 31, 2014
Messages
1,416
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.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
Hi, Voll
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.
Hi, Colin. Thanx for responding so soon. What i don't understand is that the code is loaded now but the circuit does nothing.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
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?
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
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
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
T
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
Thanks, Bob. Will check and get back to you.
 

max_torch

Feb 9, 2014
111
Joined
Feb 9, 2014
Messages
111
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.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
H
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.
I, Max. Will have to try out your advice tomorrow. Im doing nightshift. Thanks anyway for all youve done so far.
 

BobK

Jan 5, 2010
7,682
Joined
Jan 5, 2010
Messages
7,682
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
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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
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.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
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
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?
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
Hi
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.
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.
 

max_torch

Feb 9, 2014
111
Joined
Feb 9, 2014
Messages
111
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..
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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..
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.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
Hi, Max. Here is the code:
LIST p = 16F627
include "P16F627.inc"

cblock 0x20
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.
HI, Max. here is my code as promised. I'm trying to figure out where to insert the "return" command.
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..
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!!!
 

max_torch

Feb 9, 2014
111
Joined
Feb 9, 2014
Messages
111
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.
 

Devnode

Jul 13, 2015
94
Joined
Jul 13, 2015
Messages
94
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.
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
 
Top