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.

Is it possible to control a pin via PWM without setting PxSEL?

Other Parts Discussed in Thread: MSP430FR5725

Hello.  I was wondering if it is possible to control a pin via the PWM functionality of a timer without setting PxSEL |= BITn?  I have a pin that I would like to control via PWM, but it is not connected to a timer module, like TAx.n.  I am using the MSP430FR5725.  The pin description is "PJ.0/TDO/TB0OUTH/SMCLK/CD6". 

  • Hi

    I'm a bit of a beginner with MSP430 myself but I see your post has had no responses yet, so this might help (or stimulate some more responses).

    Generally I think it is not possible to do what you are asking.  Most microcontrollers have a number of pin options for given peripherals.  These options are constrained by the routing of the circuitry formed in the silicon structure of the chip.  To allow any peripheral to be routed to any pin would make for an overly complex routing structure, so options are limited to a few pins.  The pin you want to use can be used for a general digital I/O but can be alternatively used for the other functions listed in the pin description - you must set the micro up so the correct peripheral is routed to the pin (PxSEL).  As there is no silicon structure inside to permit a timer to be routed to that pin, you cannot do what you want.

    Your options are to swap pins around so that you can use one that can output a PWM signal or, if software overhead/timing is not an issue, attempt to implement one in software.  Tables 12 to 16 in the data sheet show the pin numbers that can be used for outputs from timers.

  • (With due respect to the prior poster,) This is certainly possible. Search the Forum (or Google) for "software PWM"

    The idea is to mimic the function of the hardware PWM in software, which is actually not so complicated. Store the "CCR" value in memory, set up your timer to trigger on "match" and "overflow", and wiggle the GPIO pin directly in the ISR. If (big "If") that's All your program is doing, you might get a better waveform using software delays rather than an ISR. As you search, you'll find examples of  doing this for multiple channels.

    The results won't be as accurate as those of hardware PWM -- you'll have jitter proportional to your interrupt latency. It will cost you some CPU time, and there will be a lower bound on your period and duty cycle. However, it will be quite adequate for many applications.