Hi,
I use SDK 10 pwm example (examples\peripheral\pwm) to modify the PWM cycle to 10s and duty cycle to 50%.
Code showed as below:
int main(void) { ret_code_t err_code; /* 2-channel PWM, 200Hz, output on DK LED pins. */ app_pwm_config_t pwm1_cfg = APP_PWM_DEFAULT_CONFIG_2CH(10000000L, BSP_LED_0, BSP_LED_1); /* Switch the polarity of the second channel. */ pwm1_cfg.pin_polarity[1] = APP_PWM_POLARITY_ACTIVE_HIGH; /* Initialize and enable PWM. */ err_code = app_pwm_init(&PWM1,&pwm1_cfg,pwm_ready_callback); APP_ERROR_CHECK(err_code); app_pwm_enable(&PWM1); //uint32_t value; while(true) { for (uint8_t i = 0; i < 40; ++i) { //value = (i < 20) ? (i * 5) : (100 - (i - 20) * 5); ready_flag = false; /* Set the duty cycle - keep trying until PWM is ready... */ while (app_pwm_channel_duty_set(&PWM1, 0, 50) == NRF_ERROR_BUSY); /* ... or wait for callback. */ while(!ready_flag); APP_ERROR_CHECK(app_pwm_channel_duty_set(&PWM1, 1, 50)); nrf_delay_ms(25); } } }
But the PWM cycle seem only around 3 seconds. Can it possible change PWM cycle time to 10s ? If can, how to do so?
Thanks.