Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

PWM library simpler way for on/off (enable/disable) than the example with SDK?

Is there a way to set duty cycle before app_pwm_enable(&PWM1) call ?

Or some other simple way to switch on and off a passive buzzer signal without every time at off/on cycle to go with complex sequence for setting duty value as per pwm_library example?

Let say some app like Morse Code where the frequency will be resonance of the buzzer and duty cycle will be constant 50 (or less).

Thanks

  • Hi, but you have in your code, that you put as example before, couple lines that using gpiote channel index? 

     NRF_GPIOTE->TASKS_CLR[SOUND_GPIOTE_CH] = 1;

    NRF_PPI->CH[SOUND_PPI_CH_A].TEP = (uint32_t)&NRF_GPIOTE->TASKS_SET[SOUND_GPIOTE_CH];

    NRF_PPI->CH[SOUND_PPI_CH_B].TEP = (uint32_t)&NRF_GPIOTE->TASKS_CLR[SOUND_GPIOTE_CH];

    The only task address I could get right away is the out task I created in order to use nrf_drv_gpiote_out_init and it has same config as what you made with registers in your example?

    I by the way still didn't  clear all the mess I made with adding the code for the passive buzzer, but move one step better, by getting at least the sound working and I'm using 

    gpioteChIndex = (nrfx_gpiote_out_task_get(SS_SDK_CFG_BZR_PIN) % 48) / 4;

    But if I could rid of need of gpiote channel index would be better.

    Regards

  • Hi

    There are two functions called nrfx_gpiote_set_task_addr_get(nrfx_gpiote_pin_t pin) and nrfx_gpiote_clr_task_addr_get(nrfx_gpiote_pin_t pin)

    I believe these functions should provide the task addresses you need. 

    Best regards
    Torbjørn

Related