The PWM counters can't directly do this, but there are several ways to achieve it:
Set up 2 counters, that will count the 'up' and 'down' signals, with both inputs going to the PWM signal. Write some code that enables one or the other, depending on the state of the I/P pin; you can use a pin state-change interrupt to detect this.
Alternatively, put a 2-input NAND gate on the input to each counter, with the other NAND pins going to your input signal and its inverse.
Or you could program a PIO to do this; it would be more complicated, since you'd have to incorporate a method to trigger the PIO to send its current reading to the input FIFO, but it should be quite do-able.
Set up 2 counters, that will count the 'up' and 'down' signals, with both inputs going to the PWM signal. Write some code that enables one or the other, depending on the state of the I/P pin; you can use a pin state-change interrupt to detect this.
Alternatively, put a 2-input NAND gate on the input to each counter, with the other NAND pins going to your input signal and its inverse.
Or you could program a PIO to do this; it would be more complicated, since you'd have to incorporate a method to trigger the PIO to send its current reading to the input FIFO, but it should be quite do-able.
Statistics: Posted by jayben — Thu Jul 04, 2024 10:06 am