PIC "Begin Erase/End Programming" question

Status
Not open for further replies.

If it's any help?, here's the routine from WinPicProg that writes 14 bits out, notice that I don't consider it a 16 bit word, but just send clock pulses before and after.

Code:
Procedure OutWord(Data : Word);
Var
  x,
  BitPos : Word;
Begin
  ClockPulse(DLow);
  BitPos := 1;
  For x := 0 To 13 Do
  Begin
    IF (Data AND BitPos) = BitPos THEN
      ClockPulse(DHigh)
    ELSE
      ClockPulse(DLow);
    BitPos := BitPos Shl 1;
  End;
  ClockPulse(DLow);
End;
 
Thanks for the code post. My write routine actually seems to be ok. It's my read routine I'm suspicious of.

Good point about the 14-bit vs. 16-bit consideration. I guess I'm using the 16-bit mentality because that's how the hex file is constructed. They're all 16-bit values with 0's always as the first and last bit. But I might rewrite my code to think of it as a padded 14-bit word instead.
 
Rusttree said:
I guess I'm using the 16-bit mentality because that's how the hex file is constructed. They're all 16-bit values with 0's always as the first and last bit.

I didn't think so?, I thought they were aligned at one end? - although I must admit it's been MANY years since I wrote the routines.
 
Well, you inadvertantly solved my problem. By having the logic treat the read as a 16-bit value instead of a 14-bit value with 2 extra clock cycles, I wasn't paying close enough attention to the 1st and 16th clock cycle during the read. After I rewrote my code, I realized the data pin was being inappropriately latched during the clock cycle. Still not 100% sure why that caused the problem, but by forcing the data pin low during the 1st and 16th clock cycles, it solved my problem.

Thanks Nigel!
 

It needs to be low, I can't remember why? - it's over ten years ago since I wrote the basic routines! (under DOS then).
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…