MSP430 Prüfsumme

Gast #4221739
Lesenswert?

Hallo zusammen,

ich möchte von einem Array eine Prüfsumme berechnen. Von Seitens TI gibt 
es dazu folgende Software Funktion:
1
uint16_t Calc_App_CRC(uint16_t * Addr_array, uint16_t *Size_array, uint8_t ** DataPtr_Array, uint8_t num_arrays)
2
{
3
    uint16_t addr;
4
    uint8_t i;
5
    uint16_t CRC_result = 0xFFFF;
6

7
    // Calculate CRC for the whole Application address range
8
    for (addr=App_StartAddress; addr <= App_EndAddress; addr++)
9
    {
10
        for (i = 0; i < num_arrays; i ++)
11
        {
12
            // Check if address is defined by application image
13
            if ( (addr >= Addr_array[i]) &&
14
                 (addr < (Addr_array[i] + Size_array[i])) )
15
            {
16
                // If address is defined, add it to the CRC
17
                crc16AddByte(DataPtr_Array[i][addr-Addr_array[i]],&CRC_result);
18
                break;
19
            }
20
        }
21
        if (i==num_arrays)
22
        {
23
            // If not, simply add 0xFF
24
            crc16AddByte(0xFF,&CRC_result);
25
        }
26
    }
27

28
    return CRC_result;
29
}

Da mein MSP430FR5739 aber ein CRC module besitzt, möchte ich dieses 
nutzen. Initialsiiert habe ich es so:
1
       // initializes CRC with seed, depends on CRC version
2
       CRCINIRES = 0xFF;
3

4
       // write each word to input register
5
       for(i = 0; i < (t_arr -1); ++i)
6
       {
7
         CRCDI = t_arr[i];
8
       }
9

10
       // reads CRC result
11
       CRC= CRCINIRES;

Der CRC der Funktion stimmt leider nicht mit dem des Moduls überein.

Hat Jemand einen Denkanstoß für mich?

Viele Grüße,
Newbie
Gast #4221761
Lesenswert?

Hallo,

danke für die schnellen Antworten.

> Dann ist die initiale Zuweisung CRCINIRES = 0xFF; falsch.
Müsste Sie dann nicht 0xFFFF sein, wie in der von Ti verwendeten 
Funktion auch?


> Ich vermute ebenfalls, dein CRC modul ist 8 bittig.
Laut Datenblatt 16 bittig.

Antwort schreiben

Bitte melde dich an, um einen Beitrag zu schreiben.

oder

Mit Google-Account einloggen

Die Registrierung ist kostenlos und dauert nur eine Minute.

Jetzt registrieren