@@ -240,6 +240,25 @@ TEST_IFX(analogio_pwm, test_analog_write_pwm_0_percentage_dutycycle)
240
240
TEST_ASSERT_EQUAL_MESSAGE (LOW, digitalRead (PWM_PIN_FEEDBACK), " PWM output should be LOW when 0 percentage duty cycle is set" );
241
241
}
242
242
243
+ /* *
244
+ * @brief Verify SetAnalog frequency
245
+ */
246
+ TEST_IFX (analogio_pwm, test_analog_set_fz)
247
+ {
248
+ analogWriteResolution (16 ); // Set resolution to 16 bits
249
+ analogWrite (PWM_PIN_OUTPUT, 32767 ); // Set duty of 50 percent
250
+
251
+ const float frequency[] = {1 , 50 , 5000 , 50000 };
252
+ for (size_t i=0 ; i< sizeof (frequency)/sizeof (frequency[i]); i++)
253
+ {
254
+ // Set different frequencies and verify the output
255
+ setAnalogWriteFrequency (PWM_PIN_OUTPUT, frequency[i]);
256
+ delay (1000 ); // Wait for the signal to stabilize
257
+ feedback_measurement_handler ();
258
+ TEST_ASSERT_FLOAT_WITHIN (TOLERANCE_FREQUENCY, frequency[i], measured_frequency_hz);
259
+ }
260
+ }
261
+
243
262
/* *
244
263
* @brief Bundle all tests to be executed for this test group.
245
264
*/
@@ -253,6 +272,7 @@ TEST_GROUP_RUNNER(analogio_pwm)
253
272
RUN_TEST_CASE (analogio_pwm, test_analog_write_pwm_16_bit_resolution);
254
273
RUN_TEST_CASE (analogio_pwm, test_analog_write_pwm_100_percentage_dutycycle);
255
274
RUN_TEST_CASE (analogio_pwm, test_analog_write_pwm_0_percentage_dutycycle);
275
+ RUN_TEST_CASE (analogio_pwm, test_analog_set_fz);
256
276
257
277
analogio_pwm_suite_teardown ();
258
278
}
0 commit comments