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.

PWM pins

Other Parts Discussed in Thread: MSP430FG4618

I need to produce several step signals from the msp430FG4618.

I have been told that any of the general I/o pins should work.  I will need a very high frequency though.

Do some of the Pins have a higher possible frequency than others?  How high?

Also, how do you change the frequency of a pin?

  • Hi Andrew,

    Yes, any DIO pin can provide a "slow" step signal, usually with some jitter in the frequency.  Both characteristics (slow and jittery) are due to software latencies.  Typically you would use a Timer (built into the MCU) to generate an interrupt every time you're supposed to change an output pin.  If you are driving more than one step signal, or if your MCU is doing anything else, you can end up with varying latencies from the timer interrupt to your software finally changing the output pin ( PxOUT ^= BITy; ).

    Plan on using about 50 MCLK cycles per step signal.  Maximum frequency would be about MCLK / (50*n) where n is the number of step signals.  You'll have to further reduce frequency or number of signals if your MCU is doing other things.  MCLK on the '4618 is up to 8MHz.

    If you need faster or more "stable" stepping, you'll need a timer pin (TA0, TA1, TA2, or TB0, TB1, ..., TB6) or an SPI clock pin (UCA0CLK, UCB0CLK, or UCLK1).

    For "stable" stepping (still slow), the timers are a great solution, giving you up to 10 such independent signals.  Your ISRs would set up the next toggle time, and the Timer would do the toggling for you, exactly on time, also invoking the ISR again.  This is a great way to go, but you need to pick from the right 10 MCU pins.

    For faster stepping, the timer pins are pretty limited because the whole timer (Timer A or Timer B) is set for just one frequency, and it's hard to count steps (if that's important to you).  The SPI clock pins allow you to count steps but only in increments of 8.  So for very fast stepping, there are only five such independent outputs available (one TAn, one TBn, UCA0CLK, UCB0CLK, and UCLK1).

    Jeff

  • Jeff Tenney said:
    (one TAn, one TBn, UCA0CLK, UCB0CLK, and UCLK1).

    Some MSPs have more than one TA (up to three).
    Also, you can abuse the DMA: set it up for external DMA trigger, moving one byte from one location to, well itself. You can then read the number of pulses in the transfer counter. However, this method wastes 2 or 4 MCLK cycles per pulse and cannot be used in LPM1 or up (as it requires MCLK, ending LPM temporarily, with all the wakeup latency).

**Attention** This is a public forum