Reading code ROM


Closed Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Nov 2007
    Posts
    9

    Default Reading code ROM

    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

  2. #2
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  3. #3
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    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.

  4. #4
    Join Date
    Sep 2005
    Location
    Campbell, CA
    Posts
    1,107


    Did you find this post helpful? Yes | No

    Default

    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.
    Charles Linquist

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by markk5xh View Post
    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?

  6. #6
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    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

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by markk5xh View Post
    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...

  8. #8
    Join Date
    Nov 2007
    Posts
    9


    Did you find this post helpful? Yes | No

    Default

    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.

Similar Threads

  1. Problem runing my code
    By Mus.me in forum mel PIC BASIC Pro
    Replies: 33
    Last Post: - 1st December 2009, 20:36
  2. Simple LCD code not working!...WHY?
    By jellis00 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 29th November 2009, 19:48
  3. 16F to 18F transition pains
    By lurker in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2008, 01:35
  4. Code to control 4 LEDs and 2 servos
    By The Master in forum Off Topic
    Replies: 2
    Last Post: - 26th November 2008, 13:33
  5. one wire
    By karenhornby in forum General
    Replies: 7
    Last Post: - 18th June 2008, 20:24

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts