PWM Problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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();

                }

            }

        }

}

0 Likes
1 Solution
Anonymous
Not applicable

You will not be able to run the PWM while in deep sleep I think, see here: PWM whilst in deep sleep

You should be calling the CyBle_ProcessEvents(); from main consistently, so don't comment that line out. If it is causing the PWM to crash/fail more, then you are not doing the bluetooth operations and handling correctly, for that see here: AN91267 - Getting Started with PSoC® 4 BLE | Cypress Semiconductor

If you can run the chip in debug mode, and catch the debug state when the PWM fails and crashes after 50s, then you should be able to get more information on what is going wrong, and be able to fix it.

View solution in original post

0 Likes
5 Replies
Anonymous
Not applicable
  • Your include needs to be changed from "Measure_Data.h" to "Data_measure.h"
  • Change the interrupt priority on the BLE_bless_isr from 3 to 0.
  • Most likely, the PWM is crashing when you enter low power mode (deep sleep I think) without putting the PWM to sleep. Use the PWM_Sleep() to put the PWM to sleep when changing to the low power mode, and use PWM_Wakeup() to resume it when exiting low power mode.
0 Likes
Anonymous
Not applicable

Hi sir,

Thanks for your reply.

But i want to run PWM continuosly .i don't want to stop it ,if i make CyBle_ProcessEvents(); and    LowPowerImplementation();   as

commented then PWM works fine but i want to use both  CyBle_ProcessEvents();   and PWM runs coninuosly.

please help me to resolve the issue.

Thanks in advance

0 Likes
Anonymous
Not applicable

Hi sir,

I just commented  LowPowerImplementation();  then PWM starts working for 50 seconds then after once again

PWM stops working

please help me to resolve the issue.

Thanks in advance

0 Likes
Anonymous
Not applicable

hi sir,

please help me to resolve the problwm

0 Likes
Anonymous
Not applicable

You will not be able to run the PWM while in deep sleep I think, see here: PWM whilst in deep sleep

You should be calling the CyBle_ProcessEvents(); from main consistently, so don't comment that line out. If it is causing the PWM to crash/fail more, then you are not doing the bluetooth operations and handling correctly, for that see here: AN91267 - Getting Started with PSoC® 4 BLE | Cypress Semiconductor

If you can run the chip in debug mode, and catch the debug state when the PWM fails and crashes after 50s, then you should be able to get more information on what is going wrong, and be able to fix it.

0 Likes