Skip to content

Commit 310bd7d

Browse files
committed
NRF52: Fix PWM driver
Looks like there is a bug in function `pwmout_pulsewidth()`. The function should check if given puls with is not greater than configured period. 
1 parent 5bd160b commit 310bd7d

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

targets/TARGET_NORDIC/TARGET_NRF5x/TARGET_NRF52/pwmout_api.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -295,9 +295,9 @@ void pwmout_period_us(pwmout_t *obj, int period)
295295
void pwmout_pulsewidth(pwmout_t *obj, float pulse)
296296
{
297297
DEBUG_PRINTF("pwmout_pulsewidt: %f\r\n", pulse);
298-
298+
299299
/* Cap pulsewidth to period before setting it. */
300-
if ((pulse * 1000000) > (float) (obj->pulse & ~SEQ_POLARITY_BIT)) {
300+
if ((pulse * 1000000) > (float) obj->period) {
301301
obj->pulse &= SEQ_POLARITY_BIT;
302302
obj->pulse |= obj->period;
303303
pwmout_pulsewidth_us(obj, obj->pulse);
@@ -354,4 +354,3 @@ const PinMap *pwmout_pinmap()
354354
}
355355

356356
#endif // DEVICE_PWMOUT
357-

0 commit comments

Comments
 (0)