PDA

View Full Version : Reading code ROM



markk5xh
- 20th February 2008, 19:00
Hello all,

Is it possible to read the code space ROM of a PIC (using PicBasic) and produce a CRC value for the code? If so, does anyone have any hints on how to generate a CRC 16 on the data?
I see the PEEKCODE instruction in the book but I'm a bit confused as to how to use it in practice.

Thanks

Charles Linquis
- 20th February 2008, 20:14
READCODE works.

If your chip is larger than 64K bytes, and you are using any version of PBP before 2.50, you will either have to modify your libraries or use an ASM routine to read the memory above 655535.

If you are using PBP 2.50 (and PBPL) you can read the whole chip using READCODE even if it is a > 64K device.

markk5xh
- 21st February 2008, 15:29
Thanks Charles. I got the book out and found the READCODE command. I've never used that one and had missed it when I was looking through the book yesterday. Now I need to figure out how to produce a CRC value for the code space. Thanks again.

Charles Linquis
- 21st February 2008, 22:51
There are several CRC16 examples on the forum. One of them should be usable for your application. For verifying code, I usually do just a checksum - sum all the bytes into one 16 bit word. It is fast and is usually good enough.

skimask
- 21st February 2008, 23:18
Thanks Charles. I got the book out and found the READCODE command. I've never used that one and had missed it when I was looking through the book yesterday. Now I need to figure out how to produce a CRC value for the code space. Thanks again.

Are you trying to read your own code and produce your own CRC or what?

markk5xh
- 22nd February 2008, 22:01
Yes, my code.
I'm looking at a project that requires the software/firmware to meet a U.L. spec. One of the requirements is that the program code must be verified in some way. What the spec calls for is either a "single word" CRC or a "double word" CRC. Their use of the word "word" is a bit confusing as they seems to mean 8 bits and not 16. After reading through the spec (300+ pages) I'm not even sure that a PIC can be used in such a project.
Thanks for your input.
Mark

skimask
- 23rd February 2008, 00:40
Yes, my code.
I'm looking at a project that requires the software/firmware to meet a U.L. spec. One of the requirements is that the program code must be verified in some way. What the spec calls for is either a "single word" CRC or a "double word" CRC. Their use of the word "word" is a bit confusing as they seems to mean 8 bits and not 16. After reading through the spec (300+ pages) I'm not even sure that a PIC can be used in such a project.
Thanks for your input.
Mark

Simple idea, , yet probably not so practical...???
Read your own PIC code, and compare it word for word against an external EEPROM burned with the same code...

markk5xh
- 25th February 2008, 14:09
Actually this is one of the methods that is discribed in the UL documents. I agree that it might not be the best way. Thanks for the input.