5 Replies Latest reply on Jan 16, 2018 7:29 AM by e.pratt_1639216

    PWM Problem

    venu82450_3009436

      Hi ,currently i am using PWM in my project to generate a square wave  continuosly  and  it's working fine  as per below

       

      //ADC Initialization

          ADC_Start();

          ADC_StartConvert();

       

          //PWM Initialization

           PWM_Start();

         

          UART_Start();

       

       

       

        

          /* Start CYBLE component and register generic event handler */

          CyBle_Start(AppCallBack);

          /* Register service specific callback functions */

          CyBle_BasRegisterAttrCallback(BasCallBack);

          CyBle_HtsRegisterAttrCallback(HtsCallBack);

        

       

       

          WDT_Start();

       

       

        

          calculate_Data();

          /***************************************************************************

          * Main polling loop

          ***************************************************************************/

       

           char temp_buf[30];

          while(1)

          {

           

              #if 1

               memset(temp_buf,0,sizeof(temp_buf));

               calculate_Data();

              sprintf(temp_buf,"hot_temp :%.2fV\r\n",value);

              UART_UartPutString(temp_buf);

               memset(temp_buf,0,sizeof(temp_buf));

               sprintf(temp_buf,"voltage :%.2fV \r\n",value);

              UART_UartPutString(temp_buf);

               memset(temp_buf,0,sizeof(temp_buf));

               sprintf(temp_buf,"current :%.2fV \r\n",value);

               UART_UartPutString(temp_buf);

               memset(temp_buf,0,sizeof(temp_buf));

               sprintf(temp_buf,"pcb_Temperature_value :%.2fV \r\n",value);

               UART_UartPutString(temp_buf);

               CyDelay(5000);

              #endif

          

            

          }

       

       

       

      but if  i am using  CyBle_ProcessEvents();  then PWM  stop's and  i am not getting any waveform  as  per the code shown

       

      *********************PWM NOT working code

       

       

         ADC_Start();

          ADC_StartConvert();

       

          //PWM Initialization

           PWM_Start();

         

          UART_Start();

       

       

      while(1)

          { 

              /* CyBle_ProcessEvents() allows BLE stack to process pending events */

              CyBle_ProcessEvents();

             //  PWM_Start();

              /* To achieve low power in the device */

            

              LowPowerImplementation();

           

            

              /***********************************************************************

              * Wait for connection established with Central device

              ***********************************************************************/

              if(CyBle_GetState() == CYBLE_STATE_CONNECTED)

              {

                  /*******************************************************************

                  *  Periodically measure a battery level and temperature and send

                  *  results to the Client

                  *******************************************************************/      

                  if(mainTimer != 0u)

                  {

                      mainTimer = 0u;

                    

                      MeasureBattery();

                      CyBle_ProcessEvents();

                    

                      if(temperatureMeasure == ENABLED)

                      {

                         MeasureTemperature();

                         CyBle_ProcessEvents();

                      }

                  }

              }

      }