Author Topic: Help!!! Why Can't I Program My PIC18F25K22 ID's ????(Solved)  (Read 13201 times)

0 Members and 1 Guest are viewing this topic.

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #25 on: June 01, 2015, 11:10:56 am »
Nearly all the PICkit 2 firmware and software (including sourcecode) is hosted over at Microchip.  See: http://www.microchip.com/forums/FindPost/775368

You would need the PICkit 2 v2.61 software + the upgrade to device file v1.62.14 or higher.  The firmware hex file is bundled with the standalone application. 

N.B. the standalone application programming only device support list is considerably longer than the PICkit 2 MPLAB device support list, which is itself longer than the list of devices that can be debugged with a PICkit 2.

A PICkit 2 Lite is cut down by omitting the target Vdd generation and control circuit.  As such it is limited to the subset of the device support list that can run at 5V, and also, depending on the existing target  PIC's firmware, may not be able to reprogram PICs that have external /MCLR disabled in their CONFIG.
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #26 on: June 01, 2015, 01:36:19 pm »
I tested the idea that WTD was running and my common sense demands that it is not, since Microchip would have mentioned this caveat

The most basic thing my programmer can do is 1) Read the DeviceID. This works perfectly every time.
(2) Read MCU address locations. The device ID read works perfect.
(3)Do a HV Bulkerase, it should erase everything except the DeviceID.

My SW/HW cannot seem to do this. I read back all 00's as result.

There are just two possibilities, and they are:

1)If I cannot seem to erase the 25F25K22:
    This can be due to my software code is incorrect.  But it is step-by-step copy of the code in the Microchip Prgm'ing datasheet.
    To check the Microchip code for errors or typos, I examined the latest errata sheet. There is no mention of any errors.
    So, it is not a software problem.

2)Then this is a hardware problem.
    I followed my code completely through the BulkErase procedure(it has been uploaded to this toipic)
    I monitored the Vpp, Pclk, Pdat lines to verify the code was executing bit for bit v.  the code to accomplish BulkErase.
    Result, the program executes without a detectable software or hardware flaw.
   I have checked for runt pulses, VoutHi, VoutLo, rise/fall times/glitches/VppHi and Lo transition times and they all beat the specs.

So, considering the above, I must conclude that what is left..the PIC18F25K22 chips could be defective.
This means that all 10 25F25K22 and the 4 25F45K22 are defective.  This is hard to believe since I purchased them from a reliable major electronic parts hardware player.

There is only one thing that bothers me, one of the first replies to my post for help warned me that I might not be doing things right somehow. I was not told what, just it was implied that some step was missing.

What do I do now? The chips have been purchased over 6-mths ago, and have been sitting on my Procrastination Shelf until now.

If only I had a PIC programmer to make a test!

Thanks neslekkim,  I downloaded the source code, it was difficult to read for me, but it seems to me that the Microchip BulkErase instructions are the acid test to determine if the programmer is working.

Thanks Ian.M for your help, I haven't yet attempted to download the sourcecode for the PICKIT2, but I can't get myself to accept that the Microchip guide to programming is in error, even though many sections explain programming operation in ways  that make understanding difficult, too much very important detail is poorly explained, this document is unprofessionally needlessly vague and sometimes confusingly ambiguous.

Thanks to Bruce Abbott, but open-source projects are a circus in a software jungle, they often try to be so general at everything that they are almost incapable to be understood for the specifics. As for this project it would certainly be worth the while to find a more specifically targeted HW/SW approach or buy a commercial product.

« Last Edit: June 02, 2015, 03:36:56 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #27 on: June 01, 2015, 01:40:28 pm »
Skimask replied to me, "You're doing most of what's required...but not all of it.  Re-read the programming spec datasheet."


What am I missing?
 

Online Ian.M

  • Super Contributor
  • ***
  • Posts: 12855
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #28 on: June 01, 2015, 01:50:22 pm »
You might want to try 3rd party software that can be configured for your programmer hardware (assuming you are bit-banging the programming signals from your PC)

If it works, you have an algorithm or timing problem.  If it doesn't, you have a hardware problem or maybe dead PICs.  N.B. dead PICs are *VERY* unlikely, and if you have any, the most likely cause is that your programmer has killed them!

http://picpgm.picprojects.net/ would be worth trying.
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #29 on: June 01, 2015, 03:47:39 pm »
Thousand Thanks Ian.M

I know it is highly unlikely that these chips bought are bad..very unlikely..but then????

I wish I knew about this site

http://picpgm.picprojects.net/

sooner, could have saved hours and hours of troubleshooting!

I needn't have had to re-invent the wheel.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #30 on: June 01, 2015, 04:08:19 pm »
Quote
If I then physically remove the chip in the reset idle state from the ZIF socket and re-insert back in, all the program area bytes read back are all zeroes!
Are you removing and inserting them while it's powered on? Don't do that.

I notice that you are using 5V Vdd but the datasheet says that Vihh must be at least Vdd+4.5 and at most 9. In other words, you cannot do high-voltage programming on an 18F2XK22/4XK22 at 5V Vdd, since then you'd need at least 9.5V to enter programming mode but that would violate the 9V max. The reason some of it seems to work but not others, is purely due to process variations. The parts may enter programming mode with less than 4.5V above Vdd, but this behaviour is not guaranteed at all.

Ideally you'd use something between Vdd+4.5 and 9V. Since Vdd can be between 2.7 and 5.5V if you want to do bulk erases, pick something in that range which will satisfy the Vihh requirements. E.g. 8V on Vihh and 3V Vdd should be OK.

If you look at their programming specifications you'll see that this is different from the 16F88x, which need a Vpp between 10 and 12V (I'd pick 11) and Vdd between 4.5 and 5.5V (5V is just right.) If you were using 9V Vpp with the 16F88x and it worked, I'd consider that also pure luck.

