EZ-BLE on CY8CKIT-149 I/O seems to stop without debugger

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.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Hi,

As I recently got CY8CKIT-149 and I noticed that there is an EZ-BLE on the board, I wanted to try BLE tutorial.

So I ported the "Find Me" project from the 101 Video to the EZ-BLE (CYBLE-022001-00) on the CY8CKIT-149.

With the SW4 in EZ-BLE position, I could download and run the program without problem and my iPhone could find the device and control the alert level.

And the LED changed the brightness depending on the compare value of the PWM.

So far so good.

Then I tried to run it without debugger, but this time although Wireless part seems to be working the LED, which is supposed to be off when the program starts, keep turning on.  I think that this means the pin is stuck at GND. Even with this condition I could find the device from my iPhone and when I change the alert level it reports "Written xxxx Alert Successfully", but there is no change in the way LED lights.

I tried to build the program in Release mode, supply only power from the board's VDD and GND pin, but in vain.

So could someone teach me what I am missing or am doing wrong to use EZ-BLE on CY8CKIT-149 without debugger?

Following the design information and attached is my project archive.

BLE circuit from CY8CKIT-149 schematic

000-circuit.JPG

My PSoC Creator Schematic

001-schematic.JPG

Pin assignments

012-Pin-Assignment.JPG

PWM configuration

013-PWM.JPG

BLE module configureation(s)

002-BLE-Config1.JPG

003-BLE-Config2.JPG

004-BLE-Config3.JPG

005-BLE-Config4.JPG

006-BLE-COnfig5.JPG

007-BLE-Config6.JPG

008-BLE-Config7.JPG

009-BLE-Config8.JPG

010-BLE-Config.JPG

011-BLE-Config.JPG

moto

0 Likes
1 Solution
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi Moto,

         You are putting system in deepSleep Mode and PWM is not available in DeepSleep Mode. Either do not put the system in DeepSleep Mode if you want to use PWM for LED blinking or if you want to put the system in DeeSleep Mode then do not use PWM and use WDT timer interrupt for blinking LED.

-Gyan

View solution in original post

0 Likes
3 Replies
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hi Moto,

         You are putting system in deepSleep Mode and PWM is not available in DeepSleep Mode. Either do not put the system in DeepSleep Mode if you want to use PWM for LED blinking or if you want to put the system in DeeSleep Mode then do not use PWM and use WDT timer interrupt for blinking LED.

-Gyan

0 Likes
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

Dear Gyan-san,

Thank you very much!

Now my CY8CKIT-149's EZ-BLE is working without debugger!

Best Regards,

22-May-2019

Motoo Tanaka

0 Likes
lock attach
Attachments are accessible only for community members.
MotooTanaka
Level 9
Level 9
Distributor - Marubun (Japan)
First comment on blog Beta tester First comment on KBA

So I modified my main.c as

=======================

#include "project.h"

#define LED_ON              (0u)

#define LED_OFF            (1u)

#define NO_ALERT            (0u)

#define MILD_ALERT          (1u)

#define HIGH_ALERT          (2u)

void StackEventHandler(uint32 event, void *eventParam) ;

void IasEventHandler(uint32 event, void *eventParam) ;

uint8_t alertLevel ;

int main(void)

