Synergy Software Package User's Manual
CRC Driver

CRC HAL Module Introduction

The CRC HAL module provides a high-level API to calculate 8, 16 and 32-bit CRC values on a block of data in memory or a stream of data over a Serial Communication Interface (SCI) channel using industry standard polynomials.

CRC HAL Module Features

  • CRC HAL module can calculate CRC on a block of data in memory.
  • CRC HAL module can calculate CRC on a stream of data being transmitted or received over a serial communication Interface (SCI) channel (snoop mode).
  • CRC HAL module supports the following 8-and 16-bit CRC polynomials which operates on 8-bit data in parallel
    • X8 + X2 + X + 1 (CRC-8)
    • X16 + X15 + X2 + 1 (CRC-16)
    • X16 + X12 + X5 + 1 (CRC-CCITT)
  • CRC HAL module supports the following 32 bit CRC polynomials which operates on 32-bit data in parallel
    • X32 + X26 + X23 + X22 + X16 + X12 + X11 + X10 + X8 + X7 + X5 + X4 + X2 + X + 1 (CRC-32)
    • X32 + X28 + X27 + X26 + X25 + X23 + X22 + X20 + X19 + X18 + X14 + X13 + X11 + X10 + X9 + X8 + X6 + 1 (CRC-32C)
  • CRC HAL module can calculate CRC with LSB first or MSB first bit order.
CRC_BD.png
CRC HAL Module Block Diagram

CRC Hardware support details

The following hardware features are, or are not, supported by SSP for the CRC.

Legend:

Symbol Meaning
Available (Tested)
Not Available (Not tested/not functional or both)
N/A Not supported by MCU 

 

MCU
Group
8-bit Data Size 32-bit Data Size CRC
Calculation
Switching
Module Stop
Function
CRC Snoop
S124
S128
S1JA
S3A1
S3A3
S3A6
S3A7
S5D3
S5D5
S5D9
S7G2

CRC HAL Module APIs Overview

The CRC HAL module defines APIs for opening, closing, enabling and calculating. A complete list of the available APIs, an example API call and a short description of each can be found in the following table. A table of status return values follows the API summary table.

CRC HAL Module API Summary

Function Name Example API Call and Description
open g_crc.p_api->open(g_crc.p_ctrl, g_crc.p_cfg);
Open the CRC driver module.
close g_crc.p_api->close(g_crc.p_ctrl);
Close the CRC module driver.
crcResultGet g_crc.p_api->crcResultGet(g_crc.p_ctrl, &result);
Return the current calculated value.
snoopEnable g_crc.p_api->snoopEnable(g_crc.p_ctrl, seed);
Enable snooping.
snoopDisable g_crc.p_api->snoopDisable(g_crc.p_ctrl);
Disable snooping.
snoopCfg g_crc.p_api->snoopCfg(g_crc.p_ctrl, g_crc.p_cfg);
Configure the snoop channel and direction.
calculate g_crc.p_api->calculate(g_crc.p_ctrl, &input_buffer, num_bytes, crc_seed, &crc_result);
Perform a CRC calculation on a block of data.
versionGet g_crc.p_api->versionGet(&version);
Retrieve the API version with the version pointer.
Note
For more complete descriptions of operation and definitions for the function data structures, typedefs, defines, API data, API structures, and function variables, review the SSP User's Manual API References for the associated module.

Status Return Values

Name Description
SSP_SUCCESS Configuration was successful.
SSP_ERR_ASSERTION Assertion error.
SSP_ERR_INVALID_ARGUMENT Invalid argument error.
SSP_ERR_NOT_OPEN The driver is not opened.
SSP_ERR_IN_USE If driver is already open.
Note
Lower-level drivers may return common error codes. Refer to the SSP User's Manual API References for the associated module for a definition of all relevant status return values.

CRC HAL Module Operational Overview

When the CRC HAL module is used to calculate the CRC value for a block of data in memory, the crc_api_t::calculate API can be used to take the input buffer pointer, length and the CRC seed value as input and outputs the calculated CRC value.

When the CRC HAL module is used to calculate the CRC on a stream of data being transmitted or received over a serial communication Interface (SCI) channel (snoop mode), then first the module should be configured to be in snoop mode by calling the crc_api_t::snoopCfg followed by the crc_api_t::snoopEnable APIs. After the requested number of data is transmitted or received on the SCI channel, the calculated CRC value can be polled from the module using crc_api_t::crcResultGet API.

CRC HAL Module Important Operational Notes and Limitations

CRC HAL Module Operational Notes

General CRC HAL Operational Notes

  • The CRC block does not use any interrupts.
  • There is no clock configuration for the CRC module.
  • There are no callbacks for the CRC module.
  • When using 32 bit CRC polynomials for calculating CRC values of data block in memory, the data block is interpreted using little-endian byte order.

CRC HAL Snoop Mode Operational Notes

  • The CRC snoop function monitors reads from (receive) and writes to (transfer) a specified I/O register address.
  • It performs a CRC calculation on the serial data read from (receive) and written to (transfer) the register address automatically.
  • The CRC calculation is performed 1 byte at a time. When the target I/O register address is accessed in words (16 bits) or long words (32 bits), the CRC code is generated on the lower byte (1 byte) of data.
  • The CRC snoop mode is useful in monitoring writes to the serial transmit buffer, and reads from the serial receive buffer. If the user is trying to write data through the SCI interface, then the data will be present in the TDR register of that particular channel. When the user enables the Snoop mode with the proper configuration then the CRC module will automatically calculate the CRC value for the data present in that TDR register and then stores the generated CRC value in the CRC Data output register.

