Renesas CRC HAL Application Note

Application Note Renesas Synergy™ Platform
CRC HAL Module Guide
Introduction
This module guide will enable you to effectively use a module in your own design. Upon completion of this guide, you will be able to add this module to your own design, configure it correctly for the target application and write code, using the included application project code as a reference and an efficient starting point. References to more detailed API descriptions and suggestions of other application projects that illustrate more advanced uses of the module are included in the document and should be valuable resources for creating more complex designs.
The CRC HAL module is a high-level API used 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 various types of industry-standard polynomials. The CRC HAL module is implemented on r_crc and uses the CRC peripheral on the Synergy MCU.
Contents
1. CRC HAL Module Features ..................................................................................................... 2
2. CRC APIs Overview ................................................................................................................ 2
3. CRC HAL Module Operational Overview ................................................................................. 3
3.1 CRC HAL Module Important Operat ional Notes and Li mitations ............................................................ 3
3.1.1 CRC HAL Module Operational Notes .................................................................................................... 3
3.2 CRC HAL Module Limitations .................................................................................................................. 3
4. Including the CRC HAL Module in an Application .................................................................... 3
5. Configuring the CRC HAL Module ........................................................................................... 4
5.1 CRC HAL Module Clock Configuration ................................................................................................... 5
5.2 CRC HAL Module Pin Configuration ....................................................................................................... 5
6. Using the CRC HAL Module in an Application ......................................................................... 5
7. The CRC HAL Module Application Project ............................................................................... 6
8. Customizing the CRC HAL Module for a Target Application .................................................... 7
9. Running the CRC HAL Module Application Project .................................................................. 7
10. CRC HAL Module Conclusion .................................................................................................. 8
11. CRC HAL Module Next Steps .................................................................................................. 8
12. CRC HAL Module Reference Information ................................................................................ 8
R11AN0092EU0102 Rev.1.02 Page 1 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
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);
.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);
.snoopDisable
g_crc.p_api->snoopDisable(g_crc.p_ctrl);
Disable snooping.

1. 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-bit and 16-bit CRC polynomials which operates on 8-bit data in parallel
8
CRC HAL module supports the following 32-bit CRC polynomials which operates on 32-bit data in parallel
CRC HAL module can calculate CRC with LSB first or MSB first bit order.
2
+
+ + 1 (CRC-8)
16
+ 15+
16
+ 12+
32
+ 26+ 23+ 22+ 16+ 12+ 11+ 10+ 8+ 7+ 5+ 4+ 2+ + 1 (CRC-32)
32
+ 28+ 27+ 26+ 25+ 23+ 22+ 20+ 19+ 18+ 14+ 13+ 11+ 10+ 9+ 8+
6
+ 1 (CRC-32C)
2
+ 1 (CRC-16)
5
+ 1 (CRC-CCITT)
Figure 1. CRC HAL Module Block Diagram

2. CRC APIs Over view

The CRC HAL module defines APIs for opening, closing, enabling and calculating. A complete list of the available APIs, an exam ple 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.
Table 1. CRC HAL Module API Summary
Close the CRC module driver.
Enable snooping.
R11AN0092EU0102 Rev.1.02 Page 2 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Function Name
Example API Call and Description
.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, .versionGet
g_crc.p_api->versionGet(&version);
Retrieve the API version with the version point er .
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.
num_bytes, crc_seed, &crc_result); Perform a CRC calculation on a block of data.
Note: For details on 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.
Table 2. Status Return Values
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.

3. 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 ca n be us ed which t ak es the input buf fer poi nter, length and the CR C se ed valu e as input and outputs the calculated CRC value.
When the CRC HAL module is used to calculate CRC on a stream of data being transmitted or received over a serial communication Interface (SCI) channel (snoop mode), 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 the crc_api_t::crcResultGet API.

3.1 CRC HAL Module Important Operational Notes and Limitations

3.1.1 CRC HAL Module 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 c alculating CRC values of data bloc k in memory, the data
block is interpreted using little-endian byte order.

3.2 CRC HAL Module Limitations

Refer to the most recent SSP Release Notes for any additional operational limitations for this module.

