Hello, I am trying to generate pulses with the nRF52832 chip.I created a basic setup for test purposes; I simply connected a LED to the PWM output, but even though I put 0 into the sequence duty cycle values my LED still light up. My code is below. I'd appreciate any help.
Regards.
Note: Since Keil is not updating nRF SDK on its servers I probably am using outdated things. Also, I'm using s210 softdevice
#include <stdbool.h>
#include <stdint.h>
#include "nrf_delay.h"
#include "nrf_gpio.h"
#include "nrf_gpiote.h"
#include "nrf_pwm.h"
#include "nrf_esb.h"
#include "nrf_error.h"
#include "nrf.h"
#include "nrf_drv_pwm.h"
int main(void)
{
nrf_pwm_values_common_t seq_values[1] = {0};
//nrf_pwm_sequence_t const seq =
//{
// .values.p_common = seq_values,
// .length = NRF_PWM_VALUES_LENGTH(seq_values),
// .repeats = 0,
// .end_delay = 0
//};
uint32_t out_pins[4]={16,NRF_PWM_PIN_NOT_CONNECTED,NRF_PWM_PIN_NOT_CONNECTED,NRF_PWM_PIN_NOT_CONNECTED};
nrf_pwm_enable(NRF_PWM0);
nrf_pwm_pins_set(NRF_PWM0,out_pins);
nrf_pwm_configure(NRF_PWM0,NRF_PWM_CLK_1MHz,NRF_PWM_MODE_UP,64000);
//nrf_pwm_sequence_set(NRF_PWM0,0,&seq);
nrf_pwm_seq_ptr_set(NRF_PWM0,0,seq_values);
nrf_pwm_seq_cnt_set(NRF_PWM0,0,NRF_PWM_VALUES_LENGTH(seq_values));
nrf_pwm_seq_refresh_set(NRF_PWM0,0,0);
nrf_pwm_seq_end_delay_set(NRF_PWM0,0,0);
nrf_pwm_loop_set(NRF_PWM0,200);
nrf_pwm_decoder_set(NRF_PWM0,NRF_PWM_LOAD_COMMON,NRF_PWM_STEP_AUTO);
nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_LOOPSDONE);
nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_SEQEND0);
nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_SEQEND1);
nrf_pwm_event_clear(NRF_PWM0, NRF_PWM_EVENT_STOPPED);
nrf_pwm_task_trigger(NRF_PWM0,NRF_PWM_TASK_SEQSTART0);
while (1)
{
// nrf_gpio_cfg(16,NRF_GPIO_PIN_DIR_OUTPUT,NRF_GPIO_PIN_INPUT_DISCONNECT,NRF_GPIO_PIN_NOPULL,NRF_GPIO_PIN_S0S1,NRF_GPIO_PIN_NOSENSE);
// nrf_gpio_pin_toggle(16);
// nrf_delay_ms(500);
//if(nrf_pwm_event_check(NRF_PWM0,NRF_PWM_EVENT_SEQEND0))nrf_pwm_task_trigger(NRF_PWM0,NRF_PWM_TASK_SEQSTART0);
}
}