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.

AM5729: PRU IEP Timer Configuration issues

Part Number: AM5729

Hi all,

I'm attempting to use a hardware timer in the PRU to manage parts of the program running on it.  I've assumed the IEP is what I should use for this.

The goal is to have the timer running continuously, automatically wrap to 0 when it overflows so that when read and used with unsigned difference maths, it just measures the time difference since the last reading, regardless of matching and wrapping back to 0 from 0xFFFFFFFF.

I've finally understood how to slow the timer down with slow compensation as a clock prescalar, but now I need to limit it to 32 bits, to work with normal registers as 64 bit isn't needed.

I've attempted to configure the timer to compare and reset when its lower counter register is full at 0xFFFFFFFF, but I don't believe its properly resetting to 0.

Looking at page 73 of the C/C++ compiler manual v2.3, it looks like int and long data types are exactly the same, is this correct?

I've pasted my code blow which just initialises the timer at 200MHz to compare and reset on match for the CMP0 event when it reaches the full value in the lower counter 0xFFFFFFFF.

        /* Clear SYSCFG[STANDBY_INIT] to enable OCP master port */
        CT_CFG.SYSCFG_bit.STANDBY_INIT = 0;
        /* Disable counter */
        CT_IEP.GLB_CFG_bit.CNT_ENABLE = 0;
        
        // Reset Count register regs high & low.
        CT_IEP.LOW_COUNTER = 0x00000000;
        CT_IEP.HIGH_COUNTER = 0x00000000;
        
        /* Clear overflow status register */
        CT_IEP.GLB_STS_bit.CNT_OVF = 0x1;
            
                