4. 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
To add the CRC Driver to an application, simply add it to a thread using the stacks selection sequence provided in the following table. (The default name for the CRC Driver is g_crc0. This name can be changed in the associated Properties window.)
R11AN0092EU0102 Rev.1.02 Page 3 of 10 Feb.01.19
steps in creating SSP-based applications.
Renesas Synergy™ Platform CRC HAL Module Guide
Resource
ISDE Tab
Stacks Selection Sequence
r_crc0 CRC Driver on r_crc
Threads
New Stack> Driver> Monitoring> CRC Driver on r_crc
ISDE Property
Value
Description
Parameter Checking
BSP, Enabled, Disabled
Enable or disable the Name
g_crc0
Module name.
CRC Polynomial
CRC-8, CRC-16, CRC-CCITT, CRC-32, CRC-32C
Specify the polynomial to
Bit Order
LSB, MSB
Specify the bit order of
Table 3. CRC Driver Selection Sequence
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 drivers that need additional configuration inform ation will be box text hig hl ight ed in Red. Mod ul es with a Gray band are individual modules that stand alone.
Figure 2. CRC HAL Module Stack

5. Configuring the CRC H AL Module

The CRC HAL module must be configured by the user for the desired operation. The SSP configuration window will automatically identify (by highlighting the block in red) any required configuration selections, such as interrupts or operating modes, which must be configured for lower-level modules for successful operation. Furthermore, only those properties that can be changed without causing conflicts are available for modification. Other properties are locked and are 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.
One of the properties most often identified as requiring a change is the interrupt priority; this configuration setting is available within the Properties window of the associated module. Simply select the indicated module and then view the Properties window; the interrupt settings are often toward the bottom of the properties list, so scroll down until they become available. Note that the interrupt priorities listed in the Properties window in the ISDE will include an indication as to the validity of the setting based on the targeted MCU (CM4 or CM0+). This level of detail is not included in the following configuration properties tables but is easily visible with the ISDE when configur i ng inter r upt-priority leve ls .
Note: You may want to open your ISDE, create the module and explore the Propert y sett ings in para lle l with
looking over the following configuration table settings. This will help orient you and can be a useful
Table 4. Configuration Settings for the CRC HAL Module on r_crc
hands-on approach to learning the ins and outs of deve lop ing wit h SSP.
Default: BSP
Default: CRC-32C
Default: MSB
Note: The example values and defaults are for a project using the S7G2 Synergy MSU Group. Other MCUs
may have different default values and available configuration settings.
R11AN0092EU0102 Rev.1.02 Page 4 of 10 Feb.01.19
parameter error checking.
use for calculation.
the calculation.
Renesas Synergy™ Platform CRC HAL Module Guide
In some cases, settings other than the defaults for a module can be desirable. For example, it might be useful to select a different clock source than the default. The configurable properties for the lower-level stack modules are given in the following sections for completeness and as a reference.

5.1 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.

5.2 CRC HAL Module Pin Configuration

The CRC HAL module doesn’t have any configurable pins.

6. Using the CRC HAL Module in an Application

The typical steps in using the CRC HAL module for computing CRC of data block in memory are:
1. Initialize the CRC HAL module using the crc_api_t::open API
2. Compute the CRC HAL module using the crc _ap i_t: :c a lcula te API
3. Close the CRC HAL module using the crc_api_t::close API
The following diagram shows these common steps in a typical operational flow:
Figure 3. Flow Diagram of a Typical CRC HAL Module Application
The typical steps in using the CRC HAL module for computing CRC in snoop mode are:
1. Initialize the CRC HAL module using the open API.
2. Configure CRC module to snoop an SCI channel (and its direction) using the crc_api_t::snoopCfg API.
3. Enable snooping of the SCI channel using the crc_api_t::snoo pEn ab le API.
4. Onc e the required number of bytes are transm itted or received on the SCI c hannel, get the calcu lated
CRC value using the cr c _a pi_t ::c rc Res ultGet A PI.
5. Disable the snooping operation using the crc_ap i_t::s n oopD is ab le API.
6. Close the CRC HAL module using the crc_api_t::close API.
The following diagram shows these common steps in a typical operational flow:
R11AN0092EU0102 Rev.1.02 Page 5 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Resource
Revision
Description
e2 studio
5.3.1 or later
Integrated Solution Development Environment (ISDE)
SSP
1.2.0 or later
Synergy Software Platform
IAR EW for Synergy
7.71.2 or later
IAR Embedded Workbench® for Renesas Synergy™
SSC
5.3.1 or later
Synergy Standalone Configurator
SK-S7G2
v3.0 to v3.1
Starter Kit
Figure 4. Flow Diagram of a Typical CRC HAL Module Snoop Mode Application

