element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Low Power IoT Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Low Power IoT Design Challenge
  • More
  • Cancel
Low Power IoT Design Challenge
Blog Handy BLE drum #5 Make the Prototype Drum Work
  • Blog
  • Forum
  • Documents
  • Polls
  • Files
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fyaocn
  • Date Created: 6 Nov 2021 2:40 AM Date Created
  • Views 785 views
  • Likes 2 likes
  • Comments 0 comments
Related
Recommended

Handy BLE drum #5 Make the Prototype Drum Work

fyaocn
fyaocn
6 Nov 2021

    • 1 Make the Prototype Work
    • 2 Start the Project
    • 3 Connectiong with the Board with Mobile BLE app
    • 4 More to do

1 Make the Prototype Work

There have been times working on Clock conflics, the PDM depends on PLL clock and FreeRTOS make its own clock. If two many thread opened, none works well. The tick for FreeRTOS is normally 1000, can not responsive well with realtime application. Another solution is duel core cooperation. As another try in later blogs.

This time, with ISR to control based on Anycloud FindMe demo.

After the edrumer connected, the beats detection start automatically.

 

2 Start the Project

Create the project by copy Findme as template, rename to eDrumer.

int main()
{
    cy_rslt_t rslt;
    wiced_result_t result;


    /* This enables RTOS aware debugging in OpenOCD. */
    uxTopUsedPriority = configMAX_PRIORITIES - 1;


    /* Initialize the board support package */
    rslt = cybsp_init();


    if (CY_RSLT_SUCCESS != rslt)
    {
        CY_ASSERT(0);
    }


    /* Enable global interrupts */
    __enable_irq();


    clock_init();


    /* Initialize retarget-io to use the debug UART port */
    cy_retarget_io_init(CYBSP_DEBUG_UART_TX, CYBSP_DEBUG_UART_RX, CY_RETARGET_IO_BAUDRATE);




    /* Initialize the User LED */
    cyhal_gpio_init(CYBSP_USER_LED3, CYHAL_GPIO_DIR_OUTPUT, CYHAL_GPIO_DRIVE_STRONG, CYBSP_LED_STATE_OFF);


    /* Initialize the User Button */
    cyhal_gpio_init(CYBSP_USER_BTN, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF);
    cyhal_gpio_enable_event(CYBSP_USER_BTN, CYHAL_GPIO_IRQ_FALL, CYHAL_ISR_PRIORITY_DEFAULT, true);
    cyhal_gpio_register_callback(CYBSP_USER_BTN, button_isr_handler, NULL);


    /* Initialize the PDM/PCM block */
    cyhal_pdm_pcm_init(&pdm_pcm, PDM_DATA, PDM_CLK, &audio_clock, &pdm_pcm_cfg);
    cyhal_pdm_pcm_register_callback(&pdm_pcm, pdm_pcm_isr_handler, NULL);
    cyhal_pdm_pcm_enable_event(&pdm_pcm, CYHAL_PDM_PCM_ASYNC_COMPLETE, CYHAL_ISR_PRIORITY_DEFAULT, true);
    cyhal_pdm_pcm_start(&pdm_pcm);


    printf("*********************eDrumer  Example***********************************\n");
    printf("************* eDrumer Profile Application Start ************************\n");


   /* Configure platform specific settings for the BT device */
   cybt_platform_config_init(&bt_platform_cfg_settings);


   /* Register call back and configuration with stack */
   result = wiced_bt_stack_init (app_bt_management_callback, &wiced_bt_cfg_settings);


   /* Check if stack initialization was successful */
   if( WICED_BT_SUCCESS == result)
   {
       printf("Bluetooth Stack Initialization Successful \n");
   }
   else
   {
       printf("Bluetooth Stack Initialization failed!! \n");
       CY_ASSERT(0);
   }


    /* Start the FreeRTOS scheduler */
    vTaskStartScheduler();


    /* Should never get here */
    CY_ASSERT(0) ;
}

This is main.c code to initiated the hardware and timer. The PDM/PCM block need clockinit() first. That brings alot of problems in RTOS applications. So The RTOS is not running in this case.

The main part of the PDM detection is place on adv_led_update() where the hardware is triggered for BLE control remotely.

void adv_led_update(void)
{
    /* CYBSP_USER_LED2 is only present on some kits. For those kits,it is used to indicate advertising/connection status */
#ifdef CYBSP_USER_LED2
    cy_rslt_t rslt = CY_RSLT_SUCCESS;
    /* Stop the advertising led pwm */
    cyhal_pwm_stop(&adv_led_pwm);


    /* Update LED state based on BLE advertising/connection state.
     * LED OFF for no advertisement/connection, LED blinking for advertisement
     * state, and LED ON for connected state  */
    switch(app_bt_adv_conn_state)
    {
        case APP_BT_ADV_OFF_CONN_OFF:
            rslt = cyhal_pwm_set_duty_cycle(&adv_led_pwm, LED_OFF_DUTY_CYCLE, ADV_LED_PWM_FREQUENCY);
            break;


        case APP_BT_ADV_ON_CONN_OFF:
            rslt = cyhal_pwm_set_duty_cycle(&adv_led_pwm, LED_BLINKING_DUTY_CYCLE, ADV_LED_PWM_FREQUENCY);
            break;


        case APP_BT_ADV_OFF_CONN_ON:
            rslt = cyhal_pwm_set_duty_cycle(&adv_led_pwm, LED_ON_DUTY_CYCLE, ADV_LED_PWM_FREQUENCY);
            break;


        default:
            /* LED OFF for unexpected states */
            rslt = cyhal_pwm_set_duty_cycle(&adv_led_pwm, LED_OFF_DUTY_CYCLE, ADV_LED_PWM_FREQUENCY);
            break;
    }
    /* Check if update to PWM parameters is successful*/
    if (CY_RSLT_SUCCESS != rslt)
    {
         printf("Failed to set duty cycle parameters!!");
    }


    rslt = cyhal_pwm_start(&adv_led_pwm);
    /* Check if PWM started successfully */
    if (CY_RSLT_SUCCESS != rslt)
    {
         printf("Failed to start PWM !!");
    }
#endif
}

There are some problem with my newly updated window 11, the ScreenShot is not working. So, only code listed.

3 Connectiong with the Board with Mobile BLE app

There is not enough time for better Android APP demo, normal BLE App is used . the Mobile connected with edrumer with BLE,

imageimage

 

image

image

Then the hardware response to the control from mobile.

image

Once connected, enter into the PDM cycle in responsive to any soud over threadhold to flash the led and send back the signal to mobile. The android APP shall be build to receive the customized BLE characteristic.

image

4 More to do

This is raw prototype, There shall be more to added in this drumer as one way of communication to same drum player in community. That part of work need backend running server to support such drumer life.

  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube