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.
In this post I figured out how to use the PRU's access to the CRC module to perform a CRC16-CCITT calculation on >4bytes of data.
Below is my working code.
It takes some value I have written to registers r2~r3, and loads the first 5 bytes.
Then it prints the results to R28/R29.
CRC16: zero &r29, 4 ; Clear out 4 bytes of R29 ldi32 r25, 0x4 ; Load R25 with CRC module configuration xout 0x1, &r25, 4 ; Send R25 Configuration to CRC Module ldi32 r28, 0xFFFFFFFF ; Load R28 with SEED value for CRC16-CCITT xout 0x1, &r28, 4 ; Write R28 to CRC Module (sets SEED) xout 0x1, &r2, 5 ; Moving 5 bytes starting from R2 into CRC module NOP ; Add some delay NOP ; Add some delay NOP ; Add some delay NOP ; Add some delay NOP ; Add some delay NOP ; Add some delay xin 0x1, &r28, 4 ; Reading CRC result into R28 xin 0x1, &r29, 4 ; Reading CRC result into R29
My problem is with the "xout" command.
xout 0x1, &r2, 5 ; Moving 5 bytes starting from R2 into CRC module
Here, I am specifically declaring I want to send the CRC module "5" bytes of data.
But, is there a way I can make this number a variable?
That is, I would prefer to do something like this:
xout 0x1, &r2, r12 ; Moving xx bytes from R2 into CRC module
Extra Question:
The AM243x has API for CRC calculation on main cores. (link)
Section 12.6.3.3.4 PSA Signature Register from the TRM lists the 64-bit Polynomial used with the CRC module.
Can this polynomial be changed? i.e. use the CCITT polynomial that the PRU CRC module provides?
Please refer to PRU programming manual for details on XOUT instruction https://www.ti.com/lit/ug/spruij2/spruij2.pdf
As I can see it needs to be an immediate value, it cannot be a register.