But this doesn't say which of many possible native PIC18F25K22 CPU instructions would be allowed to be executed or ignored?
Presumably everything except control flow instructions.
Quote
One thing that I can't quite wrap my head around is that in programming the PIC 18F25K22 the programmer is actually sending actual instructions of the 18FK25K22 instruction set and the MCU responds. This means that somehow internally these instructions are decoded and executed just like the chip was running code with an active instruction clock running.
...
It is obvious from the tens of nSec response of the chip being programmed that it is delivering the next PDat output bit in a few tens of nSecs from a PClck pulse inputted rise/fall, which would otherwise indicate a very fast internal clock running.
There is no "internal clock" - the only clocking is being supplied by the programmer.

There is no minimum clock frequency.

The same can be done for AVRs:

 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #31 on: June 01, 2015, 04:16:30 pm »
Thanks Amyk for your suggestions, some are good, some are very, very bad.

I think you are confusing Vdd with Vpgm when you say," you cannot do high-voltage programming on an 18F2XK22/4XK22 at 5V Vdd, since then you'd need at least 9.5V to enter programming mode" 

I think you are saying to raise Vdd to 9.5 Volts??

Vihh is rated at 11V Absolute Max Ratings in the spec sheet, so it seems that 9V would be safe, why shouldn't that work. They specify that all programming voltages are allowed to be set with a precision of  +/- .25V

See attached.
« Last Edit: June 01, 2015, 04:32:19 pm by SuzyC »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #32 on: June 01, 2015, 04:27:31 pm »
Please read carefully...

Code: [Select]
9 ---+----          ---+ Vihh MAX
     |                 |
7.2--+              ---+ Vihh MIN
     |                 ^
     |                 |
5.5--+---- Vdd MAX    4.5V
     |                 |
     |                 v
2.7--+---- Vdd MIN  ---+
     |
     |
0 ---+
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #33 on: June 01, 2015, 04:41:37 pm »
Thanks Amyk and a thousand pardons, I see your point now. If I lower Vdd to 4.5 volts that I can use Vihh =9V and meet the programming specs.

I will give that a try.

Your diagram makes your point  very clear to understand, Sorry, I was unable to distinguish in your suggestions between Vdd and Vpp  and I thought you suggested to raise Vdd to 9.5V!

It means though that just having Vihh=9 at Vdd=5.0V, Vpp  at just .5V above 9V max is enough to prevent programming!
« Last Edit: June 01, 2015, 04:53:31 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #34 on: June 01, 2015, 05:34:19 pm »
I just lowered Vdd on my breadboard to 4.25V and ViHH is set to 9.0V, but with the exactly same result. I did a scope check and the Vout Voltages and Vdd were steady at 4.15 to 4.25V
Possibilities:
(1) I have already fried my 14 victims of grave programming abuse.
(2) My software is somehow in error, If I call BulkErase, the result is of a short memory dump shows all 0's, but what is puzzling is if that I read the 7 ID locations routine and then run again another read at Flash Program Mem=&H0 to &H32 I then see all ones. The readings repeatedly show that all  are erased 0xFF,  that is until I powerdown reset or else call ReadDevID and then, if I call ReadMemory18 I am back to reading all zeros again consistently.

Something else is a widdle screwy here.

I think I need to once more step through my code to find some error.
« Last Edit: June 02, 2015, 03:59:43 pm by SuzyC »
 

Offline android

  • Regular Contributor
  • *
  • Posts: 134
  • Country: au
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #35 on: June 02, 2015, 01:06:38 pm »
One more thing you could try...

Before trying to write new ID bytes, instead of doing a Chip Erase (0F8F) do an Erase User ID (0088). The chip erase may be just taking a very long time.
Lecturer: "There is no language in which a double positive implies a negative."
Student:  "Yeah...right."
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #36 on: June 02, 2015, 02:14:41 pm »
Thanks Android for your help. I notice that the erase sequence try to writes a 16-bit word to an 8-bit space?
DW = &H8888: Call TBLWR             'Cmd 1100  Table Write  0x88 to &H 3C 0004

Here's the exact code, but the effect is that results are exactly the same.

In every case, reading the 8 IDs repeatedly shows 0xFFFF's, but IDs never program with new values, though.

If I Call SubBulkErase8FxIDsOnly, then follow with ReadPgmMem18, reads first 32-bytes I get repeatedly 0xFFFFF read out.

If I power down the programmer completely and power up
, the ReadPgmMem18 now shows again repeatedly 0's.

My four-year old daughter tried the same thing..same results.

My immediate conclusion is that the Table Pointer for Pgm Flash Memory reads is not being reset!...why??

This is odd, because every Call ReadPgmMem18 resets the MCU upon entry!

'This is the exact VB code complete to do all operations, with recently corrected comments
'====================================================================================
Private Sub BulkErase18FxIDsOnly()  'EraseUserIDs     0x0088

'First Reset MCU             BulkErase Erases the entire device, after this some CONFIG WORDS must be config'd
CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0
mSec = 10: Call Dly1
CW = &H1D: Out P, CW    'VPgm=HV 'RESETS Chip when Vpgm=VpgmHi, PC to 0000H
mSec = 1: Call Dly1     'Now MCU Erase instruction is to be clocked in