7. The CRC HAL Module Application Project

The application project associated with this module guide demonstrates these steps in a full design. The project can be found using the link provided in the References section at the end of this document. You may want to import and open the application project within the ISDE and view the configuration settings for the CRC HAL module. You can also read over the code (in crc_hal.c) which is used to illustrate the CRC HAL module APIs in a complete design.
The application project demonstrates the typical use of the CRC HAL module APIs. The application project main-thread entry initializes the CRC HAL module and periodically computes the CRC. The CRC is initially computed for a data buffer that is filled with generated bytes, then the data is copied to the so-called receive buffer, (the application simulates data transmission) and once again the CRC is computed. Both CRCs are compared, and based on the result, the green (CRCs are equal) or red (CRCs are different) LED is lit. The simulation of data transmission can introduce errors which result in lighting the red LED. The following table identifies the target versions for the associated software and hardware used by the application project.
Table 5. Software and Hardware Resources Used by the Application Project
The following flow diagram shows a simple application project:
R11AN0092EU0102 Rev.1.02 Page 6 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Figure 5. CRC Application Project Flow Diagram
The complete application project can be found using the link provided in the References section at the end of this document. The crc_hal.c file is located in the project once it has been imported into the ISDE. You can open this file within the ISDE and follow along with the description provided to help identify key uses of APIs.
In the application project, main-thread entry, the CRC HAL module is initialized using the open API right after the data array and receive buffer are set up. The data array contains growing numbers, as bytes, starting with 0; the receive buffer is initialized with zeros. When the data is ready, and the CRC HAL module is initialized, a CRC is computed for the data. Next, the application enters a loop which simulates data transmission and fills the receive buffer, computes the CRC for the buffer, and lights the green (CRCs are equal) or red (CRCs are different) LED, according to the CRC comparison result. The application is initially configured to introduce data-transmission errors. After copying bytes from the data array to the receive buffer, the byte at index 0 in the buffer is altered. This results in a different CRC and lights the red LED. This error can be removed by setting the makeError variable to false. The CRC will then match, lighting the green LED.
The CRC application project uses the CRC HAL module default property-values; no extra activities must be performed by the user.

8. Customizing the CRC HAL Module for a Targe t Application

The application project uses the default setting of the CRC-32C Polynomial on MSB data. The developer may wish to change the polynomial value and bit order to suit their target application.

9. Running the CRC HAL Module Application Project

To run the CRC HAL module application project and to see it executed on a target kit, you can simply import it into your ISDE, compile and run debug.
R11AN0092EU0102 Rev.1.02 Page 7 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
To implement the CRC HAL module application in a new project, follow the steps for defining, configuring, auto-generating files, adding code, compiling and debugging on the target kit. Following these steps is a hands-on approach that can help make the development process with SSP more practical, while just reading over this guide will tend to be more theoretical.
Note: The following steps are sufficient for someone experienced with the basic flow through the Renesas
Synergy™ Pl atf orm development process. If these steps are unfamiliar, refer to the first few chapters
To create and run the CRC HAL module application project, simply follow these steps:
1. Create a new project for the S7G2 SK Synergy MCU Group called CRC_HAL_MG_AP.
2. Select the BSP tab and select RTOS being used as No RTOS.
3. Select the Threads tab.
4. Add the CRC HAL module to the HAL thread.
5. Click on the Generate Project Content button.
6. Add the code from the supplied project file crc_hal.c or copy over the generated crc_hal.c file.
7. Connect to the host PC via a micro USB cable to J19 on the SK-S7G2 Kit.
8. Start to debug the application
9. Watch the green or red le d bei ng lit on the board .
in the SSP User’s Manual listed in the References section at the end of this document.

