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.

CC2640: PWM

Part Number: CC2640
Other Parts Discussed in Thread: CC2650

Hello TI Community,

Currently I am developing firmware with detail information as below

1. MCU: TI CC2640

2. Debugger tool:  SmartRF06 Evaluation Board Kit

3. IDE: 

Code Composer Studio 
Version: 8.0.0.00016

OS: Windows 10, v.10.0, x86 / win32

4. BLE Stack: ble_cc26xx_2_01_00_44423

I would like to reduce the LED light intensity.I already did self researched and is being aware that I have to use task/timer/pwm and task_sleep in order to control the output of LEDs.

Another solution is duty cycle, for example, within 1 seconds, I will set LEDs is ON for 600ms and is OFF for 400ms (duty cycle is 60%) so that I can also reduce the LEDs light intensity.

However, I still don't know exactly the way I have to start. Could you please do a little favour and share me how to start from the scratches ?

Best Regards,

Richard.

8030.EMAIL CLARIFICATION.html

  • Hello Richard,

    I might not have time to follow you through stepbystep the whole process, but I can try to run the PWM example on CC2650LP and let you know how that works.

    C:\ti\tirtos_cc13xx_cc26xx_2_21_01_08\examples\TI\CC2650_LAUNCHXL\pwmled

    Questions:

    1. Do you have a TI DK (launchpad) to prototype on?

    2. Do you have a logic analyzer to verify output signals on PINs? If not this is highly recommended.

     

    Notes:

    1. please use the latest release ble_sdk_2_02_02_25 and tirtos_cc13xx_cc26xx_2_21_01_08.

    2. In the release notes for ble_sdk_2_02_02_25 the recommended and tested CCS version and compiler version is:

    CCS 7.4.0 (Build 15 or later) with  TI ARM Compiler 16.9.4.LTS

  • I ran the pwmled example successfully on the LP. I had to change the sleep duration for it to work smoothly:

    //    tskParams.arg0 = 50;
        tskParams.arg0 = 5000;

    You can also increase pwmPeriod to reduce intensity even further in addition to controlling the duty cycle (duty)

    When you integrate with a ble stack example try to disable power saving during implementation (xPOWER_SAVING).

  • Hi, I used Oscilloscope to check but there are not PWM  signal on desire GPIO port. I have a confusion:

    - I integrated PWM Driver into current TI KeyFob sample project and compiled, executed successfully.

    hPWM = PWM_open(CC2650_PWM0, &params);

    hPWM is not NULL when finishing PWM_open.

    I turn LED on before invoking pwm_job, PWM is not working

    I turned LED off before invoking pwm_job, PWM is not working also.

    In my program structure, I defined 2 function: pwm_int and pwm_job

    pwm_int will be initialized only one time when the program start.

    pwm_job will be in the  loop

    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    
    static void KeyFobDemo_taskFxn(UArg a0, UArg a1){
    
    // Initialize application
    
     KeyFobDemo_init();
    
     ///////////////////////////////////////////////////////////
    
     // Application main loop
    
     for (;;)
    
     {
    
        .......
    
        .......
    
        .......
    
        if (events & KFD_APR_EVT)
    
       {
    
         events &= ~KFD_APR_EVT;
    
         apr_drv();
    
       }
    
        .............
    
        .............
    
        .............
    
     }
    
    }
    
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    
    static void KeyFobDemo_init(void)
    
    {
    
          .........
    
          .........
    
          apr_inz();
    
    }
    
    //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
    
    *****************************************
    *										*
    *			Initialize					*
    *										*
    ****************************************
    */
    void apr_inz( void )
    {
      ......
      ......
      pwm_int();
    }
    
    /*
    *****************************************
    **
    *			                *
    *					*
    *****************************************
    */
    void apr_drv( void )
    {
      BYTE i;
      sw_job();
      ad_job();
      ble_connect_job();
      blower_job();
      check_charge();
      led_job();
      pwm_job(); 
      sw_clear();
       .........
       ..........
    }
    /*
    *****************************************
    *                                       *
    *                                       *
    *                                       *
    *****************************************
    */
    static void pwm_int(void)   //hvi1hc
    {
        PWM_Params params;
        //uint16_t   pwmPeriod = 3000;      // Period and duty in microseconds
        //uint16_t   duty      = 0;
        //uint16_t   dutyInc   = 100;
    
        PWM_Params_init(&params);
        //params.dutyUnit = PWM_DUTY_US;
        params.dutyUnit = PWM_DUTY_FRACTION;
        params.dutyValue = 10;
        //params.periodUnit = PWM_PERIOD_US;
        params.periodUnit = PWM_PERIOD_US;
        params.periodValue = pwmPeriod;
        //pwm1 = PWM_open(Board_PWM0, &params);
        hPWM = PWM_open(CC2650_PWM0, &params);
    
        if (hPWM == NULL) {
            //System_abort("Board_PWM0 did not open");
            Task_exit();
        }
        PWM_start(hPWM);
    }
    
    /*
    *****************************************
    *                                       *
    *                                       *
    *                                       *
    *****************************************
    */
    
    static void pwm_job(void)
    {
    
        PWM_setDuty(hPWM, duty);
        duty = (duty + dutyInc);
        if (duty == pwmPeriod || (!duty)) {
            dutyInc = - dutyInc;
        }
    
    }

  • 4540.EMAIL CLARIFICATION.html

    I also attached an email (HTML format) which described detail Steps I did to integrate PWM Driver into TI KeyFob Code.

    Kindly take a look and let me know if any.

    Many Thanks!

  • I used SmartRF06 Evaluation Board for debugging and flashing firmware code into target board which is using MCU CC2640F128RGZT.
  • Oh thanks, finally it worked ... I read TI PWM Driver and found out I misunderstood GPIO parameters, it should be its order by its address. I fixed and PWM worked. Feel great !