Please note: We are aware of an issue affecting replies on the Arm Community forums, which may not be loading as expected.

We apologize for any inconvenience and appreciate your patience while we investigate and work to resolve the issue.

Thank you for your understanding.


This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Checksum calculation example

Can you tell me, what does "unsigned char CODE *" mean in

checksum = calc_checksum ((unsigned char code *) 0, 0x4000);


from "csumex" Keil example.

My c166 compiler can't complile it.
What shall I do?

Parents Reply Children
  • Write:

    checksum = calc_checksum( (unsigned char *)0, 0x4000);
    

    Or if removing the code keyword from all places it might appear is too tedious for you:

    #define code
    

    Sauli

  • Hi again!

    It surely compiles. But I have found another pdf - apnt_142.pdf. The example program calculates the checksum of the NCODE memory class.

    #include <stdio.h> /* standard I/O .h-file */
    #include <reg167.h> /* special function register C167 */
    #include <srom.h> /* handling for SECTIONS and CLASSES */
    CLASS_INFO (NCODE) // get class info for NCODE class
    
    /*
    * Calculate Check Sum of NCODE memory class
    */
    
    static unsigned char chksum_ncode (void) {
    unsigned char huge *s;
    unsigned long l;
    unsigned char chksum;
    chksum = 0;
    
    s = CLASS_START (NCODE); // get start address of NCODE class
    l = CLASS_LEN (NCODE); // get length of NCODE class
    
    while (l)
    {
      chksum += *s++;
      l--;
    }
    
    return (chksum);
    
    }
    

    How do you think is it better to use this one or calculate checksum of ALL FLASH size (512 Kb)?

  • "is it better to use this one or calculate checksum of ALL FLASH "

    There is no answer to that.

    There is no such thing as "better" here - it's just a question of what you need to do!

    First, you need to clearly define your Requirement - then you can think about how to meet that requirement.

    Without knowing precisely what the Requirement is, it is impossible to say what is the "best" way to meet it!! :-0

  • HI Andy !

    I just need to check if programm codes in flash was not changed. I have found 2 examples - with all flash checksum (with trash) and only code section checksum (more compact). So I just ask what should I prefer. I have no precise Requirement.

    I have no experience in checksum calculation so I ask your opinion. My be someon can post ITS working example for 166. It will be nice :)