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

How to make a simple LED blink program

Hello Everyone

I am really new to everything here, i just got nRF 52832 board,

Can anyone please tell me the step-by- step method on how to make a program in keil uVision.

Any help will be greatly appreciated.

thanks in advance

  • thanks for your reply, i will try changing that in the code, also i want to implement a simple pwm generator where i can give just 3 inputs, one for DUTY CYCLE, one for TOTAL CYCLE PERIOD VALUE, and one for PWM frequency. The example codes for pwm_library and pwm_driver are really lengthy/long including there header files and functions. Can i somehow implement a simple small pwm program on nrf52 as on other devices like PIC, AVR or 8051.
    thanks for your help

  • i know i have been asking you a lot of questions, but please help me as i am new and want to learn and implement on nr52. i got to know from other posts that using the pwm_driver is recommended as nrf52 has an inbuilt pwm hardware. But which parameters to modify in the code to change the DUTY_CYCLE, Total_Cycle period, Pwm frquency as in the code there are parmeters which i found like the following--


    typedef struct { uint16_t channel_0; ///< Duty cycle value for channel 0. uint16_t channel_1; ///< Duty cycle value for channel 1. uint16_t channel_2; ///< Duty cycle value for channel 2. uint16_t channel_3; ///< Duty cycle value for channel 3. } nrf_pwm_values_individual_t;


    typedef enum { NRF_PWM_CLK_16MHz = PWM_PRESCALER_PRESCALER_DIV_1, ///< 16 MHz / 1 = 16 MHz. NRF_PWM_CLK_8MHz = PWM_PRESCALER_PRESCALER_DIV_2, ///< 16 MHz / 2 = 8 MHz. NRF_PWM_CLK_4MHz = PWM_PRESCALER_PRESCALER_DIV_4, ///< 16 MHz / 4 = 4 MHz. NRF_PWM_CLK_2MHz = PWM_PRESCALER_PRESCALER_DIV_8, ///< 16 MHz / 8 = 2 MHz. NRF_PWM_CLK_1MHz = PWM_PRESCALER_PRESCALER_DIV_16, ///< 16 MHz / 16 = 1 MHz. NRF_PWM_CLK_500kHz = PWM_PRESCALER_PRESCALER_DIV_32, ///< 16 MHz / 32 = 500 kHz. NRF_PWM_CLK_250kHz = PWM_PRESCALER_PRESCALER_DIV_64, ///< 16 MHz / 64 = 250 kHz. NRF_PWM_CLK_125kHz = PWM_PRESCALER_PRESCALER_DIV_128 ///< 16 MHz / 128 = 125 kHz. } nrf_pwm_clk_t;

  • For beginners I would recommend using the pwm library, since it’s not as complicated as the pwm driver.

    There is a good example in SDK_folder\examples\peripheral\pwm_library. The period will depend on the frequency(frequency = 1 /period). If you look at the example, the period is configured using APP_PWM_DEFAULT_CONFIG_2CH() / APP_PWM_DEFAULT_CONFIG_1CH(). The duty cycle is set using the function app_pwm_channel_duty_set().

  • Hi t,

    In order to blink the led in the blinky example, the pin that is connect to the led is set high(VDD voltage) and low(0 voltage). By default the example changes between high and low state every 500ms. If you have more questions please create new question.

Related