This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NRF52 PWM Up/Down Counter Mode

Hi,

I am evaluating the NRF52 with PCA10040 board and nRF5x_SDK_11.0.0.alpha.

I want to create Wave Forme as below.

Out[0] pin transit low to high at compare 0, Out[1] pin transit high to low at compare 1.

**

Please let me know how to make the wave form like below picture.

** image description

but I can only make the wave form like below. image description

Please refer to my source code below.

	uint32_t err_code;

	nrf_drv_pwm_config_t const config0 =
	{
    	.output_pins =
    	{
		TEST_LED_1, // channel 0
		TEST_LED_2, // channel 1
		NRF_DRV_PWM_PIN_NOT_USED, // channel 2
		NRF_DRV_PWM_PIN_NOT_USED  // channel 3
    	},
    	
	.base_clock = NRF_PWM_CLK_125kHz,
	.count_mode = NRF_PWM_MODE_UP_AND_DOWN,
	.top_value  = 50000,
	.load_mode  = NRF_PWM_LOAD_INDIVIDUAL,
	.step_mode  = NRF_PWM_STEP_AUTO
	};

	err_code = nrf_drv_pwm_init(&m_pwm0, &config0, NULL);
	APP_ERROR_CHECK(err_code);

	// This array cannot be allocated on stack (hence "static") and it must
	// be in RAM (hence no "const", though its content is not changed).
	static nrf_pwm_values_individual_t /*const*/ seq_values[] =
	{
    	10000, 11000, 0, 0,
	};

	nrf_pwm_sequence_t const seq =
	{
    	.values.p_individual = seq_values,
    	.length              = NRF_PWM_VALUES_LENGTH(seq_values),
    	.repeats             = 0,
    	.end_delay           = 0
	};

	nrf_drv_pwm_simple_playback(&m_pwm0, &seq, 1, NRF_DRV_PWM_FLAG_LOOP);
Parents Reply Children
Related