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/TMS570LS1224: How to use Pulse Width Modulation (PWM) to auto change the brightness of a LED

Expert 1660 points
Part Number: TMS570LS1224
Other Parts Discussed in Thread: HALCOGEN

Tool/software: Code Composer Studio

hello everyone,

 How to use Pulse Width Modulation (PWM) to auto change the brightness of a LED 

  • Hello,

    PWM can be generated using ePWM module. APIs generated by HALCoGen for ePWM module can be used to change duty cycle and if PWM is driving LED the intensity is changing according to Duty Cycle of PWM. Another way to generate PWM is by using N2HET.

  • Hello Miro,

    i created a project using PWM (HET module ) to control the LED intensity manually using duty cycle .

    but my question is how to make the led  increase it's light intensity linearly ( from no light to full intensity ) (auto adjust led brightness)

     

     

  • Hello,

    HALCoGen generates APIs for PWM using N2HET. For example you can use pwmSetDuty to change Duty Cycle of PWM. The input parameter is Duty cycle in percent (0-100%).

    You can see this link that shows how to use pwmSetDuty:

    If you change the duty from a 0 to 100%  in a loop with some delay you will see LED dimming.

    Also, you can see in Project 1 how brightness can be controlled (blinking frequency is controlled by the ambient light sensor).

    Project 1 can be downloaded from git repository:

  • thanks so much