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

What is the minimum timer interrupt possible in nRF51822?

Hi, I want to generate PWM pulses of width 14uSec(off time) and 42uSec(on time). Is it possible to achieve the above

  • with app_timer module
  • without app_timer module and by using NRF_TIMER0 registers? Can you point out examples to obtain minimum timer interrupt using app_timer and an example which does not use app_timer? Thanks.
  • The best counter resolution of RTC (app_timer) is 30.5uS. And it is mentioned in the app_timer_start api that the minimum ticks that could be configured is 5. So the shortest pulse you can achieve with app_timer is 30.5 * 5 = 152.5uS.

    The below is from SDK11 app_timer module.

    /**@brief Function for starting a timer.
     *
     * @param[in]       timer_id      Timer identifier.
     * @param[in]       timeout_ticks Number of ticks (of RTC1, including prescaling) to time-out event
     *                                (minimum 5 ticks).
     * @param[in]       p_context     General purpose pointer. Will be passed to the time-out handler when
     *                                the timer expires.
     *
     * @retval     NRF_SUCCESS               If the timer was successfully started.
     * @retval     NRF_ERROR_INVALID_PARAM   If a parameter was invalid.
     * @retval     NRF_ERROR_INVALID_STATE   If the application timer module has not been initialized or the timer
     *                                       has not been created.
     * @retval     NRF_ERROR_NO_MEM          If the timer operations queue was full.
     *
     * @note The minimum timeout_ticks value is 5.
     * @note For multiple active timers, time-outs occurring in close proximity to each other (in the
     *       range of 1 to 3 ticks) will have a positive jitter of maximum 3 ticks.
     * @note When calling this method on a timer that is already running, the second start operation
     *       is ignored.
     */
    uint32_t app_timer_start(app_timer_id_t timer_id, uint32_t timeout_ticks, void * p_context);
    
  • Hi Aryan, thanks for the reply. How do I achieve 14uSec on time and 42uSec off time? I tried using the PWM example code (which uses PPI and GPIOTE), but when I change the duty_cycle to any value between 1 and 255, there is no effect in the output PWM wave. Can you please help? Or, if you could attach a file that can do PWM with outputting different duty cycles at 2 separate pins, that would be great, because that is what I want.

  • There are PWM examples in SDK_11\examples\peripheral\pwm_library Please run that on your board to see if it works on your LED, It will be good starting point for you.

  • I tried the example using ppi+gpiote+timer for generating pwm. but, when I go below a certain usec on/off time, the pwm waves generated are not stable. Is this a limitation?

  • how many usec are you talking about? there is a propagation delay of events between modules. For stable behavior I would recommend not to generate pwm waves with on/off cycle less that 5 timer ticks.

Related