{

    CYBLE_API_RESULT_T apiResult ;

  

    CyGlobalIntEnable; /* Enable global interrupts. */

  

    PWM_WriteCompare(0) ;

    PWM_Start() ;

  

    apiResult = CyBle_Start(StackEventHandler) ;

  

    if (apiResult != CYBLE_ERROR_OK) {

        /* BLE stack initialization failed, check your configuration */

        CYASSERT(0) ;

    }

  

    CyBle_IasRegisterAttrCallback(IasEventHandler) ;

    for(;;)

    {

        CYBLE_BLESS_STATE_T blessState ;

        uint8 intrStatus ;

      

        /* Single API call to service all the BLE stack events.

        * Must be called at least once in a BLE connection interval*/

        CyBle_ProcessEvents() ;

      

        /* Update Alert Level value on the blue LED */

        switch(alertLevel) {

        case NO_ALERT:

            PWM_WriteCompare(0) ;

            break ;

          

        case MILD_ALERT:

            PWM_WriteCompare(1000) ;

            break ;

      

        case HIGH_ALERT:

            PWM_WriteCompare(10000) ;

            break ;

        }

      

        /* Configure BLESS in Deep-Sleep mode */

        CyBle_EnterLPM(CYBLE_BLESS_DEEPSLEEP) ;

      

        /* Prevent interrupts while entering system low power modes */

        intrStatus = CyEnterCriticalSection() ;

      

        /* Get the current state of BLESS block */

        blessState = CyBle_GetBleSsState() ;

      

        /* If BLESS is in Deep-Sleep mode or the XTAL oscillator is turning on,

        * then PSoC 4 BLE can enter Deep-Sleep mode (1.3uA current consumption */

        if (blessState == CYBLE_BLESS_STATE_ECO_ON ||

            blessState == CYBLE_BLESS_STATE_DEEPSLEEP) {

//                CySysPmDeepSleep() ; // DeepSleep stops the PWM, I'm using Sleep instead

                CySysPmSleep() ;

    

        } else {

            /* Keep trying to enter either Sleep or Deep-Sleep mode */

        }

      

        CyExitCriticalSection(intrStatus) ;

      

        /* BLE link layer timing interrupt will wake up the system from Sleep

        * and Deep-Sleep modes */

    }

}

void StackEventHandler(uint32 event, void *eventParam)

{

    (void) eventParam ;

    switch(event) {

    /* Mandatory events to be handled by Find Me Target design */

    case CYBLE_EVT_STACK_ON:

    case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:

        /* Start BLE advertisement for 30 seconds and update link

        * status on LEDs */

        CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST) ;

//        Advertising_LED_Write(LED_ON) ;

        alertLevel = NO_ALERT ;

        break ;

      

    case CYBLE_EVT_GAP_DEVICE_CONNECTED:

        /* BLE link is established */

//        Advertising_LED_Write(LED_OFF) ;

//        Disconnect_LED_Write(LED_OFF) ;

        break ;

      

    case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

        if (CyBle_GetState() == CYBLE_STATE_DISCONNECTED) {

            /* Advertisement event timed out, go to low power

            * mode (Stop mode) and wait for device reset

            * event to wake up the device again */

//            Advertising_LED_Write(LED_OFF) ;

//            Disconnect_LED_Write(LED_ON) ;

            CySysPmSetWakeupPolarity(CY_PM_STOP_WAKEUP_ACTIVE_HIGH) ;

            CySysPmStop() ;

          

            /* Code execution will not reach here */

        }

        break ;

      

    default:

        break ;

    }

}

void IasEventHandler(uint32 event, void *eventParam)

{

    (void) eventParam ;

    /* Alert Level Characteristic write event */

    if (event == CYBLE_EVT_IASS_WRITE_CHAR_CMD) {

        /* Read the updated Alert Level value from the GATT database */

        CyBle_IassGetCharacteristicValue(

            CYBLE_IAS_ALERT_LEVEL,

            sizeof(alertLevel),

            &alertLevel) ;

    }

}

=======================

When the program started, I could find my "Find Me CY8CKIT-149"

IMG_3622.PNG

Then connect to my CY8CKIT-149

IMG_3623.PNG

Selected Find Me Service

IMG_3624.PNG

No Alert

IMG_3619.PNG

EZ-BLE LED is off

IMG_3616.JPG

Mild Alert

IMG_3620.PNG

EZ-BLE's LED is mildly turned on.

IMG_3617.JPG

High Alert

IMG_3621.PNG

EZ-BLE's LED is fully turned on

IMG_3618.JPG

moto

0 Likes