oPossum, from the 43oh Forums, derived the 15 channel PWM with serial control from his initial 16 channel PWM example.

The ISR has be extended to handle PWM and async serial reception. The first timer capture/compare is used for timing the serial bits and the second is used for PWM. The PWM code is unchanged, but now is only executed when the interrupt vector indicates capture/compare 2 match. The serial code begins in capture mode. When a falling edge is detected the mode is changed to compare to sample in the middle of each data bit and the stop bit. A ring buffer is used to prevent loss of received data. Two test cases are provided.

The first allows the brightness of the Lauchpads LED to be set using 0 to 9 and a to j.

The second test case implements a simple serial protocol to set the PWM value of all 15 outputs. The packet format is:

0x55 0xAA PWM0 PWM1 …… PWM13 PWM14 Checksum

Addressing could easily be added to allow multiple MSP430 on the same serial line. Since this code uses only a single TimerA module, it can run on any MSP430 with a TimerA.

The video below is a running example of the 16 channel PWM code:

via Four-Three-oh! MSP430 Forums • View topic – 15 channel PWM with async serial control.

Pin It on Pinterest