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

TIMER+PPI+ADC on nrf52

Hi,

I am looking for some assistance to choose the best way using the nrf52832 processor in a correct way.

The main task is to generate a 1KHz PWM Signal with changeable Duty-Ciclye during the runtime. On every cycle (Signal change high/low - low/high), or better after the signal changed, i need to measure with the integrated saadc. I also need control about the Signal to set the PWM pin to low, or to high.

What is the best way to use the nrf52 chip? Should i use the integrated hardware PWM module and can i trigger the saadc on a signal cycle? Or should i use a Timer to generate the PWM Signal, reload the CC registers with different values for Duty-Cycle and trigger saadc measurements on every timeout?

I am thankful for every help, best regards, Nils :)

  • You want to measure with saadc twice every pwm cycle, i.e. when the pwm signal goes low and when it goes high? With the pwm peripheral you can only get a signal at the end of the pwm period (EVENTS_PERIODEND). You can start a timer at this signal with a timeout equal to the duty cycle to get an additional event at the duty cycle.

    If you use timer + ppi + gpiote you should use set and clr tasks. You need to update the duty cycle at the timer clear event to avoid some periods to be constant (for example if duty cycle is updated to a lower value before the last duty cycle was reached), this can be done with ppi group enable/disable tasks. I can explain better if you chose this method.

  • Hey Ole,

    thanks for your assistance :)

    with ppm peripheral do you mean the hardware pwm? I am sorry i can not find EVENTS_PERIODEND ? If this is possible i think it could be a could solution for my problem. I could also connect the PWM output to an input and get interrupted on pin change, how does that sound to you?

    i will have a look into ppi, i got the saadc working with normal handling but not triggered by ppi.

    Kindly, Nils

  • Hardware PWM described here. EVENTS_PWMPERIODEND (sorry for the typo) is found in the register description.

Related