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-MSPM0G3507: Using cross-triggering to start two timers simultaneously

Part Number: LP-MSPM0G3507
Other Parts Discussed in Thread: MSPM0G3507, SYSCONFIG

I have a project that requires two timers (currently TIMG6 and TIMG7, although that can change).  They must be started simultaneously.  I've used SYSCFG and calls within driverlib to set up the timers, and if I issue consecutive calls to DL_Timer_startCounter() I can start the two and see that they run as I expect.  However, this doesn't quite start them simultaneously.

I've used the SYSCFG pages to set TIMG6 as "main" and TIMG7 as "secondary" with an input source set to Timer2 (based on the table 8-16 in the MSPM0G3507 datasheet).  I can't work out whether this is correct, and if it is, what single function I need to call (or register to access) to simultaneously start the two timers.

The text in the reference manual, 23.2.7, specifically mentions starting counts simultaneously but I can't quite get it going.  Am I doing something wrong?

  • Hi Alan,

    Welcome to the E2E forums.

    Your setup sounds correct to me. 

    Try the function DL_TimerG_generateCrossTrigger(GPTIMER_Regs *gptimer) to start both. You will want to pass your TIMG6 instance name as the argument. 

    Best Regards,
    Brandon Fisher

  • Brandon

    Thanks for the welcome, and for the suggestion.  However, I can't see it starting the timers.  At the point where I call DL_TimerG_generateCrossTrigger(), neither of the timers has its EN bit set in the CTRCTL register.  Is this correct - do I need to have enabled them prior to generating the cross trigger?

    Alan

  • Hi Alan,

    You see neither of your timers triggering correctly when you generate the cross trigger?

    Can you share an image of your settings in sysconfig. For your main and secondary if possible.

    You can also take a look at our cross trigger example in the SDK Here: https://dev.ti.com/tirex/explore/node?node=A__AEYdEsehvSmkpYh.kbroGA__MSPM0-SDK__a3PaaoK__LATEST&placeholder=true

    Best Regards,
    Brandon Fisher

  • That's correct, I don't see any activity on my timers when I generate the cross trigger.

    For context, each timer is set to raise an event on Load event which is used to toggle a GPIO, in order to generate a specific sequence of pulses on two GPIO lines.  Each event is also connected to a DMA channel (as I'm using 1:2 splitter events) which causes DMA to load a different LOAD value into the timer.  When I say I don't see timers running when I generate the cross trigger, what I mean is that I'm not seeing any change in GPIO output (which I do see when I start the timers "manually" one after each other).

    My two timers are configured as follows:

    I've noticed in the auto-generated code there is a line as follows:

    DL_TimerG_setExternalTriggerEvent(TIMER_EX_DR1_INST,DL_TIMER_EXT_TRIG_SEL_TRIG_1);

    I'm not clear why it's chosen trig_1 for the main timer in this case.

  • Hi Alan,

    Those settings look correct. What version of SysConfig and the SDK are you using?

    If you open the registers view during a debug  session (View->Register), and look at the timg7.TIMG7_COUNTERREGS.TIMG7_CTR register while it is running do you see the counter incrementing? I want to be sure this is a timer issue and not something to do with the event configuration to those GPIOs or the DMA reload that is occurring. 

    Best Regards,
    Brandon Fisher

  • I have several versions installed on my PC, but I'm pretty certain (as I've created the project in the last few days) that it's using the latest I have installed - MSPM0 SDK 1.20.0.05, SysConfig 1.18.0.

    If I start my timers running using two consecutive calls to  DL_Timer_startCounter() (with TIMG6 and TIMG7 as parameters) then I can see the TIMGx_CTR registers change each time I pause the debugger after starting.  If I replace those two calls with a single call to  DL_Timer_generateCrossTrigger(TIMG6) then those registers are zero on every pause of the debugger.

  • Hi Alan,

    Please try the attached project.

    It will generate a cross trigger from TIMG6 that also triggers TIMG7. I did find that the ETSEL for the main timer has to be correctly set to cross trigger from itself. Sysconfig doesn't seem to be setting those values correctly right now, but when you look at the main code you will see where I change the ETSEL value, its the same function as the one you pointed to earlier. You should see PWM output on PA28 and PB6 when you debug this code. 

    I am not exactly sure why your secondary timer wasn't at least triggering, but please try this code and let me know if you see the PWM being output.

    Best Regards,
    Brandon Fisher

    general_purpose_timer_cross_trigger_LP-MSPM0G3507.zip

  • Thanks.  I can load your project and see that there is output on the pins you listed, and also the counter registers changing when I stop the debugger.  Unfortunately opening your project appears to have stressed Code Composer (Theia) into a semi-permanent state of "Initializing".  However, when it recovers I'll compare your settings against mine to see if I can see a difference.

    Is there a reason you used the "TIMER - PWM" setup rather than the straightforward "TIMER" tab?  Was this just to get a visible output of counter behaviour, or is it likely that some part of the setup will be different?

  • Alan,

    Is there a reason you used the "TIMER - PWM" setup rather than the straightforward "TIMER" tab?  Was this just to get a visible output of counter behaviour, or is it likely that some part of the setup will be different?

    I used TIMER-PWM only because it was what my previous example code already was using. The code generated by the TIMER section when configuring the cross trigger should hopefully be the same, but if you see that matching the settings doesn't make a difference please let me know.

    It is possible that SysConfig is doing something differently for some reason, and I can dive into that on my end if it makes sense. 

    Best Regards,
    Brandon Fisher

  • I've attached what should be a minimal example of my attempts.  If I comment out the cross-trigger lines at the end of main() and replace them with the DL_Timer_startCounter() lines I can see the output.  Ultimately I need to stop the timers as well, but that's a problem for a different day.

    empty_mspm0g3507_nortos_gcc.zip

  • Having gone through your project and the settings, I can't understand what's different about them to cause mine to fail to trigger.  Are you able to load my project and see the same results?

    Also, while looking through the generated code I can see that there is a call to DL_TimerG_generateCrossTrigger() inserted into the init code.  I'm not sure I understand the intent of this, particularly as you said that SYSCONFIG was generating invalid ETSEL configuration.

  • Hi Alan,

    I actually took a look at your code this morning and I think the problem is actually due to a difference in SysConfig code generation for TIMER vs TIMER_PWM.

    Can you changing your code to trigger the timers to the below? 

        // Trigger timer(s)
        TIMER_EX_DR1_INST->COUNTERREGS.IFCTL_01[0] |= DL_TIMER_CC_IN_SEL_TRIG;
        TIMER_EX_DR1_INST->COUNTERREGS.CCCTL_01[0] |= DL_TIMER_CC_LCOND_TRIG_RISE;
    
        TIMER_EX_DR3_INST->COUNTERREGS.IFCTL_01[0] |= DL_TIMER_CC_IN_SEL_TRIG;
        TIMER_EX_DR3_INST->COUNTERREGS.CCCTL_01[0] |= DL_TIMER_CC_LCOND_TRIG_RISE;
    
        DL_Timer_setExternalTriggerEvent(TIMER_EX_DR1_INST,DL_TIMER_EXT_TRIG_SEL_TRIG_2);
        DL_Timer_generateCrossTrigger(TIMER_EX_DR1_INST);

    The extra code I added to configure IFCTL and CCCTL doesn't have to happen exactly there in the sequence, it can be anywhere as long as its before we generate the software cross trigger. 

    Best Regards,
    Brandon Fisher

  • Thanks, that made the difference (and also increased my understanding of the complexities of configuring the timers!).  Is this an error in the SYSCONFIG code generation that might be fixed in the future, or is it an error in my understanding that I need to remember for the future?

  • Alan,

    Leave this in your code for now. I have filed this as a bug internally, so I expect it will eventually get fixed. SysConfig makes some assumptions about the desired behavior of certain peripheral to keep the number of options from making it unusable. With timers this is especially true since there are so many configuration combinations. Here I think its a fair assumption that if you are setting up to cross-trigger from software you want those IFCTL and CCCTL bits set as shown above. 

    When it does get updated, if you update SDK and Sysconfig versions there shouldn't be any issue with configuring these registers twice, so it won't break your current code. 

    Best Regards,
    Brandon Fisher