Mbed-os: NRF52 PwmOut inverted

Created on 6 Aug 2018  路  14Comments  路  Source: ARMmbed/mbed-os

Description

Switched from mbed-os-5.7 to mbed-os-5.9, suddenly PwmOut behaved inverted, meaning

PwmOut led(SOME_PIN);
led.write(0); // LED on

accordingly opposite cases for .write(1000);

Note: LED circuit is active-high.

Target: NRF52832
ARM_GCC 6-2017-q2-update 6.3.1 20170620 (release)
mbed-os: 5.9, mbed-cli
Steps to reproduce:
empty mbed-os project with main() containing

PwmOut led(p17);
led.write(0);
Thread::wait(3000); // to notice a change
led.write(1000);

Issue request type

[ ] Question
[ ] Enhancement
[X] Bug

closed_in_jira nordic mirrored bug

All 14 comments

ARM Internal Ref: MBOTRIAGE-1495

I'll check it.
edit:
Hey, if you are using standard NRF52832 development kit:
https://os.mbed.com/platforms/Nordic-nRF52-DK)
then according to documentation (https://bit.ly/2OkRWHO):

The LEDs are active low, meaning that writing a logical zero ('0') to the output pin will illuminate the LED.

If you are using other board, then please let me know about it.

cc @maciejbocianski @fkjagodzinski @mprse

No, I am using my own board where the NRF52832 serves as the main processor and there the LED is connected active high.

But I see where this inverted behavior comes from, someone implemented PwmOut based on the DK and applied the active-low logic from this specific hardware?

In my opinion, this should be changed to non-inverted, what do you think? One reason might be to use PWM not for LED, but for motor control, etc, where you can not always expect active-low logic :)

shouldn't this sort of thing be specified at the mbed-os platform level and thus be standard across all devices? If so, then the default should be whatever they do.

@ARMmbed/mbed-os-hal
the PWM waveform polarity generated by nRF-52 is inconsitient to other devices like K64F, Nucleo-F070RB, what do you think, should this behaviour be changed?

CC @ARMmbed/mbed-os-hal

the PWM waveform polarity generated by nRF-52 is inconsitient to other devices like K64F, Nucleo-F070RB, what do you think, should this behaviour be changed?

As this might not be yet specified (will be!), should follow what the rest of the boards do. They do write 0 in their init:

pwmout_write    (obj, 0);

I can't locate this for NRF52, I can see obj->percent is set to 0 but not used anywhere during init ?

The main issue here is the regression in the HAL, @MateuszMaz can you check which commit broke this?

@0xc0170 ok

@0xc0170 It looks like the problem is located in PR #6547, which is about updating Nordic NRF52 based targets to SDK 14.2

I found another problem that is connected to Pwm in target NRF-52 , I described it here #7743

I covered this in https://github.com/ARMmbed/mbed-os/issues/5683 I think. It was said to be fixed, but it doesn't look to be the case. I never got a chance to go back to it at the time.

here is pr #7779

Mbed OS 5.9.7 release notes links to this issue as "fixed". Consider closing.

Was this page helpful?
0 / 5 - 0 ratings