DW = &HE3C: Call CID16  'MOVLW 0x0E3C First MOV 0x3C to 0x0E (0x003C)is the 16-bit payload to clock in
DW = &H6EF8: Call CID16 'MOVWF TBLPTRU  Move's the above 0x3C byte to the Table Pointer's Upper Reg
DW = &HE00: Call CID16  'MOVLW 00 to 0xOE register
DW = &H6EF7: Call CID16 'MOVWF TBLPTRH 'Moves above to Table Pointer High
DW = &HE05:  Call CID16 'MOVLW 5 to 0x0E register
DW = &H6EF6: Call CID16 'MOVWF 5 to TBLPTRL
DW = &H0: Call TBLWR  'Cmd 1100 Table Write Writes 0 to &H 3C 0005
DW = &HE3C: Call CID16  'MOVLW 0x3C to 0x0E register
DW = &H6EF8: Call CID16 'MOVLF the above to TBLPTRU, at RAM address 0FF8h
DW = &HE00: Call CID16  'MOVLW 0 to 0x0E register
DW = &H6EF7: Call CID16 'MOVLF the above to TBLPTRH, at RAM address 0FF7h
DW = &HE04: Call CID16  'MOVLW 0x4  to 0x0E register
DW = &H6EF6: Call CID16 'MOVLF the above to TBLPTRL, at RAM address 0FF6h
DW = &H8888: Call TBLWR 'Cmd 1100  Table Write  0x88 to &H 3C 0004
DW = &H0: Call CID16    'NOP
DW = &H0: Call BulkEraseHVStart
                        'A NOP that holds Dat Lo when 4th bit=0, for Tprog(P9>15mSec)when Bulk Erase Begins
mSec = 20: Call Dly1    'mSec=15 is Min for ID's BulkErase. There is no wait Max spec
CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0 Exits Programming Mode


End Sub

'====================================================================================
Private Sub ReadPgmMem18()

CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0
mSec = 10: Call Dly1
CW = &H1D: Out P, CW    'VPgm=HV 'RESETS Chip  Vpgm=VpgmHi
mSec = 1: Call Dly1 


'First Set TBLPTR Address to  0
DW = &HE0: Call CID16   'MOVLW 0 First MOVLW (0x0E) with &H00,the 16-bit payload to clock in
DW = &H6EF8: Call CID16 'MOVWF TBLPTRU  Move's the above 0x20 byte to the Table Pointer's Upper Reg
DW = &HE0: Call CID16   'MOVLW 0x0 to 0xOE register
DW = &H6EF7: Call CID16 'MOVWF TBLPTRH 'Moves above to Table Pointer High
DW = &HE0:  Call CID16  'MOVLW 0x00 to register
DW = &H6EF6: Call CID16 'MOVWF 0 to TBLPTRL

'------Now Table Pointer Address is set to 00 0000
cls
For Ju = 0 To 32 Step 2
    Call TBLRDPinc       'Read Pgm Flash Mem with Post Inc. Adrr Cmd
    Call ReadData18F
    Pdm(Ju) = W
    Call TBLRDPinc      'Read next 8-bit address contents   with Post Addr Inc
    Call ReadData18F
    Pdm(Ju + 1) = W
Next
CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0
mSec = 10: Call Dly1

End Sub

/======================================================================================
Private Sub ReadIDs18F()
Dim ID(20) As Integer

CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0
mSec = 10: Call Dly1
CW = &H1D: Out P, CW    'VPgm=HV 'RESETS Chip when Vpgm=VpgmHi, PC to 0000H
mSec = 1: Call Dly1         
 
                        'First Set TBLPTR = 20 0000  7 bytes: 20 0000:7 contain the IDs

DW = &HE20: Call CID16  'MOVLW 0x20 First MOVLW (0x0E) with &H0020,the 16-bit payload to clock in
DW = &H6EF8: Call CID16 'MOVWF TBLPTRU  Move's the above 0x20 byte to the Table Pointer's Upper Reg
DW = &HE0: Call CID16   'MOVLW 0x0 to 0xOE register
DW = &H6EF7: Call CID16 'MOVWF TBLPTRH 'Moves above to Table Pointer High
DW = &HE0:  Call CID16  'MOVLW 0x00 to register
DW = &H6EF6: Call CID16 'MOVWF 0 to TBLPTRL

'------Now Table Pointer Address is set to 20 0000
cls
For Ju = 0 To 7
    Call TBLRDPinc       'Cmd 1001 Read IDs with Post Inc. Adrr Cmd
    Call ReadData18F
    ID(Ju) = W
Next

CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0
mSec = 10: Call Dly1
End Sub

'=======================================================================================
Private Sub ReadData18F()
'Read Data
 A$ = "": W = 0
 For Js = 0 To 7 'First Clock in 8 zeros
    CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
    CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
 Next Js
 
 For Js = 0 To 7 'Now Data is Clocked Out..Read Data
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW: ' Clock Hi, Data Hi, Vpgm=VpgmHi
   GoSub MakeNum
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
 Next Js
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi

be$ = ""
For R = 8 To 1 Step -1
     be$ = be$ + Mid$(A$, R, 1)
Next R
For R = 0 To 7
     U = Val(Mid$(A$, R + 1, 1))
     If U = 1 Then
        W = W + (2 ^ R) 'W = 8-Bit DATA READ
     End If
Next
If Pmode Then GoTo ExitRData
LPT_Form.FontSize = 14
LPT_Form.FontBold = True
H1$ = Hex$(W): L = Len(H1$): If L < 2 Then H1$ = "0" & H1$
   
Print H1$ & "   " & Mid$(be$, 1, 4) & " " & Mid$(be$, 5, 4)

GoTo ExitRData

MakeNum:
   U = Inp(SP) 'inp(&H379 bit 4 =SELECT IN DB25 Pin13, if bit4=1 then clocked out PDat=1
   U = -((U And 16) = 16)
   A$ = A$ + Mid$(Str$(U), 2)
Return

ExitRData:
End Sub

'=====================================================================================
Private Sub TBLWR() 'TableWrite instruction

' 1100  Table Write precedes a 16-bit payload to Table

   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi  bit 0=0 cmd clk'd in
   
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi  bit 1=0 cmd clk'd in
   
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H14: Out P, CW ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW ' Clock Lo, Data Hi, Vpgm=VpgmHi  bit 2=1 cmd clk'd in
   
   CW = &H14: Out P, CW ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW ' Clock Lo, Data Hi, Vpgm=VpgmHi  bit 3=1 cmd clk'd in
   
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 3=0 cmd clk'd in. Both Clk and Data Lo, Ready for a 16 bit Load

'Now Clk in the 16-bit PayLoad DW
 Dim Bit As Integer
 For Bit = 0 To 15          ' Clocks in 16-bits of PayLoad data LSB First
   If (2 ^ Bit) And DW Then ' Clock in a 1
     CW = &H1E: Out P, CW   ' Clock Hi, Data Lo, Vpgm=VpgmHi
     CW = &H14: Out P, CW   ' Clock Hi, Data Hi, Vpgm=VpgmHi
     CW = &H15: Out P, CW   ' Clock Lo, Data Hi, Vpgm=VpgmHi bit Bit of DW=1 clk'd in
     CW = &H1D: Out P, CW   ' Clock Lo, Data Lo, Vpgm=VpgmHi 'resets Clk and Data, ready for next instruction/data bits
     
   Else 'Clk in a 0
     CW = &H1E: Out P, CW   ' Clock Hi, Data Lo, Vpgm=VpgmHi
     CW = &H1D: Out P, CW   ' Clock Lo, Data Lo, Vpgm=VpgmHi bit Bit of DW=0 clk'd in
   End If
 Next Bit
 
End Sub

'==================================================================================
Private Sub TBLRDPinc()
'18Fx5K22 Table Read Cmd 1001
   
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 0=1 cmd clk'd in

   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 1=0 cmd clk'd in

   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 2=0 cmd clk'd in

   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 3=1 cmd clk'd in

   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
End Sub
« Last Edit: June 03, 2015, 02:51:34 am by SuzyC »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #37 on: June 02, 2015, 03:37:56 pm »
Remembering that PGD is bi-directional, are you correctly changing the direction of your programmer's port? If you put a weak voltage divider on that line you should be able to see it floating in the middle in the short times between when you're driving it and the PIC is. Look at figure 4-5 in the programming spec.

At this point you might be better off getting two debounced pushbuttons and LEDs hooked up so you can bit-bang it manually... it's only a few hundred bits to key in :P
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #38 on: June 02, 2015, 03:52:10 pm »
Thanks Amyk.

I am only using the bit lines of LPT1 on the PC, when an inp(&H379) is executed by the PC the bit line is always being read.
The LPT port uses Open-Drain Pull ups for HW interface, so there is never a bus collision, the bit lines are always Open-Drain outputs.

As I have stated before, this magnificent programmer works perfectly with PIC 16F88x chips, so this is not an issue.
When I scope the output of the PIC18F25K22 when I am reading it, I can see exactly that the output reported by my reads to my VB screen are exactly what is shown on my 4-chan scope of PClk and PDat in the read operation (ReadData18F).

It is certainly a possibility that somehow I have zilched all my poor 18Fx5K22 chips.

I know for sure, having done this more times that I am proud of, that if a slip-of-the-probe accident raises Vdd above 7.5V and therefore surely fries a 16F88x chip, the device will read out all zero's when I attempt to program it or read any addr. of its memory.

But I can't accept that to be the case for sure yet because of the inconsistencies of reading out sometimes zero's, sometimes all 1s. But although these chips have once been exposed to Vpp=11V,  Vdd has never, ever exceeded 5.0V.
Besides that, the DevIDs always reads correctly.
« Last Edit: June 02, 2015, 04:32:28 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #39 on: June 02, 2015, 07:01:22 pm »
Update: I just tried a single row erase of 64 bytes (for purpose of testing, the first 64 bytes of Program Memory)

According to bit polling to test WR bit to see if RowErase is complete, the write of 64 bytes was successful!


However I get exactly the same results, a read of the first 32 bytes of Pgm Flash Mem is all 0's

How can a write be successful and yet fail to knock up all erased bytes to all 1's?

Can anyone tell me how the instructions below work read to test a bit (the code returns a byte)  to poll to see if a write is completed?       

Please see attached copy from Pgm'ing Datasheet for further clarification

I am totally confused, according to the 18F25K22 datasheet, the EECON1 Reg is located at 0xFA6, is it just me or isn't the steps below trying to manipulate 0xA6 ??? BTW these steps are directly copied from the PIC18F25K22 Pgm'ing Datasheet.


 DW = &H8EA6: Call CID16 'Configures ECON1 register to Enable Programming
 DW = &H8CA6: Call CID16 'CFGS enable programming of Config Bits if Set, Reset here to Enable Pgm Flash Program Memory
 DW = &H84A6: Call CID16 'WREN write enable enabled


'======================================================================================
Private Sub EraseSingleRow18F() 'Erases 64 Bytes in any row, but only the first row is always erased here for debugging

 CW = &H1B: Out P, CW 'RB6,RB7 Low, Vpgm=0  'P is address of Parallel Port Register 0x37A which controls Vpp, Clk, Data
 mSec = 10: Call Dly1
 CW = &H1D: Out P, CW 'Set VPgm=HV ' Vpgm=Pin1=Vpp=9 V HV to enter Pgm'ing mode.
 mSec = 1: Call Dly1
 
DW = &H8EA6: Call CID16 'Configures ECON1 register to Enable Programming
 DW = &H9CA6: Call CID16 'CFGS enable Program Flash or IDs
 DW = &H84A6: Call CID16 'WREN write enable enabled

 
 DW = &HE00: Call CID16 'Set Table Ptr Regs
 DW = &H6EF8: Call CID16 'writes &H0 to TBLPTRU
 DW = &HE00: Call CID16
 DW = &H6EF7: Call CID16 'Writes  &H0 to TBLPTRH
 DW = &HE00: Call CID16
 DW = &H6EF6: Call CID16 'Writes  &H0 to TBLPTRL
 
 DW = &H88A6: Call CID16 'Free Enabled
 DW = &H82A6: Call CID16 'WREN enabled
 DW = &H0:  Call CID16   'NOP
 DW = &H0:  Call CID16   'NOP ERASE ROW starts at 4h bit of this instruction

