I thought vectors are DWords and not Bytes?
--- In lpc2000@yahoogroups.com, "carlosahsilva" <carlosahsilva@t...>
wrote:
>
> I have made some tests on the Program CheckSum generated by IAR
> compiler and there is realy something fish.
>
> First I edited the segmentation to place the CheckSum as first
byte
> after the end of my code:
> -------------------------------------------------------------------
--
> ?CHECKSUM CHECKSUM __checksum 00037FFF
> Program Relative
> module segment
> 00037FFF -
> 00037FFF
> Segment part 1.
> ROOT.
> -------------------------------------------------------------------
-
>
> The IAR compiler informed me the value and calculation range
> -------------------------------------------------------------------
---
> Checksums
>
> Symbol Checksum Memory Start End
> __checksum 0xcc CODE 00000000 - 00037FFE
>
> -------------------------------------------------------------------
----
>
> I selected the simple checksum (not any CRC) and wrote the code
below
> to test it
>
> /*-----------------------------------------------------------------
> CheckSum calculation routine
> -----------------------------------------------------------------*/
> void CalcCheckSum(void)
> {
> unsigned char *pby;
> unsigned char *pCksGen;
> unsigned char CksGen;
> char STRCksCalc[] = "AAAAAAAAAAAAAAAAA";
> char STRCksGen[] = "AAAAAAAAAAAAAAAA";
>
> // Indicate start of the calculation
> UART_PutStringByPolling (UART0, "\n\rCalculation
Start.\n\r"); /**/
> UART_PutStringByPolling (UART0, "\n\r\n\r");
>
> // Point to Address 0x00000000
> pby = (unsigned char *)0x00000000;
> // Start the Sum with zero
> unsigned char ValCheckSum = 0;
> // Sum all bytes between 0x00000000 and 0x00037FFF.
> for (long byte = 0; byte < 0x00037FFF-0x00000000; byte++) {
> // Read a byte and sum it
> ValCheckSum += *pby;
> // Increment pointer
> pby++;
> }
>
> // Indicates the end of the calculation
> UART_PutStringByPolling (UART0, "\n\rCalculation
End.\n\r"); /**/
>
> // Get the value of the CheckSum stored in the firmware
> pCksGen = (unsigned char *)0x00037FFF;
> CksGen = *pCksGen;
>
> // Transform both values in string
> sprintf (STRCksCalc, "%x", ValCheckSum);
> sprintf (STRCksGen, "%x", CksGen);
> // Send the Vavlues by the serial
> UART_PutStringByPolling (UART0, "\n\r\n\r");
> UART_PutStringByPolling(UART0, STRCksCalc);
> UART_PutStringByPolling (UART0, "\n\r\n\r");
> UART_PutStringByPolling(UART0, STRCksGen);
> UART_PutStringByPolling (UART0, "\n\r\n\r");
> }
>
> How ever when I runned the code the genarate value and calculated
> values are different:
>
> ==============================================================
> Calculation Start.
>
> Calculation End.
>
> 22 - Calculated
> cc - Generated by the compiler
> ===============================================================
>
> Does any one call tell me what I do wrong or provide me a sample?
>
> Thanks
>Message
Re: Checksum Problem Part B
2006-01-11 by unity0724
Attachments
- No local attachments were found for this message.