I am trying to use output compare to make a particular pin output high for 0.8 us. However, I am not particularly familiar with the nRF52840. I am wondering if there's any sample code that'd help me get started?
I am trying to use output compare to make a particular pin output high for 0.8 us. However, I am not particularly familiar with the nRF52840. I am wondering if there's any sample code that'd help me get started?
Hi,
You can see a similar example here. This is for continously toggling a pin, so for outputting a single pulse hou would do it slightly differently, but this shows the principle. Adjusting this to making a simple pulse could be by triggering the first pin toggle as the timer starts counting, and toggling it once more and stop the timer (using the STOP shortcut).
For reference, you can also do this with the nrfx drivers, which you can find an example of under modules/hal/nordic/nrfx/samples/src/nrfx_gppi/one_to_one/.
Thank you!
Would it be possible to toggle a pin high and low for different durations? Here’s the scenario I’d like to achieve:
Initially, I considered configuring two separate events for the same pin. However, I came across a post suggesting that having multiple events configured to the same pin might not be advisable.
As a newcomer, I would greatly appreciate any recommendations or best practices on how to approach this.
Thank you!
Would it be possible to toggle a pin high and low for different durations? Here’s the scenario I’d like to achieve:
Initially, I considered configuring two separate events for the same pin. However, I came across a post suggesting that having multiple events configured to the same pin might not be advisable.
As a newcomer, I would greatly appreciate any recommendations or best practices on how to approach this.
Hi,
There is no problem having several events connected to the same task, but you cannot have one task for setting high and one for setting low. Sou you have to use toggle on GPIOTE. Then, you can do something like this:
Then it wold work liek this: