The 18F452 data sheets states (19.4.1): "In user mode, the CPn bits have no direct effect. CPn bits inhibit external reads and writes." The data sheet then goes on to talk about how program flash can be protected against internal read and write using the WRTn and EBTRn bits. To test the effect of the CPn bits, I wrote a piece of code that blinks a light. If the code protect bits are turned off and I call the routine the light blinks. Just as expected. If I erase the area the code is in and call the routine the light does not blink. Just as expected. Now, if I turn on code protect (I leave table read and writes alone) and I call the code the light blinks. Just as expected. If I erase the block the code is in (code protect still on and table read/write still enabled) and call the routine the light still blinks -- telling me the erase did not work. Not what I expected. The erase code is modeled after example 5-2 in the data sheet and works just fine if code protect is not enabled. Again, I did nothing to inhibit table read / write. I was careful to understand what is being erased so this is not some funny side effect of erasing code unexpectedly. I use MPLAB to toggle the code protect bits before programming. Debug is always turned off and I use "Program" (not "Debug") to load the chip. What am I missing here? Should the erase with code protect on have worked? -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body