> What about having a programmer automatically determine the best > value to use whenever an EPROM device is programmed. It would > only cost 7 words of code space from $1F8 to $1FE or $3F8 to > $3FE to burn the test program, and it would then eliminate the > need to worry about the calibration constant. I've posted this > idea before but not had time to implement it. Has anyone else > tried it? |I haven't and I'm interested. Could you explain a little bit ? Does the |programmer have to be able to turn on the chip in normal operation mode |and read out a pin ? You'd need to be able to start/run the PIC normally. Note that since you'd be testing the calibration before burning the fuse to disable /MClr, you could use /MClr L->VPP to re-enter program mode. The code I'd recommend using would be this [at $1F9 or $3F9] movlw 127 xorlw 255 movwf 5 movlw 254 ; Bit 0 is only output tris PORTB comf PORTB Running this code will cause the PORTB.0 pin to flip every 512 or 1024 cycles. Start with the code as above, and the modify it per the following algorithm: if oscillator was too fast, blow bit 7 of the xorlw blow bit 6 of the first movlw instruction if oscillator was too fast, blow bit 6 of the xorlw blow bit 5 of the first movlw instruction if oscillator was too fast, blow bit 5 of the xorlw blow bit 4 of the first movlw instruction if oscillator was too fast, blow bit 4 of the xorlw ; Note that for the original '508's you may stop here. If you ; want to allow for an 8-bit calibration constant, you may keep ; going... blow bit 3 of the first movlw instruction if oscillator was too fast, blow bit 3 of the xorlw blow bit 2 of the first movlw instruction if oscillator was too fast, blow bit 2 of the xorlw blow bit 1 of the first movlw instruction if oscillator was too fast, blow bit 1 of the xorlw blow bit 0 of the first movlw instruction if oscillator was too fast, blow bit 0 of the xorlw Once that's accomplished, determine which of the last two speeds was the best; use that speed as the calibration value. Cute, eh?