Poll: 'Poll WR bit of EECON1 Reg until it is clear
 DW = &H50A6: Call CID16 'MOVF EECON, W, 0 'Now Poll PDat line until it is Lo
 DW = &H6EF5: Call CID16 'MOVWF TABLAT
 DW = &H0: Call CID16    'NOP
 DW = 0: Call EraseRowPoll 'WR is bit 1 of EECON1 Register WRerr is Bit 2 if writting operation failed bit is set

NumTries = 0
Poll: 'Poll WR bit of EECON1 Reg until it is clear
 DW = &H50A6: Call CID16 'MOVF EECON, W, 0
 DW = &H6EF5: Call CID16 'MOVWF TABLAT
 DW = &H0: Call CID16    'NOP
 DW = 0: Call EraseRowPoll 'WR is bit 1 of EECON1 Register WRerr is Bit 2 if writing operation failed bit is set
 mSec = 1: Call Dly1
 NumTries = NumTries + 1
 If (NumTries > 1000) Then Pr$ = "Failed": GoTo ExitUponFailure
 if (W And 2) = 2 Then GoTo Poll 'Check bit 1 = 1 WR has started in progress

 mSec = 30: Call Dly1  'Erase wait time is 200uS spec'd min
 
 DW = &H94A6: Call CID16 'WREN disabled

ExitUponFailure:
 
 CW = &H1B: Out P, CW 'RB6,RB7 Low, Vpgm=0
 mSec = 10: Call Dly1

End Sub

'=======================================================================================
Private Sub EraseRowPoll() '0010 Reads Data from EECON1 for EraseRowPolling, W is byte read out from MCU

   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 0=0 lsb cmd entered

   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 1=1 cmd clk'd in
   
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 2=0 cmd entered

   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 2=0 cmd clk'd in

'Read Data
 A$ = "": W = 0 'W has been declared Public as Integer
 
 For Js = 0 To 7 ' Dummy 0 bits must be Clk'd in prior to Clk'ing out 8-bits
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW: ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
 Next Js
 
 'Now Clock Out the PDat bits read and make a byte
 For Js = 0 To 7 ' Now Clk'ing out 8-bits
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW: ' Clock Hi, Data Hi, Vpgm=VpgmHi
   
   GoSub MakeNum 'Input the bit clocked out of the MCU

   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
 Next Js

For R = 0 To 7
     U = Val(Mid$(A$, R + 1, 1))
     If U = 1 Then
        W = W + (2 ^ R) 'W = 8-Bit DATA READ
     End If
Next

GoTo ExitRData

MakeNum:
   U = Inp(SP) 'inp(&H379 bit 4 =SELECT IN DB25 Pin13, if bit4=1 then Select In LPT1 pin13 is at Vdd, so PDat was read =1
   U = -((U And 16) = 16)
   A$ = A$ + Mid$(Str$(U), 2)
Return

ExitRData:
End Sub
« Last Edit: June 03, 2015, 02:52:31 am by SuzyC »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #40 on: June 03, 2015, 02:58:48 pm »
However I get exactly the same results, a read of the first 32 bytes of Pgm Flash Mem is all 0's

How can a write be successful and yet fail to knock up all erased bytes to all 1's?

How are you sure that your readback code works?

If your readback code is broken, you can't tell the difference between a successful modification or not. Make sure you are able to read any area of memory in the (unprotected) device first, before proceeding with writing. Since the configuration bits by default will have non-FF values, I would recommend attempting to read those.
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #41 on: June 03, 2015, 03:34:41 pm »
Thanks a quadrillion protected bits,  Amyk.


I am able to most consistently, always able to read the Dev ID bytes without error..but these two bytes are never protected.

My read routine has been checked over more than once, so it is OK, it copied right out of the Pgm'ing datasheet in VB code.
 
However, if HV bulkerase is working(looks like it is not from my reading of bits!), then I would expect the CONFIG bytes to be all erased and the write/read protects require a bit to be 0 to protect. The BulkEraseHV supposedly erases everything with the 0xF8F call.
 However, if the BulkEraseHV is not working, then the CONFIG bytes might all be zeroed, preventing me from
writing or reading correctly Pgm MeM or even changing the CONFIG words!

So, there still might be a possibility that I am reading a Read/Write Protected memory spaces and that is why I see all 0's.
In that case I must try to program/read CONFIG words to see what I get.

And that's what I will do now in the next few minutes. Just takes a few minutes to code.

But in this case, the Pgm'ing datasheet would have to be error, since it is stated there that a HV will erase all without any  setting write enable EECON1 permission bits. Or else my BulkEraseHV routine would have to be in error, but it is code directly copied from the steps in the Pgm'ing datasheet.

If setting the CONFIG bytes fails to fix the problem, then the only reasonable possibility left is that my chips are fried!

« Last Edit: June 03, 2015, 04:24:09 pm by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #42 on: June 03, 2015, 06:12:31 pm »
I wrote the following code below to set the CONFIGW all to the datasheet default values (Except for WDT turned off)

The result: Same problems, and MCU still shows memory erased only if I call ReadIDs18 until I do a BulkEraseHV 0xF8F, then the first 32 bytes of memory show as zeros again.

Quote from 18F25K22 Datasheet:
Control bit, CFGS, determines if the access will be to the Configuration registers or to program memory/data
EEPROM memory. When the CFGS bit is set, subsequent operations access Configuration registers.
When the CFGS bit is clear, the EEPGD bit selects either program Flash or data EEPROM memory


