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
  • Hi,

    As an introduction, I would recommend the Getting Started guide and our examples in the SDK. For PWM generation on the nRF51, you should take a look at the PWM library example. You can find the example in the folder: <SDK_InstallFolder>\examples\peripheral\pwm_library

  • hi,Sigurd thanks for everything. i have make some changes in my code and now everything is working but i am using pin no p0.05 for pwm output and output voltage is in mv so it is not sufficient to drive the vibration motor have also used transistor. i have given my pwm signal to base of transistor and load is connected to collector side but the voltage that i found at collector is 0.7 v.when i check pin p0.09 and p0.011 i found the voltage at this pin is 3.3 v and when tried to run this pin for pwm output the pin doesn't respond anything just giving the 3.3 v output.Does the nrf51822 pins have different voltage and current specification if yes then can you tell me which pins can i use for normal pwm output. i have used this configuration for gpio

      nrf_gpio_pin_set(pin_number1);
        nrf_delay_ms(10);
        nrf_gpio_pin_clear(pin_number1);
        nrf_delay_ms(20); 
    

    do i need to set some parameter in my program while configuring gpio so i will get 3.3 v pwm output insted of 130 mv.

Reply
  • hi,Sigurd thanks for everything. i have make some changes in my code and now everything is working but i am using pin no p0.05 for pwm output and output voltage is in mv so it is not sufficient to drive the vibration motor have also used transistor. i have given my pwm signal to base of transistor and load is connected to collector side but the voltage that i found at collector is 0.7 v.when i check pin p0.09 and p0.011 i found the voltage at this pin is 3.3 v and when tried to run this pin for pwm output the pin doesn't respond anything just giving the 3.3 v output.Does the nrf51822 pins have different voltage and current specification if yes then can you tell me which pins can i use for normal pwm output. i have used this configuration for gpio

      nrf_gpio_pin_set(pin_number1);
        nrf_delay_ms(10);
        nrf_gpio_pin_clear(pin_number1);
        nrf_delay_ms(20); 
    

    do i need to set some parameter in my program while configuring gpio so i will get 3.3 v pwm output insted of 130 mv.

Children
No Data
Related