Other Parts Discussed in Thread: MSP432E401Y
Hi TI Experts,
I am working on a communication protocol between the MSP432E401Y and the MSP430FR5739, which requires 16-bit hardware CRC generation. I am using the driver libraries on both the MSP432 and the MSP430 to interface with each CRC driver to generate a 16-bit CRC. Data input to the drivers is 1 byte at a time (unsigned char or uint8_t type).
The MSP432 has several CRC standards to choose from, but the closest to the MSP430 is the CCITT option. The MSP430 has the 16-bit CRC-CCITT-BR (BR=byte reversed?) standard (cannot be changed), so it is not exactly the same as the MSP432.
Below is the example for the MSP432E401Y I am following, modified to show my CRC configuration and parameters entered. The data I am creating the checksum for is also the same. The CRC16 result = unsigned short 1111111101110100b (Binary)
/*
* ======== 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(¶ms);
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, ¶ms);
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;
}
Below is the example code for the MSP430FR5739 I am following, modified to show my configuration, parameters and data entered. The resulting CRC16 crcResult = unsigned int 1011011111011001b (Binary)
#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();
}
I have attempted to enter the reversed byte on the MSP430, hoping to get back the CCITT standard without reversed bytes, so I can match it to the CCITT CRC16 standard on the MSP432. However, I may be implementing this wrong. Can someone please show me how I can modify this example code on the MSP430 or the MSP432, so I can match the calculated CRC on the two devices.
Hope this is possible using the hardware CRC generators on these two devices. Looking forward to a solution.