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.

LP-AM261: What is the purpose of PRU register C28?

Part Number: LP-AM261

Tool/software:

Hi!
In the PRU linker command script I find the following:

PAGE 2:
      /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */
      /* 32 KB Shared general purpose memory RAM with ECC, shared between PRU0 and PRU1 */
      PRU_SHAREDMEM     : org = 0x00010000 len = 0x00008000
What does the part in bold mean? When is that supposed to be done and why?

Best regards
Daniel
  • Hi Daniel,



    The addresses in constants entries 24–31 are partially programmable. Their programmable bit field (nn_nn)
    (for example, c28_blk_index[3:0]) is programmable through the PRU CTRL register space from below address


    PRU assembly code to configure C28 to hold SMEM address

    ; Configure the Constant Table entry C28 to point to start of shared memory
    ; PRU_ICSSG Shared RAM (local-C28) : 00nn_nn00h, nnnn = c28_pointer[15:0]
    ; By default it is set to 0000_0000h so it will point to DMEM0 address
        
        ldi     R0, 0x0100
        sbco    &R0, C11, 0x28, 2
        
    ; example code to write into smem after configuring C28 with SMEM address
        ldi     R0, 0x1234
        sbco    &R0, C28, 0x0, 4



    Thanks & regards,
    Manoj.


  • Hi Manoj,
    I still don't understand why this is needed, because I have been able to transfer data R5<->PRU through SMEM without setting up C28. 
    I'm developing in C on the PRU, here's one example how I access the SMEM on the PRU side.

    #define PRUICSS_SHARED_RAM  0x10000U
    #define FW_SIGNATURE 0x55555555
    
     *shared_mem = FW_SIGNATURE;

  • I forgot to add this line to my code example

    volatile uint32_t *shared_mem = (volatile uint32_t *)PRUICSS_SHARED_RAM;

  • Hi Daniel,

    You code will get converted to similar to below code in assembly adding one PRU clock cycle extra:

    without C28

    LDI32  R1, 0x010000
    LDI32  R2, 0x55555555
    SBBO  &R2,  R1, 0, 4

    with C28

    LDI32 R2, 0x55555555
    SBCO &R2, C28, 0, 4


    When you are using c code, there should be way to inform compiler to use constant table while accessing SMEM, I will check this and let you know

    Thanks & regards,
    Manoj.

  • Hi Daniel,

    When you are using c code, there should be way to inform compiler to use constant table while accessing SMEM, I will check this and let you know

    you also need to add c code to configure  c28_blk_index[3:0] which I mentioned previously and make below changes in linker command file

    /* Specify the System Memory Map */
    MEMORY
    {
        PAGE 0:
          /* 12 KB PRU Instruction RAM */
          PRU_IMEM          : org = 0x00000000 len = 0x00003000
    
        PAGE 1:
          /* Data RAMs */
          /* 8 KB PRU Data RAM 0 */
          PRU0_DMEM_0       : org = 0x00000000 len = 0x00002000 CREGISTER=24
          /* 8 KB PRU Data RAM 1 */
          PRU0_DMEM_1       : org = 0x00002000 len = 0x00002000 CREGISTER=25
    
        PAGE 2:
          /* C28 needs to be programmed to point to SHAREDMEM, default is 0 */
          /* 32 KB Shared general purpose memory RAM with ECC, shared between PRU0 and PRU1 */
          PRU_SHAREDMEM     : org = 0x00010000 len = 0x00008000 CREGISTER=28
    }



    Refer 8.5.4.2 section of below documentation for more details :  pru_compiler_guide

    Let me know if you have any other questions

    Thanks & regards,
    Manoj.

  • Hi Manoj.
    I think I got it, thanks for the help!

    Daniel