Skip to content

Commit 051a259

Browse files
committed
src/corelibs: Extended test case.
Signed-off-by: IFX-Anusha <[email protected]>
1 parent bfd6e1e commit 051a259

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/corelibs/analogio/test_analogio_pwm.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -244,11 +244,12 @@ TEST_IFX(analogio_pwm, test_analog_write_pwm_0_percentage_dutycycle)
244244
* @brief Verify SetAnalog frequency
245245
*/
246246
TEST_IFX(analogio_pwm, test_analog_set_fz)
247-
{
248-
analogWriteResolution(16); // Set resolution to 16 bits
247+
{
248+
analogWriteResolution(16);
249249
analogWrite(PWM_PIN_OUTPUT, 32767); // Set duty of 50 percent
250250

251251
const float frequency[] = {1, 50, 5000, 50000};
252+
252253
for(size_t i=0; i< sizeof(frequency)/sizeof(frequency[i]); i++)
253254
{
254255
// Set different frequencies and verify the output
@@ -257,6 +258,16 @@ TEST_IFX(analogio_pwm, test_analog_set_fz)
257258
feedback_measurement_handler();
258259
TEST_ASSERT_FLOAT_WITHIN(TOLERANCE_FREQUENCY, frequency[i], measured_frequency_hz);
259260
}
261+
262+
//test that frequency set is used by analogwrite function
263+
setAnalogWriteFrequency(PWM_PIN_OUTPUT, 100);
264+
delay(1000);
265+
analogWrite(PWM_PIN_OUTPUT, 32767);
266+
delay(1000);
267+
feedback_measurement_handler();
268+
TEST_ASSERT_FLOAT_WITHIN(TOLERANCE_FREQUENCY, 100, measured_frequency_hz);
269+
270+
setAnalogWriteFrequency(PWM_PIN_OUTPUT, 1000); //set back to default fz
260271
}
261272

262273
/**

0 commit comments

Comments
 (0)