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

Code for Checksum

I am working on this PLM51 code written for 80552 written many years ago.I am basically trying to re-write the whole code in embedded c using Keil.The statement given below is part of PLM51 code that deals with checksum error detection method.

DECLARE MEM$PTR WORD IDATA; /* Variables used for EPROM test */
DECLARE MEM$VAL BASED MEM$PTR BYTE CONSTANT;
DECLARE CONTROL1 WORD AT (7FFEH) CONSTANT (0FFFFH); /* checksum Eprom */
DECLARE CHECK WORD IDATA;

DO MEM$PTR=0H TO 7FFDH; CHECK=CHECK+MEM$VAL; END; CHECK=CHECK+0FFH+0FFH;/* sum last 2 bytes */ IF CHECK<>CONTROL1 THEN DO; INITIAL$ERROR=90; END;

Can someone PLEASEEEE interpret the statements above to convert to C..Else can anyone suggest a method to program checksum error detection method in embedded C.

Kat

Parents
  • Thankyou so much for the help..!!
    I have written my code in Keil as below.

    code unsigned char MEM_VAL;
    unsigned int idata *MEM_PTR = &MEM_VAL; //Warning 259:Pointer:Different Memory Space
    code unsigned int CONTROL1 _at_ 0x7FFE = 0xFFFF ; // Error 274:Absolute Specifier illegal
    unsigned int idata CHECK;
    INITIAL_ERROR=0;
    CHECK=0;
    MEM_PTR=0;
    for(MEM_PTR=0x0000;MEM_PTR<=0x7FFD;MEM_PTR++) { CHECK=CHECK+MEM_VAL; }
    CHECK=CHECK+0x0FF+0x0FF;
    if(CHECK!=CONTROL1) { INITIAL_ERROR=90; }

    Is it possible to initialise a "absolute" variable declared in code memory (CONTROL1) ?Pleasee look through the error in my code...!!

    Thanks.

Reply
  • Thankyou so much for the help..!!
    I have written my code in Keil as below.

    code unsigned char MEM_VAL;
    unsigned int idata *MEM_PTR = &MEM_VAL; //Warning 259:Pointer:Different Memory Space
    code unsigned int CONTROL1 _at_ 0x7FFE = 0xFFFF ; // Error 274:Absolute Specifier illegal
    unsigned int idata CHECK;
    INITIAL_ERROR=0;
    CHECK=0;
    MEM_PTR=0;
    for(MEM_PTR=0x0000;MEM_PTR<=0x7FFD;MEM_PTR++) { CHECK=CHECK+MEM_VAL; }
    CHECK=CHECK+0x0FF+0x0FF;
    if(CHECK!=CONTROL1) { INITIAL_ERROR=90; }

    Is it possible to initialise a "absolute" variable declared in code memory (CONTROL1) ?Pleasee look through the error in my code...!!

    Thanks.

Children
No data