1 Reply Latest reply on Jan 20, 2018 2:43 AM by JoMe_264151

    Alternating Pulse Generator Issue

      I am trying to create alternating pulses on two pins of a CY8C29466 and display a count of the pulses on an LCD character display. The attached code works to some extent, but basically the pulses stop alternating between the two pins after 10 cycles. I am using a counter to generate an interrupt and throw a flag that I am checking for in the main loop. Once the interrupt flag is detected, a second flag is toggled that should alternate what pin the pulse appears on. Relevant code:


      if (countFlag == TRUE)


                  Pin_C_Data_ADDR ^= Pin_C_MASK;

                  if (turnA == 0x0)


                      Pin_A_Data_ADDR |= Pin_A_MASK;

                      for (i = 0; i < 5000; i++);

                      Pin_A_Data_ADDR &= ~Pin_A_MASK;

                      turnA = 0x1;


                  else if (turnA == 0x1)


                      Pin_B_Data_ADDR |= Pin_B_MASK;

                      for (j = 0; j < 5000; j++);

                      Pin_B_Data_ADDR &= ~Pin_B_MASK;

                      turnA = 0x0;


                      LCDUpdate = TRUE;


                  countFlag = FALSE;



      I do not understand why this isn't working after 10 cycles. Any ideas?