10. CRC HAL Module Conclusion

This module guide has provided all the background information needed to select, add, configure and use the module in an example project. Many of these steps were time consuming and error-prone activities in previous generations of embedded systems. The Renesas Synergy Platform makes these steps much less time consuming and removes the common errors, like conflicting configuration settings or the incorrect selection of lower-l evel dr ivers. The use of high-level APIs (as demonstrated in the application project) illustrates additional development time savings by allowing work to begin at a high level and avoiding the time required in older development environments to use or, in some cases, create, lower-level drivers.

11. CRC HAL Module Next Steps

After you have mastered a simple CRC HAL module project, you may want to review a more complex example. Other application projects and application notes that demonstrate CRC HAL-use can be found as described in the References section at the end of this document.

12. CRC HAL Module Reference Information

SSP User Manual: Available from the Renesas Synergy Software Package website here:
https://www.renesas.com/us/en/products/synergy/software/ssp.html
Links to all the most up-to-date r_crc module reference materials and resources are available on the Synergy Knowledge Base here: https://en-support.renesas.com/knowledgeBase/16977474
R11AN0092EU0102 Rev.1.02 Page 8 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Website and Support
Visit the following vanity URLs to learn about key elements of the Synergy Platform, download components and related documentation, and get support.
Synergy Software www.renesas.com/synergy/software Synergy Software Package www.renesas.com/synergy/ssp Software add-ons www.renesas.com/synergy/addons Software glossary www.renesas.com/synergy/softwareglossary
Development tools www.renesas.com/synergy/tools
Synergy Hardware www.renesas.com/synergy/hardware Microcontrollers www.renesas.com/synergy/mcus MCU glossary www.renesas.com/synergy/mcuglossary Parametric search www.renesas.com/synergy/parametric
Kits www.renesas.com/synergy/kits
Synergy Solutions Gallery www.renesas.com/synergy/solutionsgallery Partner projects www.renesas.com/synergy/partnerprojects
Application projects www.renesas.com/synergy/applicationprojects
Self-service support resources:
Documentation www.renesas.com/synergy/docs Knowledgebase www.renesas.com/synergy/knowledgebase Forums www.renesas.com/synergy/forum Training www.renesas.com/synergy/training Videos www.renesas.com/synergy/videos Chat and web ticket www.renesas.com/synergy/resourcelibrary
R11AN0092EU0102 Rev.1.02 Page 9 of 10 Feb.01.19
Renesas Synergy™ Platform CRC HAL Module Guide
Rev.
Date
Description
Page
Summary
1.00
Jul.31.17
Initial Release
1.01
Aug.30.17
7
Update to Hardware and Software Resources Table
1.02
Feb.01.19
7
Update to program operational description

Revision History

