PDA

View Full Version : Code verify on 12F683



swr999
- 10th October 2014, 01:40
Hello all!

I haven't had any luck searching on this topic. I have a RBPro 2.50A program running on a 12F683. Program runs fine. I want to add a short section of code at the top of the program which would do a code integrity check, to try and verify that the program code got loaded correctly, and check that nothing has changed. Could be a full CRC check or maybe a quick and dirty (cheap and cheerful) summation. The PB Pro instruction to do this should be the READCODE instruction. However this instruction does not work on the 12F683.

Here's my program:

'============================
sum VAR WORD
rslt VAR WORD
i VAR WORD

sum=0
FOR i=0 to 2047
READCODE i, rslt
sum=sum+rslt
NEXT I
IF rslt != $3DF5 THEN STOP
'============================

At compile time this code produces:

Error READCODE.ASM 51:[225] undefined symbol 'eeadrh'
Error READCODE.ASM 51:[225] undefined symbol 'eedath'
Error READCODE.ASM 51:[212] extra tokens on end of line

I'm not concerned about the meaning of the error messages, just the fact that READCODE does not compile for the 12F683. The code shown here compiles fine on a 16F877.

So, my Question:
Does anyone have any ideas on how to read program memory in the 12F683 (or any other 12F part)?

Thanks in advance for any suggestions!

richard
- 10th October 2014, 02:23
12f683 has no
• EEDATH
• EEADRH
registers and cannot read the flash pgm memory , along with many other chips


from the manual




READCODE


Read the value at location Address in code space into Var. Some PIC16F and
PIC18 devices allow program code to be read at run-time. This may be useful for
additional data storage or to verify the validity of the program code. For PIC16F
devices, 14-bit-sized data can be read from word code space Addresses

rsocor01
- 10th October 2014, 05:41
Some programmers like for example my U2 USB Programmer have a verification routine after writing the program in the chip. You might want to use that feature that has already been created for you. Easier for you and no headaches :).

swr999
- 10th October 2014, 18:31
Some programmers like for example my U2 USB Programmer have a verification routine after writing the program in the chip...
Thanks. This would be fine for one or a few instances. In my case a PCB assembler will be gang-programming many chips. Plus, once out in the field I would like the program to not run at all if, whenever it powers up, the code validation fails. Any suggestions for a similar 8-pin chip which does allow to read out of program memory? Or some other way to do code validation?

Thanks!

swr999
- 10th October 2014, 19:36
Actually, a partial answer to my own question. Turns out that some of the 12(L)F1xxx family parts are available in 8-pin packages and have self-programming capability. However, for use with meLabs PIC Basic you need the PBP3 compiler. However, I'm still searching for a way to do code validation on the 12F683.
Any more ideas?? Thanks!

rsocor01
- 10th October 2014, 20:51
Thanks. This would be fine for one or a few instances. In my case a PCB assembler will be gang-programming many chips. Plus, once out in the field I would like the program to not run at all if, whenever it powers up, the code validation fails. Any suggestions for a similar 8-pin chip which does allow to read out of program memory? Or some other way to do code validation?

Thanks!

If you are programming the chips at the factory in Thailand, they use CRC error checking. If you are using somebody else, do you mind me asking how are they "gang-programming" the chips? There have been a few people asking in this forum how to "gang-program" many chips, but I don't think that they never got a satisfying answer.

Robert

swr999
- 11th October 2014, 01:09
... do you mind me asking how are they "gang-programming" the chips? ...
Robert
I may be using the wrong terminology. All I meant was that I send the hex code along with the gerbers and BOM and the assembly house includes loading the chips with my hex code as part of the assembly cost. But I don't know how they do it. But in addition to error-checking the initial loading of the hex code, I also want to re-validate the program memory space on each power-up and have the code not run if the code is not validated. I believe I can do this if I switch to a part like the 12F1xxx family.