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.
Hello,
I am using PRU CRC16/32 module for communication data check with CRC16 (x16+x15+x2+1 ) mode.
I found that the accumulated CRC output results do not match to the CRC16 online tool.
For example, I pushed 0x1304 into CRC16 and get 0xc2b9 as the results, but the correct result should be 0xf30c.
Below is the programming code:
; CRC16 enable.
ldi32 r20, 0x00001304 ; original data
ldi r25.b0, 0 ; config CRC type
xout 1, &r25, 1
mov r29, r20 ; load CRC data
xout 1, &r29, 2 ; push CRC data to CRC16 module
nop
xin 1, &r29, 4 ; load the accumlulated CRC result into PRU
May I have your comments?
BR,
Chen
Hi Chen,
I tried to follow your code, it seems your observation is correct. Let me check internally with the expert on this.
Hi Chen,
1. As per TRM, R25 should be written 4 bytes at a time
There is some info missing in TRM please find below. It will be updated in next revision.
2. PRU ICSS is based on little endian architecture, so the input data should be given as 0413
3. Also For CRC16 mode, SW can read CRC_DATA_32_BFLIP[31:16] to get the correct bit order.
Please find the working code below.
; Copyright (C) 2023 Texas Instruments Incorporated - http://www.ti.com/ ; ; Redistribution and use in source and binary forms, with or without ; modification, are permitted provided that the following conditions ; are met: ; ; Redistributions of source code must retain the above copyright ; notice, this list of conditions and the following disclaimer. ; ; Redistributions in binary form must reproduce the above copyright ; notice, this list of conditions and the following disclaimer in the ; documentation and/or other materials provided with the ; distribution. ; ; Neither the name of Texas Instruments Incorporated nor the names of ; its contributors may be used to endorse or promote products derived ; from this software without specific prior written permission. ; ; THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ; "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ; LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR ; A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT ; OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, ; SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT ; LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ; DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY ; THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE ; OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ;************************************************************************************ ; File: main.asm ; ; Brief: Template asm file example ;************************************************************************************ ; CCS/makefile specific settings .retain ; Required for building .out with assembly file .retainrefs ; Required for building .out with assembly file .global main .sect ".text" ;************************************* includes ************************************* ; icss_constant_defines.inc: Defines symbols corresponding to Constant Table Entries .include "icss_constant_defines.inc" .asg R2, TEMP_REG DATA16 .set 0x0413 ;ASCII equivalent for "21" CRC_XID .set 0x1 ;******** ;* MAIN * ;******** main: init: ;---------------------------------------------------------------------------- ; Clear the register space ; Before begining with the application, make sure all the registers are set ; to 0. PRU has 32 - 4 byte registers: R0 to R31, with R30 and R31 being special ; registers for output and input respectively. ;---------------------------------------------------------------------------- ; Give the starting address and number of bytes to clear. zero &r0, 120 ; CRC 16 CRC_16: ZERO &R25, 4 XOUT CRC_XID, &R25, 4 LDI R29.w0, DATA16 ;Move the data to R29 register XOUT CRC_XID, &R29.w0, 2 ;Moving 2 bytes NOP XIN CRC_XID, &R28, 4 ;Reading CRC XIN CRC_XID, &R29, 4 halt ; end of program