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.

CCS: [CC3220S/SDK4.10] The questions about Timer

Other Parts Discussed in Thread: CC3220S

Tool/software: Code Composer Studio

Hi Ti,

I am trying use Timer to control LED and I already checked the timerled.c on driver folder, but still have something confuse me. Please help me to clarify. Thanks.

1. How many timer I can use? According programming guide, the number is 8, right?

18.5.2.5 Timer Control
Up to 8 timers may be defined by the scripting tool, each with a 1 second resolution, and in a one-shot or multiple-shot mode. The timers remain active in LPDS.

2. What is the relationship between timer and PWM? If we want to have 4 PWM LEDs on our project, is that possible?

3. When I try to Timer_open the Timer0, anything looks good. But when open Timer1 and Timer2, always fail to open, why?

Regards, Eric.

  • Hi Eric,

    The CC3220 has 4 general-purpose timer modules that can be split into 2 16-bit timers each, so up to 8 hardware timers. PWM pins use these timer modules. Please see the Technical Reference Manual for how these are shared.

    You can also use software timers (handled by the RTOS) instead of a hardware timer. These are better in a low power application because the MCU can sleep while the timer is running. The application MCU cannot enter LPDS if a hardware timer or PWM is running. Check out the POSIX timers (timer_create, timer_settime, etc.) in source/ti/posix. These timers are used in demo examples like provisioning and Out of Box.

    For hardware timer configuration in your application, you need a new instance for each timer.

    Best regards,

    Sarah

  • Hi Sarah,

    Thanks. So far, I do not have permission to access the Technical Reference Manual page. I will ask support to help me out.

    One simple question, if we have four PWM LEDs on CC3220S and one PWM LED is always working(maybe breathing), does it mean MCU always can not enter LPDS? If yes, what can I do if  PWM always works and we need LPDS? Thanks.

  • Hi Sarah,

    Yes, I can create 1 PWM LED and 4 Timers with 16bit resolution.

     PWM1.$name                = "CONFIG_PWM_1";

     PWM1.timer.$name          = "MyTimer1";      

     PWM1.timer.$assign        = "Timer3";

     PWM1.timer.pwmPin.$assign = "GP11";

     Timer1.$name         = "CONFIG_TIMER_0";

     Timer1.timer.$name   = "MyTimer1";

     Timer1.timer.$assign = "Timer0";

     Timer2.$name         = "CONFIG_TIMER_1";

     Timer2.timer.$name   = "MyTimer1";

     Timer2.timer.$assign = "Timer0";

     Timer3.$name         = "CONFIG_TIMER_2";

     Timer3.timer.$name   = "MyTimer1";

     Timer3.timer.$assign = "Timer1";

    Timer4.$name         = "CONFIG_TIMER_3";

    Timer4.timer.$name   = "MyTimer1";

    Timer4.timer.$assign = "Timer1";

    When I use Timer_open to open CONFIG_TIMER_0 and CONFIG_TIMER_1 are okay. But when I try to open CONFIG_TIMER_2 and CONFIG_TIMER_3 are always failed. Any ideal? Thanks.

  • Hi Sarah,

    Could you please help me out? Thanks.

  • Hi Eric,

    The application MCU cannot enter LPDS if the PWM is running. You can use a software timer as I described in my previous post. I suggest using it to toggle the LED.

    I am able to successfully start 4 hardware timers according to your configuration above by defining a new Timer_Handle for each instance (so I have timer0, timer1, timer2, timer3). Make sure you are not trying to configure a 16-bit timer to a period that is too large for the buffer.

    Best regards,

    Sarah

  • Hi Sarah,

    Thanks, because the LEDs on our board, we would like to use PWM to control it. For LPDS feature, we think we need to take more time to make sure it is correctly operating.

    And, could you please pack your testing code of successfully start 4 hardware timers? I would like to try it. Thanks.

  • Hi Eric,

    I made changes to the timerled example for CC3220S. My timerled.c and .sysconfg are attached.

    /cfs-file/__key/communityserver-discussions-components-files/81/timerled.c

    /cfs-file/__key/communityserver-discussions-components-files/81/timerled.syscfg

    Best regards,

    Sarah

  • Hi Sarah,

    Thanks. I will try it now.