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

How to connect single pwm signal to multiple GPIO

Hi,

At the moment I generate 4 independent pwm signals, I would prefer to have 6 but this is not possible to my understanding due to the lack of GPIOTE [ref1,ref2].

So I am trying to connect a single PWM signal to 2 gpio pins, is this possible through the ppi or any other way?

Link, here they advise to connect them in hardware. I would like to do this in software so that in the future it is possible to switch from PWM to something else.

Kind regards,

Niels Kool

Parents Reply
  • Hi,

    Your reference is for a 52832 as I am using the 51822. 
    Sigurd makes use of the DMA and the GPIOTE, where as the 52832 has 8 GPIOTE and the 51822 only 4.
    And I don't see any mentioning of a DMA in the 51822 that can be used.

    The problem is not really the limitation of the timers but getting it to the GPIO.
    However your suggestion to use IRQ might be possible but is not preferred.

Children
  • As far as I know, since you are on 51822 your only choice is IRQ.  You should avoid using the GPIO drivers as there is a lot of code between you and the ports.  Just write the set/clear register directly.  In one shot you can write all the gpio if needed.

    Average latency due to the SD is up to about 1 millisecond.  But if you are not running the SD then you can easily do the PWM using an ISR and run it reliably up to about 500kHz maybe more.  Just depends on how much code has to get executed.

    You can also timeslot your PWM solution to make it less dependent on the SD.  But most people don't want a PWM that is only on some of the time.

Related