I am totally confused: The settings for the EECON1 Addr 0xF6A register controls all Writes and where they are written:
It has default values of:   xx-0 x000
The settings for EECON1 are directly from the steps Section 3.6 (See attached copy of this page if below is confusing)
Note:
EEPGD can enable Pgm Mem writes, but CFGS overrides this if writing to ConfigW registers =1 enabled

' Control bit, CFGS, determines if the access will be to the Configuration registers or to program memory/data
'EEPROM memory. When the CFGS bit is set, subsequent operations access Configuration registers.
'When the CFGS bit is clear,  EEPGD=1 allows Program Flash writes or if clear EEPROM memory writes are enabled

 'Address Name    Bit7                 6                  5      4                    3              2             1            0                     EECON1
 ' FA6h   EECON1  EEPGD         CFGS               —   FREE           WRERR    WREN         WR           RD       (Default Values xx-0 x000)
 '                            0                 1                    -        0                   x             1            1 when     x
 '               Write EEPROM     Write CfgMem          Writes                         WREN         Write
 '                        Enabled      Enabled                   Enabled                     enabled       Starts
 '  if EEPGD=1 Pgm Memory                                  if FREE=1
'   writes are enabled                                           Erases are Enabled
'  only  if CFGS=0
'----------------------------------------------------------------------------------------------------------------------
'DW = &H8EA6                                                                                                                                           Result
'                EEPGD       CFGS     -   FREE    WRERR    WREN     WR         RD
'                 1                0          -    0           1             1           1             x                     CONFIGW Writes DisableD
'DW = &H8CA6                                                                                 
'                 1                0          -    0           1             1           ?             x                      CONFIGW Writes DISABLED
'DW = &H84A6
'                 1                0          -    0            0            1           ?             x                     CONFIGW writes DISABLED
'-------------------------------------------------------------------------------------------------------------------
How can CONFIGW words be modified if writing to them is disabled?

'========================================================================================
Private Sub PgmCfg18()
 CW = &H1B: Out P, CW 'RB6,RB7 Low, Vpgm=0  'P is address of Parallel Port Register 0x37A which controls Vpp, Clk, Data
 mSec = 10: Call Dly1
 CW = &H1D: Out P, CW 'Set VPgm=HV 'RB6,RB7 Low, VPgm=VpgmHi, Resets Chip, Enters Programming Mode
 mSec = 1: Call Dly1
 
 CWnum = 1
Again:
 
 DW = &H8EA6: Call CID16 'Configures ECON1 register to Enable Programming
 DW = &H8CA6: Call CID16 'CFGS enable programming of Config Bits
 DW = &H84A6: Call CID16 'WREN write enable enabled
 
 DW = &HE30: Call CID16 'Set Table Ptr Regs to Address of CONFIGW
 DW = &H6EF8: Call CID16 'writes &H30 to TBLPTRU
 DW = &HE00: Call CID16
 DW = &H6EF7: Call CID16 'Writes  &H0 to TBLPTRH
 'All CONFIG words will be set to the default/unprogrammed values shown in datasheet
 If CWnum = 1 Then 'CONFIGW number
   DW = &HE00
   DW1 = &H2500        'DW1 in every case is CONFIGnHi=MSB and CONFIGnLo=LSB where n=CWnum
 ElseIf CWnum = 2 Then
   DW = &HE02
   DW1 = &H1F
 ElseIf CWnum = 3 Then
   DW = &HE04
   DW1 = &HBF00
 ElseIf CWnum = 4 Then
   DW = &HE06
   DW1 = &HFF85
 ElseIf CWnum = 5 Then
   DW = &HE08
   DW1 = &HC00F
 ElseIf CWnum = 6 Then
   DW = &HE0A
   DW1 = &HE00F
  ElseIf CWnum = 7 Then
   DW = &HE0C
   DW1 = &H400F
 End If
 Call CID16  'Addr=DW of CONFIG Reg Pair
 DW = &H6EF6: Call CID16 'Writes  DW to TBLPTRL
 CWnum = CWnum + 1
 DW = DW1: Call StartWrite18 'Writes LSB to &H30 000n and MSB to &H30 000(n+1) where n=CWnum

 If CWnum < 8 Then GoTo Again
 
 DW = &H94A6: Call CID16 'Resets Write Enable bit WREN, Write Enable disabled.
 DW = &H9CA6: Call CID16 'Disables Writing to CONFIG Regs
 
 mSec = 1: Call Dly1
 CW = &H1B: Out P, CW    'RB6,RB7 low, Vpgm=0 Exits Programming Mode
End Sub


« Last Edit: June 04, 2015, 10:27:05 am by SuzyC »
 

Offline android

  • Regular Contributor
  • *
  • Posts: 134
  • Country: au
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #43 on: June 06, 2015, 12:55:24 pm »
Hi SuzyC,

It just occurred to me that I may be able to help with some actual timings. What I did was put a Salae Logic analyser on the PGD/PGC pins of a PIC18F25K50 (not quite the same as yours) and captured the successful programming of the ID bytes by my MikroProg programmer. The programmer indicated that it did a chip erase followed by write ID bytes. Verify was turned off, so that should be all that was captured.

I've attached a screenshot of the "google earth" view ... it only took 3 seconds but it was way too much to show on a screen all at once. This should help guide you through the csv file that Logic created (also attached) - showing all the transitions and when they occurred.

It might take a while to digest...but it just might help you nail it. Good luck  ;D.

Edit: Forgot to mention, the ID bytes I programmed were: A1 A2 A3 A4 A5 A6 A7 A8
« Last Edit: June 06, 2015, 12:56:58 pm by android »
Lecturer: "There is no language in which a double positive implies a negative."
Student:  "Yeah...right."
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #44 on: June 07, 2015, 03:24:18 am »
Thanks Android,   :clap:

These pictures are quite pretty, thanks a million for taking the effort!

 I can do the same thing with IDs programming, now works perfect, except my word!, everything is bit too all one-ish in  programming results.

I have everything working now except the code flash programming.

I even bought a few more brand new chips..same result!

I can display any 32-byte region of memory or ID's or Config Data.
 
I can modify CONFIG bits or change ID's, just can't seem to get the *#@a@! Program Flash pgm. Mem. to write a single byte. |O

Note: LastAddr DW W Ju mSec, PgmCodeSize, are declared Public
'=======================================================================================
Private Sub Pgm18F25K()
Call BulkErase18Fx 'ERASES everything but CONFIGW are set to DEFAULT VALUES
                    'Erases Program mem even if CP=1
                    'and erases Data mem even if CPD=1
cls
 LPT_Form.FontSize = 14
 Print "Bulk Erase Completed"
 
Call FindLastAddr
 
Print "Programming from 0 to "; LastAddr; "Started ": T = Timer
 U = 0: H = 0: L = 0
                   
 Dim N As Integer
 Ju = 0
Do While Ju < LastAddr
        IsBlank = True
       
        For L1 = Ju To Ju + 31
           If Pdm(L1) <> &HFFFF Then IsBlank = False: Exit For
        Next
        If (IsBlank = True) Then
           L = L + 32
           If (L = 256) Then
             H = H + 1
             L = 0
           End If
           Ju = Ju + 32
           GoTo SkipBlanks
        End If

        N = 0
        DW = &H8EA6: Call CID16 'Configures ECON1 register to Enable Programming
        DW = &H9CA6: Call CID16 'CFGS set to Program Flash or IDs
        DW = &H84A6: Call CID16 'WREN write enable enabled
       
        DW = &HE00 + U: Call CID16 'Set Table Ptr Regs
        DW = &H6EF8: Call CID16 'writes &H20 to TBLPTRU
        DW = &HE00 + H: Call CID16
        DW = &H6EF7: Call CID16 'Writes  &H0 to TBLPTRH
        DW = &HE00 + L: Call CID16
        DW = &H6EF6: Call CID16 'Writes  &H0 to TBLPTRL
   
Again: 'Loop to fill 64-byte write buffer with 32 Pdm() words
       Call W2HiLoBytesInc2 'Cmd 1101 Table Buffer Writes 2 bytes with post Inc 2
       Ju = Ju + 1
       N = N + 2
       If N = 62 Then
         Call Pgm64Bytes18F 'Writes last 2 bytes and starts programming
         N = 0: Ju = Ju + 1
       Else
         GoTo Again
       End If
       L = L + 32
       If (L = 256) Then
         H = H + 1
         L = 0
       End If

SkipBlanks:
Loop
                   
ExitPgm18F:
Print "Last Address Programmed: "; LastAddr
Print "Programming of "; PgmCodeSize; " Bytes Completed in ";
Print Format(Timer - T, "###.# Seconds.")
 
 mSec = 1:  Call Dly1

End Sub
'========================================================================================
Private Sub Pgm64Bytes18F() 'Writes last 2 bytes and starts programming
 ' Special NOP(0000) holds 4th data bit high for Pgm Time(3mS) and then Lo=200uS
   DW = Pdm(Ju)
   
   CW = &H15: Out P, CW:   ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW    ' Clock Hi, Data Hi, Vpgm=VpgmHi
   
   CW = &H15: Out P, CW:   ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 0=1 cmd clk'd in

   CW = &H14: Out P, CW    ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW:   ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 1=1 cmd clk'd in
   
   CW = &H14: Out P, CW    ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW:   ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 2=1 cmd clk'd in
   
   CW = &H14: Out P, CW    ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW:   ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 3=1 cmd clk'd, Cmd 1111 StartWrite clk'd in
   
   CW = &H1D: Out P, CW    ' Clock Lo, Data Lo, Vpgm=VpgmHi 'resets Clk and Data, ready for next instruction/data bits

  Dim Bit As Integer
  For Bit = 0 To 15         ' Clocks in 16-bits of Payload data LSB First
   If (2 ^ Bit) And DW Then ' Clock in a 1
     CW = &H1E: Out P, CW   ' Clock Hi, Data Lo, Vpgm=VpgmHi
     CW = &H14: Out P, CW   ' Clock Hi, Data Hi, Vpgm=VpgmHi
     CW = &H15: Out P, CW   ' Clock Lo, Data Hi, Vpgm=VpgmHi bit Bit bit=1 of DW  clk'd in
     CW = &H1D: Out P, CW   ' Clock Lo, Data Lo, Vpgm=VpgmHi 'resets Clk and Data, ready for next instruction/data bits
     
   Else 'Clk in a 0
     CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
     CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi  Bit bit =0 of DW  clk'd in
   End If
  Next Bit
                        ' 0000  Special NOP that starts programming the ID bits on 4th bit
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 1=0 cmd entered
   
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 2=0 cmd clk'd in
   
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 3=0 cmd clk'd in
   
   CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi PROGRAMMING of ID bits Starts
   mSec = 3: Call Dly1 ' Tprog  for StartWrite must wait TDelay5=P9  with Clock held hi for programming to complete
                                    '30mSec exceeds spec P9 wait spec=1mSec.. wait extended for debugging tests
   CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi wait time starts with 'bit 4=0 Cmd=0000 clk'd in.
                                         
   mSec = 1: Call Dly1 ' (P10 Clk Lo must wait =TDly6 is Spec'd at 200uSec Minimum), wait  extended for debugging test
   ' Now clock in NOP Payload = 0
   For Bit = 0 To 15      ' Clocks in 16-bits of Payload data LSB First
     CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
     CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi bit B of DW  0 clk'd in
   Next Bit
