Home

CRC computation using PCP

image

Contents

1. if a failure of such components can reasonably be expected to cause the failure of that life support device or system or to affect the safety or effectiveness of that device or system Life support devices or systems are intended to be implanted in the human body or to support and or maintain and sustain and or protect human life If they fail it is reasonable to assume that the health of the user or other persons may be endangered AP32171 e Infineon CRC Computation using PCP Revision History V1 0 2010 09 Previous Version none Page Subjects major changes since last revision We Listen to Your Comments Is there any information in this document that you feel is wrong unclear or missing Your feedback will help us to continuously improve the quality of this document Please send your proposal including a reference to this document to mcdocu comments infineon com Application Note 3 V1 0 2010 09 ec AP32171 Infi neon CRC Computation using PCP Preface Table of Contents 1 POT ACC EE eL LU LI LC MICI AT 5 2 CRC Parameters E 5 3 PCP Implermentati9 eee T 6 3 1 Example BI Te eie EE N buis AE E A O aides al earei 6 3 2 Implementation Details cerent erento teuer eed ione ea SE DY eek ey Pe ds ee kg ese SP EG 7 3 3 Memory Footprint and Performance sees riia anna Naaa EEA Aa EAAS nen
2. PREFIX xor out extern volatile unsigned long pram ADD GLOBAL SYMBOL PREFIX croc out extern unsigned long pram ADD GLOBAL SYMBOL PREFIX crc table 256 fendif CTC The __ pram keyword tells the TriCore compiler to use symbol names prefixed by 1c s 2 i e it declares the variables as shared global variables of PCP The prefix of the shared symbols in this example CH1 is set by an option in the PCP projects see Figure 1 This enables only one source code for all CRC algorithms because the specific labelling is performed automatically by the PCP C compiler Application Note 7 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP PCP Implementation B Properties for pcp cre chL os B s type filter text Settings x T Resource k Builders c C C Build Configuration Release Active Manage Configurations Build Variables Discovery Options ER Environment Tool Settings Build Steps dip Build Artifact Binary Parsers Error Parsers Processor m Settings Global Options firefix for global symbols CH1 g e g sy C C General f Channel Configuration F Allow channel to be interruptible Project References W C C Compiler F Preserve R7 flags 0 7 E Refactoring History 3 Preprocessing i Run Debug Settings 3 Include Paths Subversion Language Code Generation Allocation 3 Optimizatio
3. array in DPRAM or PMU and access it through the FPI but this is not desirable when the FPI bus is intensively used The solution to maximize speed is to use the double word data type for 8 and 16 bit CRC This will cost 4 or 2 times the table size but the performance will be not impacted Application Note 8 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP PCP Implementation Where there are tight PRAM constraints it is possible to use the regular size CRC lookup table but some extra code is required to set and read table values This has a big impact on performance For example an 8 bit CRC is 2 times slower than a 32 bit CRC computation By using the CRC TABLE ALWAYS 32BITS CH2 macro it is possible to switch between the two implementations When CRC TABLE ALWAYS 32BITS CH2 is set to 0 the lookup table has the expected size crc size in bytes x 256 but extra code is required to access it to get the correct lookup table value When CRC TABLE ALWAYS 32BITS CH2 is set to 1 the lookup table is always 4 x 256 bytes regardless of the CRC size and only a small portion of table entries are used to store the values needed for the computation So retrieving values is very fast at a cost of PRAM size Below is the macro that retrieves the lookup table values if CRC TABLE ALWAYS 32BITS define GET TABLE ITEM A crc table A else define GET TABLE ITEM A get table item A Return crc table value a
4. is printed out The example is divided into three sub projects pcp crc start pcp crc ch1 and pcp crc ch2 3 1 1 Project pcp crc start This TriCore project initializes the PCP channels triggers their execution and verifies the result of the CRC computation The project contains the following files main c computes the tables required by the Direct Table CRC implementation triggers the PCP channels checks results and prints performance results crc init c and crc init h contains the function required to generate the table required by the CRC Direct Table algorithm e cstart c and cstart h these are Tasking toolset generated files required to initialize the C environment e simio c required by the pls debugger in order to enable simulated VO 3 1 2 Project pcp crc ch1 and pcp crc ch2 These two projects compute two different CRCs of data pointed to by the buffer pointer using different CRC parameters The two projects each contain two files e pcp crc1 c and pcp crc2 c identical files except for the header files which are used to configure the code Input and output variables are shared PRAM variables crc parameters ch1 h and crc parameters ch2 h Application Note 6 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP PCP Implementation two header files that store the configuration of the two CRC algorithms They are used by the pcp crc start project to initialize the CRC lookup t
5. ables used in the calculation 3 2 Implementation Details The PRAM variables used by the PCP channels are declared as follows Pointer to the message to be translated in FPI space unsigned char far mau8 volatile buffer pointer volatile unsigned long num bytes Num of bytes to be transferred volatile unsigned long init value Initial value of CRC volatile unsigned long xor out Nalue to be xored before returning the CRC volatile unsigned long crc out CRC result Attention The pointer to the buffer located on the FPI bus is declared using far mau8 in order to have a data size of 8 bit see 2 Attention You can use the type qualifier mau8 only on objects that have the far qualifier because only objects located in the FPI space can have byte access PRAM has only double word access see 3 For TriCore the variable counterparts of the PCP channel global variables are as follows These are th xternal declarations required by Tricore compare in order to access the PCP channel global variables if CTC define ADD GLOBAL SYMBOL PREFIX A CH1_ A extern volatile unsigned long pram ADD GLOBAL SYMBOL PREFIX buffer pointer extern volatile unsigned long pram ADD GLOBAL SYMBOL PREFIX num bytes extern volatile unsigned long pram ADD GLOBAL SYMBOL PREFIX init value extern volatile unsigned long pram ADD GLOBAL SYMBOL
6. al computer system It could be considered as the host processor s first line of defence as an interrupt handling engine The PCP can unload the CPU from having to service time critical interrupts This provides many benefits including e Avoiding large interrupt driven task context switching latencies in the host processor e Reducing the cost of interrupts in terms of processor register and memory overhead Improving the responsiveness of Interrupt Service Routines to data capture and data transfer operations e Easing the implementation of multitasking operating systems Therefore it is quite natural to check or generate the CRC checksum of a data packet inside the PCP In this application note an efficient and re usable PCP implementation of a configurable CRC algorithm is described The application note is provided together with a Tasking VX toolset for TriCore and a PCP example for the TC1797 device This example is implemented in a way that allows for easy configurability for 8 16 and 32 bit CRC and it can also be adapted very easily to different applications such as validation of incoming data from a peripheral or memory to memory data transfer with CRC validation and so on 2 CRC Parameters This document does not discuss the CRC theory and the mathematics behind the chosen implementation but for background reading regarding this topic please refer to the 6Bibliography references 1 4 and 5 The Direct table algorithm implem
7. entation was chosen because it is very fast and allows easy configuration for different CRC polynomials Unfortunately in real life a CRC algorithm is not only defined by the polynomial as in the mathematical theory but other parameters are required such as the Initialization value reflection and so on As there is no standard for the full definition of a CRC computation this document is based on the Rocksoft Model CRC Algorithm parametrized model 5 Table 1 lists the CRC model parameters together with the name used in the example source code Table 1 CRC Algorithm Parameters Parameter Description CRC WIDTH CRC bits width POLYNOMIAL Value of CRC polynomial INIT VALUE Initilization value XOR OUT Value to be xored to crc checksum before to output it REFLECT IN If true the input bytes will be reflected REFLECT OUT If true CRC chekcsum is reflected before to ouput it 1 Refer to the bibliography chapter for a paper reporting the Hamming distance for most common CRC polynomial 4 Application Note 5 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP PCP Implementation Note The REFLECT IN parameter enables an efficient CRC computation when the input bytes are reversed Some serial communication protocols require that each byte be transmitted with the least significant bit LSB first and the most significant bit last Instead of reflecting switching from LSB first to LSB last ord
8. ering all input bytes by reflecting the algorithm it is possible to compute the correct CRC without the overhead of byte reflection 3 PCP Implementation The Direct Table Algorithm has been chosen as the C implementation because it is a good compromise between speed memory footprint and configurability A lookup table of 256 entries was selected because of the small memory size available The Tasking compiler provides a PCP C compiler The C implementation of the Direct Table algorithm is very efficient and it can be compiled in fast PCP binary code as each part of code is adapted for PCP The PCP assembly instruction set does have the following limitations that affect the C compiler 3 e PRAM addressing is 32bits gt PRAM can be written from FPI bus only by double word e No load store byte word instruction from to PRAM all data stored in PRAM has 32 bit size Therefore it is not possible to just copy the C code and compile it unless some adaptations have been made The code described in the next section is developed in order to allow full configurability for any CRC8 16 32 polynomial and to maximize the speed 3 1 Example Description The example performs the following operations 1 TriCore project initializes two different PCP channels that implement two different CRCs 2 The two PCP channels are activated sequentially and calculate two different CRCs of a block of 1024 bytes stored in flash 3 The CRC and throughput
9. it Cyclic Redundancy Codes for Internet Applications Koopman Philip 2002 The International Conference on Dependable Systems and Networks DSN 2002 10 1109 DSN 2002 1028931 5 Williams Dr Ross CRC A Paper On CROs Online http www ross net crc crcpaper html Application Note 10 V1 0 2010 09
10. j 1 Cinfineon TriCore Family AP32171 CRC Computation using PCP Application Note V1 0 2010 09 Microcontrollers Edition 2010 09 Published by Infineon Technologies AG 81726 Munich Germany 2010 Infineon Technologies AG All Rights Reserved LEGAL DISCLAIMER THE INFORMATION GIVEN IN THIS APPLICATION NOTE IS GIVEN AS A HINT FOR THE IMPLEMENTATION OF THE INFINEON TECHNOLOGIES COMPONENT ONLY AND SHALL NOT BE REGARDED AS ANY DESCRIPTION OR WARRANTY OF A CERTAIN FUNCTIONALITY CONDITION OR QUALITY OF THE INFINEON TECHNOLOGIES COMPONENT THE RECIPIENT OF THIS APPLICATION NOTE MUST VERIFY ANY FUNCTION DESCRIBED HEREIN IN THE REAL APPLICATION INFINEON TECHNOLOGIES HEREBY DISCLAIMS ANY AND ALL WARRANTIES AND LIABILITIES OF ANY KIND INCLUDING WITHOUT LIMITATION WARRANTIES OF NON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY WITH RESPECT TO ANY AND ALL INFORMATION GIVEN IN THIS APPLICATION NOTE Information For further information on technology delivery terms and conditions and prices please contact the nearest Infineon Technologies Office www infineon com Warnings Due to technical requirements components may contain dangerous substances For information on the types in question please contact the nearest Infineon Technologies Office Infineon Technologies components may be used in life support devices or systems only with the express written approval of Infineon Technologies
11. n Custom Optimization 3 Debugging 5E MISRA C Custom 2004 3 Custom 1998 e CERT C Secure Coding Custom CERT C Diagnostics 3 Miscellaneous ri N Arramblace m Figure 1 How to Set Prefix for Global Symbol The PCP channel variables are initialized using macros stored in the channel specific header file crc_parameters_chx h The following shows how initialization is performed for channel 1 Initialize crc parameters of chl Gl crc_table_init CH1l_crc_table REFLECT_IN_CH1 CRC_WIDTH_CH1 POLYNOMIAL_CH1 CRC_TABLI ALWAYS 32BITS CH1 CH1 buffer pointer unsigned int test pattern CH1 num bytes BUFFER SIZE CH1 init value INIT VALUE CH1 CH1 xor out XOR OUT CH1 Note that the function crc table init is used to set the CRC lookup table so it is possible to change some CRC algorithm parameters at runtime Attention REFLECT IN and CRC WIDTH cannot be changed at runtime because those are used to configure the code for efficiency reasons In fact if these are used as runtime parameters additional conditional instructions are required inside the loop that computes the CRC and so performance is impacted The PCP limitation described at the beginning of this chapter has an impact on the performance of CRC8 and CRC16 It is only possible to address the CRC lookup table as a double word because it is located in the PRAM One solution is to place this
12. nen nennen nennen nnne nnn 9 3 4 How to Create a New PCP CRC Channel ees ee nenne nennen entere nnne nnns 9 4 COMCIU SION me OE ene 10 5 Appendix A Project Tool Requirements esse EER EER E EER RR REGEER RR ERGER RR nnnm nnne nnn nannten 10 6 dje ele ET c 10 Application Note 4 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP Preface 1 Preface The importance of a CRC Cyclic Redundancy Check in data storage and transmission is well known and it is also a fundamental feature in safety and high reliability embedded systems The TriCore Audo NG and Audo Future family do not actually include a CRC engine but they do have a MISR Multiple Input Shift Register Checksum engine that uses an Ethernet Polynomial The MISR algorithm is suitable for protecting a large quantity of data but lacks the following property for a given polynomial and a given data length CRC detects all possible combinations of a number of failure bits Hamming Distance 1 For this reason the most common transmission protocols and data protection schemes use the CRC algorithm to protect data In Audo NG and Audo Future devices the Peripheral Co Processor PCP is present The PCP performs tasks that would normally be performed by the combination of a DMA controller and its supporting CPU Interrupt Service Routines in a tradition
13. oject and include the crc parameters ch3 Add code to initialize the PCP channel as shown in main c with the precaution of changing the prefix CH1 to CH3 10 Activate the channel Note The PCP CRC channel does not overwrite shared global variables except crc out so it is not necessary to re initialize the variables before every new channel execution o0 0 4 Conclusion This application note presents a configurable library code to compute CRC inside the PCP This very efficient implementation can be configured for any 8 16 or 32 bit CRC using the parameters defined by the Rocksoft Model CRC Algorithm This implementation can be very easily adapted for different applications as a peripheral to memory data transfer and CRC verification memory to peripheral and CRC computation and memory to memory safe transfer 5 Appendix A Project Tool Requirements The following tools are required to compile and execute the example Software e Tasking VX toolset for TriCore and PCP version 3 4r1 http www tasking com e PLS UDE Desktop hitp www pls mc com Hardware e Triboard TC1797 v4 1 e PLS Universal Access Device 2 Bibliography 6 1 Cyclic Redundancy Check CRC Wikipedia Online http en wikipedia org wiki Cyclic redundancy check 2 TASKING VX toolset for PCP User Guide s l Altium 3 Infineon AG TC1797 User s Manual TC1797 UM v1 1 pdf Infineon Web Site http www infineon com 4 32 B
14. t position defined by index d static inline unsigned long get table item unsigned long index unsigned long index by 32bit bits offset value index by 32bit index 4 CRC WIDTH 8 value crc table index by 32bit bits offset index CRC WIDTH 32 value value bits offset amp CRC MASK return value endif CRC TABLE ALWAYS 32BITS 3 3 Memory Footprint and Performance The memory footprint depends on the CRC configuration e Code footprint ranges from 216 to 78 bytes max speed optimizations e Data footprint ranges from 308 to 1024 bytes Minimum measured throughput is 1 5 MB sec CRC8 while maximum measured throughput is 3 5 MB sec CRC32 When CRC TABLE ALWAYS 32BITS CH2 is set to O all configurations give almost the same throughput 3 5 MB sec 3 4 How to Create a New PCP CRC Channel The following steps describe how to use the PCP library and create a new CRC PCP channel Create a new PCP project e g by copying an existing one and renaming pcp crc ch3 Copy pcp crc1 c and crc parameters ch1 h Change the file names to pcp crc3 c and crc parameters ch3 h Update the included header filename in pcp crc3 c Change all CH1 to CH3 ra N Application Note 9 V1 0 2010 09 e AP32171 Infi neon CRC Computation using PCP Conclusion Update the CRC parameters as required Update in the PCP project the prefix of global symbols to CH3 see Figure 1 Switch to the TriCore pr

Download Pdf Manuals

image

Related Search

Related Contents

Samsung MH035FKEA User Manual  Husqvarna HUV 4213-G Utility Vehicle User Manual  全文情報 - 労働委員会関係 命令・裁判例データベース  installation solaire thermique avec garantie de resultat  SGQ_ATS Automatic Transfer Switch USER MANUAL  9052107 - eLED LINE SQUARE  Hampton Bay HJC1392A-3 Instructions / Assembly  ハイフローフィルター ( 減音タイプ ) 取扱説明書  Documentation Technique  

Copyright © All rights reserved.
Failed to retrieve file