element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • 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 & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • 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
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • 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 #3 Create Project with Capsense Control
  • 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: 28 Oct 2021 8:50 AM Date Created
  • Views 626 views
  • Likes 1 like
  • Comments 0 comments
Related
Recommended

Handy BLE drum #3 Create Project with Capsense Control

fyaocn
fyaocn
28 Oct 2021

      • 1 Create New Project
      • 2 BSP
      • 3 Build with FreeRTOS
      • 4 The Fun in PWM control

 

1 Create New Project

After Install Modus IDE, the creating of new project becomes easy. Just press CRTL+7 to invode Project creater, select template, middleware and peripheral. Then new project can be created.

image

After customized the selection, new project can be created

image

Another way is to revise sample project, that would be more quick, but some functions are not included, there are still a lot work needed.

 

2 BSP

Becareful with BSP, there is device configurator for customized BSP, this is good for new design from scratch with electrical design. Once modified, each project shall be influeced, for this project with PSoCRegistered 62S2 Wi-Fi BT Pioneer Kit.

image

 

3 Build with FreeRTOS

With RTOS, the scaling of the project becomes easy. Just create new task, adding in thread, then all the task can run well, I have added several tasks it runs well.

image

Communication between task with Created Quene, the data structures need to be clear and robust, part of the code  for LED pwm is listed below.

void task_led(void* param)
{
    cyhal_pwm_t pwm_led;
    bool led_on = true;
    BaseType_t rtos_api_result = pdFAIL;
    led_command_data_t led_cmd_data;
    int freqled=    PWM_LED_FREQ_HZ;
    /* Suppress warning for unused parameter */
    (void)param;


    cyhal_gpio_init(CYBSP_USER_BTN, CYHAL_GPIO_DIR_INPUT, CYHAL_GPIO_DRIVE_PULLUP, CYBSP_BTN_OFF);
    printf("Raw Frequency==%d !\n",freqled);
    while(cyhal_gpio_read(CYBSP_USER_BTN) == CYBSP_BTN_PRESSED);
    /* Wait for SW2 to be released */
    while(cyhal_gpio_read(CYBSP_USER_BTN) == CYBSP_BTN_OFF);


    /* Configure the TCPWM for driving led */
    if(CY_RSLT_SUCCESS != cyhal_pwm_init(&pwm_led, CYBSP_D5, NULL))
    {
        printf("CapSense interrupt initilization failed!");
    }


    if(CY_RSLT_SUCCESS != cyhal_pwm_set_duty_cycle(&pwm_led, GET_DUTY_CYCLE(LED_MAX_BRIGHTNESS),
    freqled))
    {
        printf("PWM failed to set dutycycle!");
    }


   if(CY_RSLT_SUCCESS != cyhal_pwm_start(&pwm_led))
   {
       printf("PWM failed to start!");
   }

 

4 The Fun in PWM control

Connected with oscilloscope,here is the wave form.

image

image

So, go to BLE in next blog.

  • 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