PIC18F628A serial programming help!!

Status
Not open for further replies.

mulaish

New Member
Hey,

I've implemented a serial programmer for the PIC17F628A via a xilinx CPLD and additional hardware. I am able to move about to various location in program memeory and configuration memory and my write/verify routines work fine. I can also read the device ID and rev # at address 0x2006 in the configuration memory.

The problem is that once I set the fuses Low voltage enabled, HS, MCLR enabled, Power up timer enabled, brown out detection disabled e.t.c, I am no longer able to access the device. It almost seems like I have put the device in some weird state. If I don't touch the configuration bit (I have a few of these pics to try thing sout on), then the program memory is flashed fine. And I am able to write and read to/from the device. The only issue is that the default value for the config word is all 1's, therefore the RC oscillator selection is chosen and I do not get any clock output on RA6 (code won't work). Even when I program the configuration word with the HS setting, I do not see any clock output on RA6. I am having problems using ICD 2 to program the device. Flacky behaviour (it was always working then all of a sudden stopped. Can't read the device ID.... expected 0x83 read 0x0).

I am really confused. I have a PIC that I flashed fine (with the same hex file) with ICD2 and I see the clock on RA6 via the scope. Problem is that LVP was disabled in this hex file and I can't read back all locations to see if there is something I am missing (and now ICD2 doesn't work anymore!!!!)

I notice that after programming the condfiguration word the output on Ra6 goes to about 3V from 1V (VDD is at 5). I am starting to think that the device is not comming out of reset? The device seems to be unresponsive after setting the Power Up Timer fuse??????

Any ideas............. Any help wold be greatly appreciated. Sorry for the lenghty post.
 
I think you are confusing matters as you refer to 18F628A, and 17F628A, and never to 16F628A (which is probably the chip you're talking about?).

But I would suggest that it's fairly obvious that you're doing something wrong!, designing and building, plus writing the software, for a PIC programmer isn't a trivial task. As it appears you are doing it in a very strange way (CPLD?), presumably you can't test it with other software?, so it's difficult to determine where you problems might lie.
 
mulaish said:
The problem is that once I set the fuses Low voltage enabled,....

When you enable the LV programming by changing the configuration memory, then you must either ground Pin10 RB4/PGM so that you can program the PIC using HV mode (like ICD2), or pull PGM high to Vdd and use the LV programming. You must never let this pin float.

You have not told us what you have done to this particular pin.
 
Sorry,

I'm using the 16F628A. Been at this a while and wrote that post later. The board that the PIC lies on has a CPLD that controls other IC's Muxes digital IO e.t.c. Through the CPLD I can toggle the state of the lines on ports A and B.


I am following the PRogram/Verify mode in the PIC16F627A/628A/648A EEPROM Memory Programming Specification doument from microchip. I'll raise PGM, then nMCLR to put the device in low voltage mode. This works as I can write to various address and read back the opcodes writen. If I do a load configuration command then I'll be in configuration memory, and can increment the PC to the Device ID and read the Device ID and rev #. 1 problem is that I do not see an output on RA6 after setting the HS setting on the configuration word.This line (RA6) just goes high when the device is powered. Any ideas what can cause this? Is the device not comming out of reset? Also, it seems that once I set the PUT fuse, I am not able to enter low voltage programming any more. Its almost like the configuration bits are not being written correctly, but I read back the corect value from addres 0x2007? The value I am writing ix 0x3FA2.

Oscillator HS
Watchdog OFF
PUT ON
BROWN OUT OFF
MASTER Clear ENABLED
LVP ENABLED
DATA EE read protect DISBALED
CODE PROTECT OFF


I am currently trying to get ICD to work again so that I can use high voltage programming to reset the all memory locations.
 
Do you have any special reason to enable LVP? I think LVP is useless (especially if you have ICD2) because it will dedicate one I/O pin for PGM function. Why don't you just disable LVP, it might solve your problem.
 
mulaish said:
1 problem is that I do not see an output on RA6 after setting the HS setting on the configuration word.This line (RA6) just goes high when the device is powered. Any ideas what can cause this?

HS is telling the PIC to use an external high speed crystal. What do you expect to come out RA6, clock pulses?

Why would you think that you can have clock pulses without a crystal?
 
To sum up:

HVP mode is always available! LVP can be disabled (by clearing LVP bit).

The only way to see any clock activity (without any external clock source) on RA6 is to run on INTOSC, HS mode (XT & LP as well) needs crystal to function!
 
"The only way to see any clock activity (without any external clock source) on RA6 is to run on INTOSC, HS mode (XT & LP as well) needs crystal to function!"

When I had HV prorgamming working I had set the ICD flag equal to true.
#Device ICD=TRUE

This causes compiled code to have configuratin word 0x3F02

I noticed that the HS fuse was selected so I tried to just mimick these settings but still enable LVP setting when doing LVP. The weird thing is that when I was able to HV program (with ICD=true) I saw oscilltor output on RA6, even though it seems by your stament that I shouldn't have????


I also had a question regarding HV programming. Currently it is not working, but If I scope the clock and data lines I see the load configuration command, followed by 6 increment PC commands then a readFromProgramMemeory command. During the read the data line does not change. It almost seems like High Voltage Program Verify mode failed? I have a working PIC (displays stuff to an LCD screen on reset). Note that this board is different than the one I have been testing but I wanted to have a setup to test programming on a board that was known to work 100%. My question is it says that nMCLR must be raised before VDD (HV). If the device has its own target for VDD, then VDD will always rise before nMCLR. Is this a problem? This type of setup has worked for me in the past, so I think the answer is no?

"Do you have any special reason to enable LVP? I think LVP is useless (especially if you have ICD2) because it will dedicate one I/O pin for PGM function. Why don't you just disable LVP, it might solve your problem."

I need to be able to easily flash the device since this hardware will be at many different locations (Nice to have this automated and not require on user intervention). Essentially all control of this hardware is done via a webservice which accesses a DAQ card in the PC to talk to to various CPLDs on a bus. One of the CPLD has a register that allows me to write and read values to/from the PIC, so essentially using LVP can allow the device to be flashed without external hardware.
 
I suggest you would use a more advanced device (such as 16F88) that can do "self programming", this is much simplier than CPLD and using programming mode. With 16F88 you can make a bootloader that will serve you well.

As for ICD config bit, this only switches PIC to Debug mode and it has nothing to do with programming itself, don't enable Dubug mode if you just want to program the PIC.

As I said HVP mode is always available! LVP can be disabled (by clearing LVP bit)., are you sure that PIC is not damaged? HVP must work regardles any config bits (except MCLR_OFF together with INTOSC !).
 
Jay.slovak said:
HVP must work regardles any config bits (except MCLR_OFF together with INTOSC !).

No, HVP works even with MCLR off and INTOSC. On some PICs, secret is to raise Vpp before Vdd.
 
Yes, but he has unmodified ICD2 so he should be aware of such config. With proper Vdd/Vpp circuit everything works fine.
 
I grabbed another PIC that I know works (as there is code running on it), and I still can't seem to HV program it. I'm starting to think it might be driver-related problems (something on the computer), although I do see the proper commands on the clk and data lines? I'm going to try on another system that has MPLAB and ICD2 working with other PICs.


Unfortunately the circuit has already been designed and boards have already been made so there is no way to raise Vpp before Vdd, or select a different PIC IC.


"As for ICD config bit, this only switches PIC to Debug mode and it has nothing to do with programming itself, don't enable Dubug mode if you just want to program the PIC. "

When I select this bit, it doens't allow me to change the configuration fuses (MPLAB 7.1)? Is this setting supposed to work this way when you set #device ICD = TRUE. Also in the configuration bits section the oscillator type is HS and not INTOSC. If you program with HS fuse does that mean you have to supply an external clock?? I have done this (by setting ICD=TRUE) and it still showed an clock output on RA6.
 
What I am trying to tell you is NOT to enable ICD funcionality for programming only! Did you check your PGM pin, is it floating or grounded?
HS stands for High Speed Crystal/Resonator so you have to connect crystal/resonator to PIC in order to work. Oscilator is NOT a requirement for programming!
 
CLK AND DATA Voltage levels

Hi,

I'm almost got low voltage programming working. Seems that the configuration bits I am writing are not getting written correctly. For low voltage what are the voltages needed for clk and data. Is 3.3 o.k. It mentions VDD needs to be between 4.5 and 5.5 for bulk erase but not sure if that impies that you have pull-ups to VDD on clk and data lines. I have seen mention of 4.7K pull-ups to on these lines?


thanks
 
Because PGD and PGC pins have ST (Schmitt Trigger) input with Vil of 0.2V*Vdd and Vih of 0.8*Vdd, the voltage level on theese should be 4V (at 5V Vdd) minimum, but the chance is it will work with 3.3V, no pull-ups are needed.
 
Hi,

I can get LVP to work. After writing the configuration word. I check all contents of program memery and configuration memery and what I read back looks good. I can move around between program memory and configuration memery fine until I allow the device to run. Pull nMclr low and then high without PGM set. The code on the dvice works fine. If I then try and enter LVP mode again I am not successful. It previously always works on a part that had not had the configuration bits programmed (I am usign 0x3FAA for the configuratin word). If almost seems like the configuration bits are not being set properly.... even though I can read them back from memory. Note I have not pulling clk data and pgm up to VDD (5V). I am driving them at 3.3. I did try pulling pgm up to VDD via a pull-up resistor but this did not seem to get me into lvp mode. Currently the ICD2 that I am using (have a whole bunch here), does not seem to be able to connect to this PIC.

I can have marginal success (with ICD 2) on a board with a PIC that hasn't been programmed, but once I program the PIC and have code running of it. HV programming does not work. When it does work (first time only), I consistently get an error verifying the configuration word? Expected 0x3FAA got 0x0000. I can program the entire program memory and can always re-enter lvp mode, but once I set the configuration bits, I am locked out after the PIC has a change to boot?

Any ideas?
 
I would really like to help you, but I still don't know what your problem is (I mean HVP has to work). Can you upload your schematic and some pictures? That would help a lot!
 
Jay.slovak said:
I would really like to help you, but I still don't know what your problem is (I mean HVP has to work).

Unless his PIC is already happily running his previous codes when he try to progrm it using HVP. :shock:
 
Exactly, we need more info here...
 
mulaish said:
but once I set the configuration bits, I am locked out after the PIC has a change to boot?

By using 3FAA as config word, you have enable LVP. But if you have enable LVP, then it is a requirement that you must pull PGM high in order to enter LVP mode.

Have you set PGM high before trying to use LVP?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…