Hi All:
When I simulated PWM by GPIO, the output current noise was shown like the picture below (red circle area):
Cause it will lead to a loading issue in the backend, so I'm wondering the root cause and if there is any possible solution for this.
Any suggestion will be great. Thanks!!
SDK: 14.2
We use GPIOTE to simulate the PWM.
#define IO_KEY_PAIRING 15
#define IO_ZERO_X 31
APP_ERROR_CHECK(nrf_drv_gpiote_init());
nrf_drv_gpiote_in_config_t gpiote_config =
{
.sense = NRF_GPIOTE_POLARITY_TOGGLE,
.pull = NRF_GPIO_PIN_PULLUP,
.is_watcher = false,
.hi_accuracy = false
};
APP_ERROR_CHECK(nrf_drv_gpiote_in_init(IO_KEY_PAIRING, &gpiote_config, gpiote_event_handler));
nrf_drv_gpiote_in_event_enable(IO_KEY_PAIRING, true);
gpiote_config.pull = NRF_GPIO_PIN_NOPULL;
APP_ERROR_CHECK(nrf_drv_gpiote_in_init(IO_ZERO_X, &gpiote_config, gpiote_event_handler));
nrf_drv_gpiote_in_event_enable(IO_ZERO_X, true);
In gpiote_event_handler(), we generate PWM pulse according to IO_ZERO_X.
Update code of generating PWM --- gpiote_event_handler()- :
static void gpiote_event_handler(nrf_drv_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
{
NRF_LOG_INFO("gpiote_event_handler");
if (pin == IO_KEY_PAIRING)
{
uint32_t read_value = nrf_gpio_pin_read(IO_KEY_PAIRING);
if (!read_value)
{
nrf_delay_ms(1);
if (read_value == nrf_gpio_pin_read(IO_KEY_PAIRING))
{
m_pairing_key_latch_for_on_off = 0x01;
m_pairing_key_latch = 0x01;
}
}
}
if (pin == IO_ZERO_X)
{
controls_zero_x_trigger();//generate PWM
}
}