/* Clear compare status */
        CT_IEP.CMP_STS_bit.CMP_HIT = 0xFFFF;
        
      
            //Set timer match compare values
            CT_IEP.CMP0_0 = 0xFFFFFFFF;
            CT_IEP.CMP1_0 = 0;
            
            //Timer reset value on match
            CT_IEP.LOW_CNT_RST = 0x00000000;
            CT_IEP.HIGH_CNT_RST = 0x00000000;
            
            // Reset on event
            CT_IEP.CMP_CFG_bit.CMP0_RST_CNT_EN = 0x1;
                        
            //Enable CMP0 (16 bits in total, 1st is CMP0...16 is CMP15)
            CT_IEP.CMP_CFG_bit.CMP_EN = 0x0001;
            
            
            /* Clear the status of all interrupts */
            CT_INTC.SECR0 = 0xFFFFFFFF;
            CT_INTC.SECR1 = 0xFFFFFFFF;
            
            
            /*Currently commented out 
*This section below is to enable "slow compensation". * Essentially a prescaler to divide the 200MHz clock //Enable compensation counter mode CT_IEP.GLB_CFG_bit.CMP_INC = 1; // Disable fast compensation, off when using DEFAULT_INC or SLOW_COMPEN. On when need to speed up the IEP clock. CT_IEP.COMPEN_bit.COMPEN_CNT = 0x0; //Slow Compensation to slow the timer down (prescaler) Needs CMP_INC enabled CT_IEP.SLOW_COMPEN = 200; */ /* This Section below disables compensation so IEP clock * runs either as normal, or increments more than 1 count per clock cycle. */ //Disable compensation counter mode CT_IEP.GLB_CFG_bit.CMP_INC = 0; // IEP counter increments by 1 per clock cycle CT_IEP.GLB_CFG_bit.DEFAULT_INC = 1; // Enable IEP counter, final state to activate all timer settings. CT_IEP.GLB_CFG_bit.CNT_ENABLE = 1;

  • Hi all,

    Is there a Linux command to view and change PRU and other register values in the AM5729 chip?

    I ask, so one can view what's happening, and see if they keep their expected values.

    This has become an issue, because I've seen some instances where the PRU clock settings don't seem to change in terms of speed until the board has been restarted, I've seen this for the IEP.  Previously, likely due to undeclared interrupts, the pru_rproc module has frozen Linx when loading PRU firmware, or the PRU wouldn't respond to stopping and starting.  The only option was to restart the board.

    I'll need to find out how Linux may correctly do a hardware reset of the PRU.

    The ARM CPU is supposed to be able to reset the PRU, 2 types, including a full hardware reset.

    In version L of the TRM, on page 7358, it details this on the PRU side, around page 459 is where the main CPU clocking and power/reset system is described with a table showing other parts of the chip, including the 2 PRU subsystems.

    If there's no specific command, then I'll make a script to change the needed clocking and hardware control registers.

    Thanks,

    Fisher

  • Hi all,

    I've set the compare value of CMP0 to 0xFFFFFFFF which is the lower count register being totally full, and CT_IEP.SLOW_COMPEN = 0x1 (might be slowest setting).

    This does trigger the "HIT" flag for CMP0, but the counter value resets to around 214564 (dec)  or 0x34624 in Hex

    When I set CT_IEP.SLOW_COMPEN = 0xFFFFFFFF, the timer resets to about 2099556.  The timer seems faster on this compensation setting compared to 0x1.

    I'm reading these values through a character display, so a few cycles are used to print characters to it etc and I assume that has an impact on the timer value captured.

    Fisher

  • Hi,

    >I've attempted to configure the timer to compare and reset when its lower counter register is full at 0xFFFFFFFF, but I don't believe its properly resetting to 0

    TI : How do you find the wraparound and reset values ?

    >Looking at page 73 of the C/C++ compiler manual v2.3, it looks like int and long data types are exactly the same, is this correct?

    TI : Yes

    >I've pasted my code blow which just initialises the timer at 200MHz to compare and reset on match for the CMP0 event when it reaches the full value in the lower counter 0xFFFFFFFF.

    TI : Can you download the Ethernet/IP component here and compare your initialization with the function TimeSync_drvIEPConfig() in the file icss_timeSync_init.c ? This will tell you if everything is configured correctly. On top of this you can enable CMP0 and set the CMP0 value for wraparound.

    >Is there a Linux command to view and change PRU and other register values in the AM5729 chip?

    TI : You can access as a memory mapped register via devmem2

    >If there's no specific command, then I'll make a script to change the needed clocking and hardware control registers.

    TI: There's no specific command. You can take a look at the Linux PRU driver in kernel under drivers/net/ethernet/ti/prueth.c

    Let me know after you have compared your initialization code. I can perform a quick test here to see if I can reproduce the issue.

    Regards

    Vineet

  • Hi Vineet,

    Thanks a lot for your reply, I'll look into the initialisation function and get back to you.

    Where can I find the devmem2 app?

    In terms of reset/wrap around values. I've set it to reset to zero on compare at a full 32 bit value as in my previous post with the code:

    //Set timer match compare values
    CT_IEP.CMP0_0 = 0xFFFFFFFF;
    CT_IEP.CMP1_0 = 0;
    //Timer reset value on match
                CT_IEP.LOW_CNT_RST = 0x00000000;
                CT_IEP.HIGH_CNT_RST = 0x00000000;
    // Reset on event
    CT_IEP.CMP_CFG_bit.CMP0_RST_CNT_EN = 0x1;
                            
    //Enable CMP0 (16 bits in total, 1st is CMP0...16 is CMP15)
    CT_IEP.CMP_CFG_bit.CMP_EN = 0x0001;

    I didn't realise TI had some PRU source code, this is great as is a resource for me to look through later.

    I see the TI industrial packages are a mix of source, libraries, and binary firmware. Have the libraries been compiled from the same sources?

    Is the source part of what's in the firmware?

    Is this the full documentation resource for the industrial software link you just sent?

    software-dl.ti.com/.../Industrial_Protocols.html

    Is this industrial FW the only code examples besides the PRU support SW package, or is there some other source examples that run on the PRU?

    Thanks,
    Fisher

  • Hi Fisher,

    >Where can I find the devmem2 app?

    TI : It should be part of the filesystem

    >I see the TI industrial packages are a mix of source, libraries, and binary firmware. Have the libraries been compiled from the same sources?

    TI : Yes

    >Is the source part of what's in the firmware?

    TI : Industrial firmware sources are not public. Only Dual MAC firmware which is part of PDK (Download this SDK and go to pdk/packages/ti/drv/icss_emac/firmware) is public.

    > Is this the full documentation resource for the industrial software link you just sent?

    TI: Yes, all documentation will be cross linked from here. Also see this post for archived information.

    > Is this industrial FW the only code examples besides the PRU support SW package, or is there some other source examples that run on the PRU?

    TI : There is a functional IEP example in PDK (Dual EMAC firmware), please check it out. Link above.

    Regards

    Vineet