You wrote: >I am having [a problem] with a PIC16C57 program that works in the >EPROM part but doesn't work in the OTP part. .... Microchip >and others recommend that the FSR and status registers >be cleared just after the ORG statement. > .... >Now, someone was nice enough to send me some code written >by Fast Forward Engineering that was entitled "ZERO THE >16C57 RAM", however, in the code comments, they say "prepare >to zero all registers except the processor status, pc, rtcc, >and fsr registers." Why wouldn't you want to clear the FSR >and STATUS? Is the best solution to include the "zero ram" >code just after the ORG 0 statement and just before the CLRF FSR >statement in the listing above? Or, do I just leave out the >two CLRF statements all together? Should this ram clearing >procedure be included in all code just in case someone wants >to go to OTP parts? Dave: The STATUS bits that select the Code-Space page are cleared for you by the RESET hardware in the PIC (which is why the GOTO at the 16C57's Reset Vector [0x7FF] must point to an address on page 0, by the way). The FSR bits that select the Data-Space (Register) bank are also cleared by the RESET hardware, and, if you look closely at my "Clear the 16C57 RAM" code, you'll see that it leaves them cleared. I don't understand why Microchip would recommend that you manually clear these bits, especially since the "PICs are afraid of the light" problem is so well-known. If you haven't heard of this before, it's simple: When light impinges on the silicon die in a windowed PIC, it usually clears the registers to 00 on RESET. On the other hand, if the window is covered (or the PIC is a non-windowed OTP device), the registers come up in undefined states. The fact that your code works only when the window's uncovered means that you're reading from registers before you write to them. This may be what you intended, or it may mean that there are errors in your code. Either way, you should add a manual "Clear RAM" routine to your program. This is a bit tricky to do on a 16C57; that's why I posted my routine here. Put it early in your code, before you read from any general-purpose registers. There is no need for the CLRF FSR and CLRF STATUS instructions; aside from being pointless, this makes it impossible to tell whether your last reset was due to Power-On, MCLR, or Watchdog Timeout. Remove them from your code and tell the Microchip guy who suggested them to get a fucking clue. -Andy P.S. You don't have to use those exact words. -- Andrew Warren - fastfwd@ix.netcom.com Fast Forward Engineering, Vista, California