I am trying to develop a delay generator that can generate 50 "pulses" within a short amount of time and then hold for a much longer time, then repeat. I am familiar with using the MSP 430 as a constant PWM source, but I am not sure what the best approach is for Pulsing, ie, PWM for x pulses then hold.

I have attached a drawing of the problem, and I will add my code so that anyone can see my approach to the problem.

I am still new to using MSP430, most of my experience is with Arduino, so my code may not work as intended (it has a problem). I am more so interested in how to approach the problem then troubleshooting the code I attached.

![Drawing of Problem statement](https://i.stack.imgur.com/pGQag.jpg)

```
#include <msp430.h>
int i;

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
  P1DIR |= BIT2;                            // P1.2 output
  P1SEL = BIT2;                             // Select PWM function for P1.2
  P1REN = BIT1;                             // enable pull up resistor for button P1.1
  P1IE |= BIT1;                             // Interrupt enabled for P1.1
  P1IES |= BIT1;                            // Interrupt active on falling edge
  __bis_SR_register(GIE);                   // Global Interrupt Enable
  __no_operation();                         // For debugger
}

#pragma vector = PORT1_VECTOR
  __interrupt void PORT_1(void) {
      for (i = 50; i = 0; i--) {
          TA0CCR0 = 50000;                  // PWM Period
          TA0CTL = TASSEL_2 + MC_1;         // SMCLK, upmode
      }
      P1IFG &= ~BIT1;
  }

```