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
Declare an unsigned char pointer for code memory.
Iterate between address 0 and 0x7ffd (inclusive) and add to a 16-bit variable. Add 0xff two times more, and then compare with the value stored at 0x7ffe,0x7fff.
The question here is if PLM51 is using the same byte order for 16-bit values as Keil C51, to make sure that the comparison with the stored checksum will match.
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.