zephyr PWM - how to set default clock on 16MHz using devicetree

Hello

I need to configure PWM on 16 MHz clock and i really don't know how to do this via device tree.

Parents
  • I'll take a look at this and provide you with an answer tomorrow

    Best regards,

    Simon

  • Thought i would check the driver implementation in file pwm_nrfx.c.

    It turned out that apart from assigning pins to individual channels, all other PWM configs are default and it is not possible to configure them from the device tree level. 

    Part of pwm_nrfx.c

    #define PWM_NRFX_DEVICE(idx)						      \
    	static struct pwm_nrfx_data pwm_nrfx_##idx##_data;		      \
    	static const struct pwm_nrfx_config pwm_nrfx_##idx##config = {	      \
    		.pwm = NRFX_PWM_INSTANCE(idx),				      \
    		.initial_config = {					      \
    			.output_pins = {				      \
    				PWM_NRFX_OUTPUT_PIN(idx, 0),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 1),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 2),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 3),		      \
    			},						      \
    			.base_clock = NRF_PWM_CLK_1MHz,			      \
    			.count_mode = PWM_NRFX_COUNT_MODE(idx),		      \
    			.top_value = 1000,				      \
    			.load_mode = NRF_PWM_LOAD_INDIVIDUAL,		      \
    			.step_mode = NRF_PWM_STEP_TRIGGERED,		      \
    		},							      \
    		.seq.values.p_raw = pwm_nrfx_##idx##_data.current,	      \
    		.seq.length = NRF_PWM_CHANNEL_COUNT			      \
    	};		

Reply
  • Thought i would check the driver implementation in file pwm_nrfx.c.

    It turned out that apart from assigning pins to individual channels, all other PWM configs are default and it is not possible to configure them from the device tree level. 

    Part of pwm_nrfx.c

    #define PWM_NRFX_DEVICE(idx)						      \
    	static struct pwm_nrfx_data pwm_nrfx_##idx##_data;		      \
    	static const struct pwm_nrfx_config pwm_nrfx_##idx##config = {	      \
    		.pwm = NRFX_PWM_INSTANCE(idx),				      \
    		.initial_config = {					      \
    			.output_pins = {				      \
    				PWM_NRFX_OUTPUT_PIN(idx, 0),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 1),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 2),		      \
    				PWM_NRFX_OUTPUT_PIN(idx, 3),		      \
    			},						      \
    			.base_clock = NRF_PWM_CLK_1MHz,			      \
    			.count_mode = PWM_NRFX_COUNT_MODE(idx),		      \
    			.top_value = 1000,				      \
    			.load_mode = NRF_PWM_LOAD_INDIVIDUAL,		      \
    			.step_mode = NRF_PWM_STEP_TRIGGERED,		      \
    		},							      \
    		.seq.values.p_raw = pwm_nrfx_##idx##_data.current,	      \
    		.seq.length = NRF_PWM_CHANNEL_COUNT			      \
    	};		

Children
Related