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.

TMS320F28379D: CLB Counter Event Load Register is Overwritten by the HLC

Part Number: TMS320F28379D

Greetings,

In our CLB implementation, a counter, C0, is used to generate pulses via the zero, match1, and match2 outputs.  At the beginning of the transaction there is a rising edge at the EVENT input which causes the counter to load the LOAD VALUE into C0.  Later in the transaction, the HLC is used to load R2 into C0.  This is the only instruction for the  HLC event, and no other HLC events are being used.

The first transaction works perfectly.  But when the second transaction begins and the EVENT signal is generated, instead of the LOAD VALUE appearing in the counter, the R2 value is loaded instead.  I can find nothing in the TRM which suggests that this will happen.  Is this the expected behavior, or did I overlook something in the literature?

In debugging this, I also noted that a write to the LOAD VALUE register also results in the value being written to C0, without needing an event.  Is this expected too?

Thank you,

Ed

  • Ed,

    So to summarize:

    1. COUNTER mode = LOAD

    2. COUNTER EVENT signal is connected to?

    Updating the LOAD_val should not automatically update the COUNTER C0 register. only on an EVENT or an HLC triggered instruction should the C0 be updated. What is the EVENT signal?

  • Nima,

    1. Yes

    2.  The CLB_GP_REG.  So the 28x controls the event input of the counter.

    I expected this answer, so I created a small project, which uses none of our IP, but demonstrates the issue.  I could zip it up and send it to you if you like.  If so, please tell me how to attach it.

    Thanks,

    Ed

  • Yes just send me your C file and your syscfg file. I will import them into an example project on my side!

    Is your EVENT signal high when you write to the COUNTE Cx?

  • The project has several files including the syscfg file.  I have zipped them up, but I can't find a way to attach the file.  It seems to want an image or video file.

    In the attached project, the EVENT signal is toggled high and low.  In our IP, the signal will go high for a prolonged period of time and then go low.  But in neither case is LOAD_VAL written during the EVENT signal’s high time.  Does a high value on EVENT cause a different behavior when LOAD_VAL is written?

    Thank you,

    Ed

  • OK.  I’ve combined the files into a single C file which includes the clb_config.h output from the build of the syscfg file, and copied it and the syscfg files below.  Hope you can see these.  If you put the C0_x variables in order in the Expressions window, you can see the evolution of the C0 value under the various stimuli.

    Ed

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    ///////////////////////////////////////////////////////////
    //
    // HLC Overwrites Event Load Value
    //
    ///////////////////////////////////////////////////////////
    #include "clb_config.h"
    /////////////////////////////////////////
    // Data types for this experiment.
    typedef unsigned int uint16;
    typedef int int16;
    typedef unsigned long uint32;
    typedef long int32;
    /////////////////////////////////////////
    /////////////////////////////////////////
    // Access control
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    // These arguments were used when this file was generated. They will be automatically applied on subsequent loads
    // via the GUI or CLI invocations. Run CLI with '--help' for additional information on how to override these arguments.
    // @cliArgs --device "CC3200" --package "Default" --part "Default" --product "CLB Configuration Tool@1.0.0"
    // @versions {"data":"2019051709","timestamp":"2019051709","tool":"1.1.792","templates":"2019051709"}
    var TILE = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/TILE");
    var TILE1 = TILE.addInstance();
    var TILE2 = TILE.addInstance();
    var TILE3 = TILE.addInstance();
    var TILE4 = TILE.addInstance();
    // clock_period - Period of the clock (in Nano Seconds) used for simulation in System C
    TILE.clock_period = 5;
    // reset_duration - Time at which reset signal is deassrted, specified in Nano Seconds
    TILE.reset_duration = 1;
    // sim_duration - Duration of the simulation (in Nano Seconds)
    TILE.sim_duration = 2000;
    // Name
    TILE1.$name = "Tile1";
    // Name
    TILE1.BOUNDARY.$name = "BOUNDARY0";
    // in0
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Let me dig into your example and I will get back to you!

  • Ed,

    I just ran the following scenario, and you are correct. When the CLB counter is in Load mode, and the load value is change:

    CLB_configCounterLoadMatch(CLB1_BASE, CLB_CTR0, 5000, 8000, 0);

    Whether the CLB is enabled or disabled, the C0 (counter's active counter value) is also updated to the LOAD value. WITHOUT AN EVENT signal.

    This is certainly something that we will document in the TRM.

    Nima

  • For your reference:

    clb_ed.c
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    #include "driverlib.h"
    #include "device.h"
    #include "clb_config.h"
    #include "clb.h"
    __interrupt void clb1ISR(void);
    #define EVENT_TIMER 1
    #define ENABLE_TIMER 2
    #define COUNTUP_MODE 4
    void main(void)
    {
    Device_init();
    Device_initGPIO();
    Interrupt_initModule();
    Interrupt_initVectorTable();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    clb_ed.syscfg

    In the code, you can see that if you run this, it will halt on ESTOP0.

    The values are:

    I will add this to the TRM as a note. 

  • Ahh.  You took my experiment a step further.  Great information.  Thank you!

    In my experiment, I also used the HLC to load C0, and the appearance is that the LOAD_VALUE register was written too because, after the HLC event, when the counter event occurs, C0 is written with the value from the HLC, not the original value written to the LOAD_VALUE register.  Is it possible that the HLC writes to C0 through the LOAD_VALUE register using the mechanism you illustrated above?

    Thank you,

    Ed

  • I dont think HLC can update the LOAD_val. HLC directly updates the C0. We can check this too to confirm!

  • Thank you for checking.  The middle step in my experiment uses the HLC to load C0 with a value, in R2, which is different from the value loaded into LOAD_VALUE.  After the HLC event, it shows that C0 contains the value in the HLC's R2 register.  After a reset of the counter to put 0 into C0, the counter event is toggled and the R2 value can then be seen in C0, not the original LOAD_VALUE.

    Thanks,

    Ed

  • I'm going to code this too really quick and we can add this to the TRM as well.

    Nima

  • Yes the HLC MOVing value from Rx to C0, updates the LOAD_val as well.

    Main.c file

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #include "driverlib.h"
    #include "device.h"
    #include "clb_config.h"
    #include "clb.h"
    __interrupt void clb1ISR(void);
    #define EVENT_TIMER 1
    #define ENABLE_TIMER 2
    #define COUNTUP_MODE 4
    #define HLC_TRIG 8
    void main(void)
    {
    Device_init();
    Device_initGPIO();
    Interrupt_initModule();
    Interrupt_initVectorTable();
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    SysCfg File

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    /**
    * These arguments were used when this file was generated. They will be automatically applied on subsequent loads
    * via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
    * @cliArgs --device "F2837xD" --package "F2837xD_176PTP" --part "F2837xD_176PTP" --product "CLB Configuration Tool@4.0.0"
    * @versions {"tool":"1.10.0+2029"}
    */
    /**
    * Import the modules used in this configuration.
    */
    const TILE = scripting.addModule("/utilities/clb_tool/clb_syscfg/source/TILE");
    const TILE1 = TILE.addInstance();
    /**
    * Write custom configuration values to the imported modules.
    */
    TILE.clock_period = 10;
    TILE.sim_duration = 100000;
    TILE1.$name = "TILE1";
    TILE1.BOUNDARY.$name = "BOUNDARY0";
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Everything makes sense now.  Thank you again for all your help Nima.

    Regards,

    Ed