I am quite new to embedded firmware development and definitely just two days old into Nordic nRF52 development.
I want to just setup a 25% duty cycle clock output on GPIO pin 5 for nRF52 with 100 KHz frequency. How can I do this with using just the drivers_nrf header files? I believe that I don't need to setup any IRQ handler for this, correct?
I do not plan to use any SoftDevice and right now want something very simple so that that I can experiment and learn. Just just the static inline functions from components\drivers_nrf\hal\ folder if possible.
I see some sample code online that seems to use NRF_TIMER along with PWM_IRQHandler. But I thought that I could use PWM without any CPU interaction. Can't I use the NRF_PWM resources? I was hoping to find sample code that uses nrf_pwm_pins_set() and nrf_pwm_configure() etc. to just get a simple clock.
I was hoping to have code similar to below but all examples I see use the TIMER2 instead. It feels like I am missing something major...
uint32_t out_pins[] = {5, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED, NRF_PWM_PIN_NOT_CONNECTED};
static uint16_t pwm_seq[2] = {0x8800, 0x0800};
nrf_pwm_sequence_t const seq =
{
.values.p_common = pwm_seq,
.length = sizeof(pwm_seq)/sizeof(uint16_t),
.repeats = 0,
.end_delay = 0
};
nrf_gpio_cfg_output(5);
nrf_pwm_pins_set(NRF_PWM0, out_pins);
nrf_pwm_enable(NRF_PWM0);
nrf_pwm_configure(NRF_PWM0, NRF_PWM_CLK_16MHz, NRF_PWM_MODE_UP, 1600);
nrf_pwm_loop_set(NRF_PWM0, 0);
nrf_pwm_decoder_set(NRF_PWM0, NRF_PWM_LOAD_COMMON, NRF_PWM_STEP_AUTO);
nrf_pwm_sequence_set(NRF_PWM0, 0, &seq);
NRF_PWM0->TASKS_SEQSTART[0] = 1;
BTW - this is on my custom board and not on dev-kit but that should really matter much. Any pointers appreciated. Thanks!