This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how to define gpio pins and generate pwm on gpio pins?

Hi There, i am new to nrf51822 and new to program this kind of controller.I searched over the website, I couldn't find a good introductory documentation for programming the nrf51822, specifically the nrf51-dk. i have two problems 1.i want to connect a led and buzzer to gpio pins of nrf51822 so how to declare gpio pins in program for ex. suppose if i press button on nrf board the buzzer connected to gpio pins (for (ex. p0.0) should be on (make some sound). 2.i want to generate a pwm on gpio pin (for ex on p0.1) how to declare this pin as output for pwm how to use functions to declare gpio,led and other stuff as i gone through the tutorial it is not well defined and the tutorials are very much confused and easy to understandable can anybody give me the good explnation about this a good tutorial with each and every line explained will be great help!! Regards, Abhijeet Kapse

Parents Reply
  • If you need PWM on 2 GPIO pins, use APP_PWM_DEFAULT_CONFIG_2CH(). If you need PWM on 1 GPIO pin, use APP_PWM_DEFAULT_CONFIG_1CH().

    The first argument is the period in microseconds, and second argument is the GPIO pin you want to use.

    APP_PWM_DEFAULT_CONFIG_1CH(period_in_us,#PIN_YOU_WANT_TO_USE)
    

    In the PWM library example we have this:

     app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(5000L, BSP_LED_0, BSP_LED_1);
    

    So you can just remove the BSP_LED_0and BSP_LED_1, and replace it with the GPIO pin number you want to use.

Children
No Data
Related