CRC HAL Module Limitations

  • Refer to the latest SSP Release Notes for any additional operational limitations for this module.

Including the CRC HAL Module in an Application

This section describes how to include the CRC HAL Module in an application using the SSP configurator.

Note
This section assumes you are familiar with creating a project, adding threads, adding a stack to a thread and configuring a block within the stack. If you are unfamiliar with any of these items, refer to the first few chapters of the SSP User's Manual to learn how to manage each of these important steps in creating SSP-based applications.

To add the CRC Driver to an application, simply add it to a thread using the stacks selection sequence given in the following table. (The default name for the CRC Driver is g_crc0. This name can be changed in the associated Properties window.)

CRC HAL Module Selection Sequence

Resource ISDE Tab Stacks Selection Sequence
r_crc0 CRC Driver on r_crc Threads New Stack> Driver> Monitoring> CRC Driver on r_crc

When the CRC Driver on r_crc is added to the thread stack as shown in the following figure, the configurator automatically adds any needed lower‑level modules. Any modules needing additional configuration information have the box text highlighted in Red. Modules with a Gray band are individual modules that stand alone. Modules with a Blue band are shared or common; they need only be added once and can be used by multiple stacks. Modules with a Pink band can require the selection of lower-level modules; these are either optional or recommended. (This is indicated in the block with the inclusion of this text.) If the addition of lower-level modules is required, the module description include Add in the text. Clicking on any Pink banded modules brings up the New icon and displays possible choices.

CRC_MS.png
CRC HAL Module Stack

Configuring the CRC HAL Module

The CRC HAL Module must be configured by the user for the desired operation. The available configuration settings and defaults for all the user-accessible properties are given in the properties tab within the SSP configurator and are shown in the following tables for easy reference. Only properties that can be changed without causing conflicts are available for modification. Other properties are locked and not available for changes and are identified with a lock icon for the locked property in the Properties window in the ISDE. This approach simplifies the configuration process and makes it much less error-prone than previous manual approaches to configuration. The available configuration settings and defaults for all the user-accessible properties are given in the Properties tab within the SSP Configurator and are shown in the following tables for easy reference.

Note
You may want to open your ISDE, create the module and explore the property settings in parallel with looking over the following configuration table settings. This will help orient you and can be a useful 'hands-on' approach to learning the ins and outs of developing with SSP.

Configuration Settings for the CRC HAL Module on r_crc

ISDE Property Value Description
Parameter Checking BSP, Enabled, Disabled

Default: BSP
Enable or disable the parameter error checking.
Name g-crc0 Module name.
CRC Polynomial CRC-8, CRC-16, CRC-CCITT, CRC-32, CRC-32C

Default: CRC-32C
Specify the polynomial to
use for calculation.
Bit Order LSB, MSB

Default: MSB
Specify the bit order of the calculation.
FIFO Mode Enable, Disable

Default : Disable
Enable this property when using SCI_UART with FIFO mode during CRC snoop operation.
Note
The example settings and defaults are for a project using the Synergy S7G2 MCU Group. Other MCUs may have different default values and available configuration settings.
CRC snoop mode operation for SCI_UART with FIFO must be enabled when the SCI channel supports FIFO mode.

CRC HAL Module Clock Configuration

The CRC HAL module is clocked via the Peripheral Clock A (PCLKA.)

The CRC HAL module does not support any APIs for setting the frequency at which it operates.

CRC HAL Module Pin Configuration

The CRC HAL module does not have any configurable pins.

Using the CRC HAL Module in an Application

There are two main types of CRC implementations- normal mode and snoop mode. The typical steps for each mode are shown below.

The typical steps in using the CRC HAL module in an application are:

  1. Initialize the CRC HAL module using the crc_api_t::open API.
  2. Compute the CRC HAL module using the crc_api_t::calculate API.
  3. Close the CRC HAL module using the crc_api_t::close API.

These common steps are illustrated in a typical operational flow diagram in the following figure:

CRC_TA.png
Flow Diagram of a Typical CRC HAL Module Application

The typical steps in using the CRC HAL module for computing in Snoop mode are:

  1. Initialize the CRC HAL module using the crc_api_t::open API.
  2. Snoop channel and snoop direction must be set manually by using snoop configuration structure crc_snoop_cfg_t.
  3. Configure the CRC module to snoop an SCI channel (and its direction) using crc_api_t::snoopCfg API.
  4. Enable snooping of the SCI channel using crc_api_t::snoopEnable API.
  5. Once the required number of bytes are transmitted or received on the SCI channel, get the calculated CRC value using crc_api_t::crcResultGet API.
  6. Disable the snooping operation using crc_api_t::snoopDisable API.
  7. Close the CRC HAL module using the crc_api_t::close API.

These common steps are illustrated in a typical operational flow diagram in the following figure:

CRC_TA2.png
Flow Diagram of a Typical CRC HAL Module Application