R11AN0092EU0102 Rev.1.02 Page 10 of 10 Feb.01.19
Corporate Headquarters
Contact information
www.renesas.com
Trademarks
of their respective owners.
Notice
1. Descriptions of circuits, software and other related information in this document are provided only to illustrate the operation of semiconductor products
and application examples. You are fully responsible for the incorporation or any other use of the circuits, software, and information in the design of your product or system. Renesas Electronics disclaims any and all liability for any losses and damages incurred by you or third parties arising from the use of these circuits, software, or information.
2. Renesas Electronics hereby expressly disclaims any warranties against and liability for infringement or any other claims involving patents, copyrights,
or other intellectual pro pe rt y rig hts of th i rd parties, by or arising from the use of Renesas Electronics products or technical information described in this document, including but not limited to, the product data, drawings, charts, programs, algorithms, and application examples.
3. No license, express, implied or otherwise, is granted hereby under any patents, copyrights or other intellectual property rights of Renesas Electronics
or others.
4. You shall not alter, modify, copy, or reverse engineer any Renesas Electronics product, whether in whole or in part. Renesas Electronics disclaims any
and all liability for any losses or damages incurred by you or third parties arising from such alteration, modification, copying or reverse engineering.
5. Renesas Electronics products are classified according to the following two quality grades: “Standard” and “High Quality”. The intended applications for
each Renesas Electronics product depends on the product’s quality grade, as indicated below. "Standard": Computers; office equipment; communications equipment; test and measur em ent eq uipm e nt ; audi o and visu al equi p ment; home
"High Quality": Transportation equipment (automobiles, trains, ships, etc.); traffic control (traffic lights); large-scale communication equipment; key
Unless expressly designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas Electronics document, Renesas Electronics products are not intended or authorized for use in products or systems that may pose a direct threat to human life or bodily injury (artificial life support devices or systems; surgical implantations; etc.), or may cause serious property damage (space system; undersea repeaters; nuclear power control systems; aircraft control systems; key plant systems; military equipment; etc.). Renesas Electronics disclaims any and all liability for any damages or losses incurred by you or any third parties arising from the use of any Renesas Electronics product that is inconsistent with any Renesas Electronics data sheet, user’s manual or other Renesas Electronics document.
6. When using Renesas Electronics products, refer to the latest product information (data sheets, user’s manuals, application notes, “General Notes for
Handling and Using Semiconductor Devices” in the reliability handbook, etc.), and ensure that usage conditions are within the ranges specified by Renesas Electronics with respect to maximum ratings, operating power supply voltage range, heat dissipation characteristics, installation, etc. Renesas Electronics disclaims any and all liability for any malfunctions, failure or accident arising out of the use of Renesas Ele ctro ni cs pr odu c ts outside of such specified ranges.
7. Although Renesas Electronics endeavors to improve the quality and reliability of Renesas Electronics products, semiconductor products have specific
characteristics, such as the occurrence of failure at a certain rate and malfunctions under certain use conditions. Unless designated as a high reliability product or a product for harsh environments in a Renesas Electronics data sheet or other Renesas Electronics document, Renesas Electronics products are not subject to radiation resistance design. You are responsible for implementing safety measures to guard against the possibility of bodily injury, injury or damage caused by fire, and/or danger to the public in the event of a failure or malfunction of Renesas Electronics products, such as safety design for hardware and software, including but not limited to redundancy, fire control and malfunction prevention, appropriate treatment for aging degradation or any other appropriate measures. Because the evaluation of microcomputer software alone is very difficult and impractical, you are responsible for evaluating the safety of the final products or systems manufactured by you.
8. Please contact a Renesas Electronics sales office for details as to environmental matters such as the environmental compatibility of each Renesas
Electronics product. You are responsible for carefully and sufficiently investigating applicable laws and regulations that regulate the inclusion or use of controlled substances, including without limitation, the EU RoHS Directive, and using Renesas Electronics products in compliance with all these applicable laws and regulations. Renesas Electronics disclaims any and all liability for damages or losses occurring as a result of your noncompliance with applicable laws and regulations.
9. Renesas Electronics products and technologies shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is
prohibited under any applicable domestic or foreign laws or regulations. You shall comply with any applicable export control laws and regulations promulgated and administered by the governments of any countries asserting jurisdiction over the parties or transactions.
10. It is the responsibility of the buyer or distributor of Renesas Electronics products, or any other party who distributes, disposes of, or otherwise sells or
transfers the product to a third party, to notify such third party in advance of the contents and conditions set forth in this document.
11. This document shall not be reprinted, reproduced or duplicated in any form, in whole or in part, without prior written consent of Renesas Electronics.
12. Please contact a Renesas Electronics sales office if you have any questions regarding the information contained in this document or Renesas
Electronics products.
(Note1) “Renesas Electronics” as used in this document means Renesas Electronics Corporation and also includes its directly or indirectly contr oll ed
(Note2) “Renesas Electronics product(s)” means any product developed or manufactured by or for Renesas Electronics.
subsidiaries.
electronic appliances; machine tools; personal electronic equipment; industrial robots; etc.
financial terminal systems; safety control equipment; etc.
(Rev.4.0-1 November 2017)
TOYOSU FORESIA, 3-2-24 Toyosu, Koto-ku, Tokyo 135-0061, Japan
Renesas and the Renesas logo are trademarks of Renesas Electronics Corporation. All trademarks and registered trademarks are the property
For further information on a product, technology, the most up-to-date version of a document, or your ne are s t sales office, please visit:
www.renesas.com/contact/.
© 2019 Renesas Electronics Corporation. All rights reserved.
Loading...