This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

[参考译文] MSP432E401Y:匹配 MSP432E401Y 上生成的硬件 CRC16 CCITT 与 MSP430FR5739 16位硬件 CRC-CCITT-BR

Guru**** 2386620 points
Other Parts Discussed in Thread: MSP430FR5739, MSP432E401Y
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1162716/msp432e401y-matching-hardware-crc16-ccitt-generated-on-msp432e401y-to-msp430fr5739-16-bit-hardware-crc-ccitt-br

器件型号:MSP432E401Y
主题中讨论的其他器件:MSP430FR5739

尊敬的 TI 专家:  

我正在 MSP432E401Y 和 MSP430FR5739之间建立通信协议、这需要生成16位硬件 CRC。 我正在使用 MSP432和 MSP430上的驱动程序库与每个 CRC 驱动程序进行连接、以生成16位 CRC。 驱动器的数据输入一次为1字节(unsigned char 或 uint8_t 类型)。

MSP432有多种 CRC 标准可供选择、但最接近 MSP430的是 CCITT 选项。 MSP430具有16位 CRC-CCITT-BR (BR=字节反转?) 标准(无法更改)、因此与 MSP432不完全相同。

下面是我正在关注的 MSP432E401Y 示例、经过修改后显示了我的 CRC 配置和输入的参数。 我为其创建校验和的数据也是相同的。 CRC16结果 =无符号短整型11111101110100b (二进制)  

/*
 *  ======== crc.c ========
 */
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>

/* Driver Header files */
#include <ti/drivers/CRC.h>

/* Driver configuration */
#include "ti_drivers_config.h"

/* Expected CRC for CRC_32_IEEE with full endianness reversal */
static const uint32_t expectedCrc = 0x4C4B4461;

/* Example test vector */
static const size_t srcSize = 3;
static const uint8_t src [] = {
    0x02,0x08,0x01
};


/* ======== mainThread ======== */
void *mainThread(void *arg0)
{
    int_fast16_t status;
    uint16_t result;

    CRC_Handle handle;
    CRC_Params params;

    /* Initialize the drivers */
    CRC_init();

    /* Set data processing options, including endianness control */
    CRC_Params_init(&params);
    params.byteSwapInput = CRC_BYTESWAP_UNCHANGED;
    params.returnBehavior = CRC_RETURN_BEHAVIOR_BLOCKING;
    params.polynomial = CRC_POLYNOMIAL_CRC_16_CCITT;
    params.dataSize = CRC_DATA_SIZE_8BIT;
    params.seed = 0xFFFF;

    /* Open the driver using the settings above */
    handle = CRC_open(CONFIG_CRC_0, &params);
    if (handle == NULL)
    {
        /* If the handle is already open, execution will stop here */
        while(1);
    }

    /* Calculate the CRC of all 32 bytes in the source array */
    status = CRC_calculateFull(handle, src, srcSize, &result);
    if (status != CRC_STATUS_SUCCESS)
    {
        /* If the CRC engine is busy or if an error occurs execution will stop here */
        while(1);
    }

    /* Close the driver to allow other users to access this driver instance */
    CRC_close(handle);


    return NULL;
}

下面是我正在关注的 MSP430FR5739的示例代码、经过修改后显示了我的配置、参数和输入的数据。 生成的 CRC16  crcResult = unsigned int 1011011111011001b (二进制)  

#include "driverlib.h"

uint16_t crcResult;

void main (void)
{
    uint16_t crcSeed = 0xFFFF;
    uint8_t data[] = {0x02,
                           0x08,
                           0x01};

    uint8_t i;

    //Stop WDT
    WDT_A_hold(WDT_A_BASE);

    //Set P1.0 as an output
    GPIO_setAsOutputPin(
        GPIO_PORT_P1,
        GPIO_PIN0);

    //Set the CRC seed
    CRC_setSeed(CRC_BASE,
        crcSeed);

    for (i = 0; i < 5; i++)
    {
        //Add all of the values into the CRC signature
        CRC_set8BitDataReversed(CRC_BASE,
            data[i]);
    }

    //Save the current CRC signature checksum to be compared for later
    crcResult = CRC_getResult(CRC_BASE);

    //Enter LPM4, interrupts enabled
    __bis_SR_register(LPM4_bits);
    __no_operation();
}

我已经尝试在 MSP430上输入反转字节、希望在没有反转字节的情况下返回 CCITT 标准、因此我可以将其与 MSP432上的 CCITT CRC16标准匹配。 但是、我可能会实施这种错误。 可以有人告诉我如何修改 MSP430或 MSP432上的示例代码、以便我可以使用两个稍微不同的 CRC 标准匹配计算出的 CRC。

希望这可以通过使用这两个器件上的硬件 CRC 生成器来实现。 希望找到解决方案。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    [引用 userid="541001" URL"~/support/microcontrollers/arm-based-microcontrollers-group/arm-based-microcontrollers/f/arm-based-microcontrollers-forum/1162716/msp432e401y-matching-hardware-crc16-ccitt-generated-on-msp432e401y-to-msp430fr5739-16-bit-hardware-crc-ccitt-br ]MSP432有多种 CRC 标准可供选择、但最接近 MSP430的是 CCITT 选项。 MSP430具有16位 CRC-CCITT-BR (BR=字节反转?) 标准(无法更改)、因此与 MSP432不完全相同。[/quot]

    CRC 多项式必须在两者之间相同、并且流入的数据顺序必须相同、才能生成相同的结果。 只有微小的差异才能产生完全不同的校验和。 我不熟悉 MSP430器件。 您将需要打开一个新的 TT、为器件型号指定 MSP430、以便那里的专家可以帮助您处理字节反向排序问题。 我发现此 MSP 应用手册可能也很有用。  https://www.ti.com/lit/pdf/slaa221。

     您还可以使用在线 CRC 计算器生成校验和、并与硬件生成的校验和进行比较。  https://crccalc.com/

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    感谢您的告知。 我在 MSP430器件型号下提出了一个新问题。 请告诉我是否应该删除此帖子。

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

     将帖子保留在这里没有问题。  

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Charles、我已经对此进行了进一步调查、发现该问题专门出现在 MSP432上。 我在这里开了一个新的 TT (2) MSP432E401Y:用于16位 CCITT 标准 的硬件 CRC 始终具有用于高字节的0xFF -基于 Arm 的微控制器论坛-基于 Arm 的微控制器- TI E2E 支持论坛及具体内容。 也许您可能知道我为什么会遇到这个问题?

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Parryh、

     我将回复您的新帖子并关闭此帖子。