End Sub
'======================================================================================
Private Sub W2HiLoBytesInc2()
  'Cmd 1101
   DW = Pdm(Ju)
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 0=1 cmd clk'd in
 
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
   CW = &H1E: Out P, CW  ' Clock Hi, Data Lo, Vpgm=VpgmHi
   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi 'bit 1=0 cmd clk'd in

   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 2=1 cmd clk'd in
   
   CW = &H14: Out P, CW  ' Clock Hi, Data Hi, Vpgm=VpgmHi
   CW = &H15: Out P, CW: ' Clock Lo, Data Hi, Vpgm=VpgmHi 'bit 3=1 cmd clk'd in

   CW = &H1D: Out P, CW  ' Clock Lo, Data Lo, Vpgm=VpgmHi
   
   'clock into buffer two bytes
   Dim Bit As Integer
   For Bit = 0 To 15         ' Clocks in 8-bits of Lo-Byte Payload data LSb First
        If (2 ^ Bit) And DW Then ' Clock in a 1
          CW = &H1E: Out P, CW   ' Clock Hi, Data Lo, Vpgm=VpgmHi
          CW = &H14: Out P, CW   ' Clock Hi, Data Hi, Vpgm=VpgmHi
          CW = &H15: Out P, CW   ' Clock Lo, Data Hi, Vpgm=VpgmHi bit Bit of DW = 1 clk'd in
          CW = &H1D: Out P, CW   ' Clock Lo, Data Lo, Vpgm=VpgmHi 'resets Clk and Data, ready for next instruction/data bits
        Else 'Clk in a 0
          CW = &H1E: Out P, CW ' Clock Hi, Data Lo, Vpgm=VpgmHi
          CW = &H1D: Out P, CW ' Clock Lo, Data Lo, Vpgm=VpgmHi bit Bit of DW=0 clk'd in
        End If
   Next Bit
End Sub
'========================================================================================
Private Sub FindLastAddr()
LastAddr = 0
For J = 65535 To 0 Step -1
  If Pdm(J) <> &HFFFF Then LastAddr = J + 1: Exit For
Next
'If LastAddr > &H7FFF Then LastAddr = &H7FFF 'later a problem with 64KB Chip??
End Sub
« Last Edit: June 07, 2015, 08:30:24 am by SuzyC »
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #45 on: June 07, 2015, 03:31:58 am »
BTW: Can anyone tell me how long it takes a real PICKIT3 or clone to write and verify, fully stuff 32KB of code into a PIC18F25K22 or similar?

« Last Edit: June 07, 2015, 03:47:02 am by SuzyC »
 

Offline android

  • Regular Contributor
  • *
  • Posts: 134
  • Country: au
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #46 on: June 07, 2015, 04:21:54 am »
I just programmed and verified the following code (which uses all 32768 bytes of ROM) into a PIC18F25K50 ...took just under 17 seconds with a MikroProg programmer:
Code: [Select]
const char FIXED[32722] = "A";

void main()
{
  const char * p = &FIXED[0];
}
Hex file attached.

I'll try with a PICKIT3...but I don't usually use that so I'll need to set it up.
Lecturer: "There is no language in which a double positive implies a negative."
Student:  "Yeah...right."
 

Offline android

  • Regular Contributor
  • *
  • Posts: 134
  • Country: au
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #47 on: June 07, 2015, 07:53:07 am »
Ok, finally got a PicKit3 working with MPLABX again...
Source...
Code: [Select]
#include <stdio.h>
#include <stdlib.h>
const char FIXED[30718] = "A";
/*
 *
 */
int main(int argc, char** argv)
{
    const char * p = &FIXED[0];
    p++;
    return (EXIT_SUCCESS);
}
Programming messages...
Code: [Select]
Connecting to MPLAB PICkit 3...

Currently loaded firmware on PICkit 3
Firmware Suite Version.....01.37.15
Firmware type..............PIC18F

Programmer to target power is enabled - VDD = 4.750000 volts.
Target device PIC18F25K50 found.
Device ID Revision = 1

The following memory area(s) will be programmed:
program memory: start address = 0x0, end address = 0x7fff
configuration memory

Device Erased...

Programming...
Programming/Verify complete

...took just under 10 seconds.


Hex file birds eye view png attached FWIW (the csv file was 59 MB so I couldn't attach it).
Lecturer: "There is no language in which a double positive implies a negative."
Student:  "Yeah...right."
 

Offline SuzyCTopic starter

  • Frequent Contributor
  • **
  • Posts: 792
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #48 on: June 07, 2015, 08:25:31 am »
That's about the same time it takes to "program/verify" on my faster PC with my  QB program. On my 486 2.8GHz the total process takes 16.2 seconds, but waiting just a few seconds doesn't tax my patience.

Interesting, the Vdd=4.75 with the PICKIT3, this violates the programming specsheet  Max Vihh <= 9V with Vihh =Vdd+4.5 =9.25V.

At the same time, programming these chips with 11V (Absolute Max V Spec for Vpgm pin 1) at 5V Vdd doesn't seem to harm these chips at all, but time will tell if I need to do a HW modification to set Vihh lower.
« Last Edit: June 16, 2015, 01:23:55 pm by SuzyC »
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8264
Re: Help!!! Why Can't I Program My PIC18F25K22 ID's ????
« Reply #49 on: June 07, 2015, 03:20:06 pm »
I can do the same thing with IDs programming, now works perfect, except my word!, everything is bit too all one-ish in  programming results.

I have everything working now except the code flash programming.
What was the problem?

Yes it appears the PICKIT3 is using a slightly lower difference between Vdd and Vihh, but there are tolerances in these and it makes sense for the programming specs to be on the conservative side.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf