nRF Connect SDK Intermediate course - Lesson 4, Exercise 1 PWM terminology

In this exercise the PWM terminology is used incorrectly, confusing the pwm pulse width (nsecs) and duty cycle (percentage).  I know the difference from 40+ years of designing PWM circuits and firmware, but your lesson will confuse people that are new to PWM.

In step 2 the text says "Define the PWM period and pulse, as the macros PWM_PERIOD_NS and PWM_PULSE_NS", but the code snippet shows a macro for duty cycle with a value that is clearly nsecs and not a percentage:

#define PWM_PERIOD_NS 20000000
#define PWM_DUTY_CYCLE 1400000

The text on the rest of the page continues to correctly refer to the second setting as the pulse width, but two more code snippets show the incorrectly named PWM_DUTY_CYCLE macro, including passing it to the pwm_set_dt() function that takes a pulse width, not duty cycle.

I checked the solution in GitHub, and that code also has the incorrectly named PWM_DUTY_CYCLE macro in two places, matching the lesson code snippets.

Parents Reply Children
No Data
Related