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.

Compiler/MSP430G2231: MSP430G2231

Part Number: MSP430G2231


Tool/software: TI C/C++ Compiler

please help me to generate PWM signal where I can change my duty cycle or on-off period with switching frequency. I had done some coding but in that, I am getting some random frequency and not what I want.

  • Hi,

    to generate a PWM on your MSP430G2231 device you can use the integrated Timer A and set the desired frequency and duty cycle by adjusting the CCRx and CCR0 registers.

    In general the TACCR0 register defines the period, the TACCRx register defines the duty cycle. Please check the Timer_A register settings in the MSP430x2xx User's Guide Timer_A section for more details.

    To get started you can take a look at the Code examples provided in the  MSP430G2231 Software Section. You find some PWM examples for the device that you can test.

    In case this doesn't help you solve your issues, please add some more details on your current code.

    Best regards,

    Britta

  • easy: github.com/.../MSP430G_F2

    get pwmta0.h/c, or pwmta1.h/c or pwmtb0.h/c if your chip has it, or you can port it whatever timers you may have. the code was written originally for the FR5 series but works on F2/G2 series as well.
  • Hi,
    could the examples help youn to get started with your PWM?
    Please click the "Verify answer" button in case the posts solved your issues.
    Also, let us know if you need further assistance.

    Thanks and best regards,
    Britta

**Attention** This is a public forum