Skip to content

Commit

Permalink
[Gen 3][SoM][test] no_fixture: adds more dummy reads after PWM period…
Browse files Browse the repository at this point in the history
… updates
  • Loading branch information
technobly committed Mar 14, 2019
1 parent 893249a commit 8ca5583
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions user/tests/wiring/no_fixture/pwm.cpp
Expand Up @@ -266,6 +266,11 @@ test(PWM_08_LowDCAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 8);
// analogWrite(pin, 25); // 9.8% Duty Cycle at 500Hz = 196us HIGH, 1804us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
uint32_t avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 25); // 9.8% Duty Cycle at 500Hz = 196us HIGH, 1804us LOW.
Expand All @@ -284,6 +289,11 @@ test(PWM_08_LowDCAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 4);
// analogWrite(pin, 2); // 13.3% Duty Cycle at 500Hz = 266us HIGH, 1733us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 2); // 13.3% Duty Cycle at 500Hz = 266us HIGH, 1733us LOW.
Expand All @@ -302,6 +312,11 @@ test(PWM_08_LowDCAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 12);
// analogWrite(pin, 409); // 10% Duty Cycle at 500Hz = 200us HIGH, 1800us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 409); // 10% Duty Cycle at 500Hz = 200us HIGH, 1800us LOW.
Expand All @@ -320,6 +335,11 @@ test(PWM_08_LowDCAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 15);
// analogWrite(pin, 3277); // 10% Duty Cycle at 500Hz = 200us HIGH, 1800us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 3277); // 10% Duty Cycle at 500Hz = 200us HIGH, 1800us LOW.
Expand Down Expand Up @@ -442,6 +462,11 @@ test(PWM_10_HighFrequencyAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 8);
// analogWrite(pin, 25, 10000); // 9.8% Duty Cycle at 10kHz = 9.8us HIGH, 90.2us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
uint32_t avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 25, 10000); // 9.8% Duty Cycle at 10kHz = 9.8us HIGH, 90.2us LOW.
Expand All @@ -458,6 +483,11 @@ test(PWM_10_HighFrequencyAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 4);
// analogWrite(pin, 2, 10000); // 13.3% Duty Cycle at 10kHz = 13.3us HIGH, 86.6us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 2, 10000); // 13.3% Duty Cycle at 10kHz = 13.3us HIGH, 86.6us LOW.
Expand All @@ -474,6 +504,11 @@ test(PWM_10_HighFrequencyAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 12);
// analogWrite(pin, 409, 10000); // 10% Duty Cycle at 10kHz = 10us HIGH, 90us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 409, 10000); // 10% Duty Cycle at 10kHz = 10us HIGH, 90us LOW.
Expand All @@ -490,6 +525,11 @@ test(PWM_10_HighFrequencyAnalogWriteOnPinResultsInCorrectPulseWidth) {
assertEqual(analogWriteResolution(pin), 15);
// analogWrite(pin, 3277, 10000); // 10% Duty Cycle at 10kHz = 10us HIGH, 90us LOW.
// if (pin == D0) delay(5000);
#if HAL_PLATFORM_NRF52840
// Dummy read to wait until the change of PWM takes effect
pulseIn(pin, HIGH);
pulseIn(pin, LOW);
#endif
avgPulseHigh = 0;
for(int i=0; i<10; i++) {
analogWrite(pin, 3277, 10000); // 10% Duty Cycle at 10kHz = 10us HIGH, 90us LOW.
Expand Down

0 comments on commit 8ca5583

Please sign in to comment.