9 years, 2 months ago.

PwmOut channels for nRF51822

Does nRF51822 have a maximum of 3 channels using PwmOut? (20150219)? There is no compiler warning when I define more, but only first 3 give a pwm signal. Do the PWMOUT channels consume timers?

Where would I find this kind of information in mbed website for future reference?

(Maybe SoftPwm or FastPwm modules can add more)

Question relating to:

1 Answer

9 years, 2 months ago.

Seems to be correct, number of PWMs in source code is defined as 3 (#define NO_PWMS 3). Often this is visible in pinout graph, but with flexible pinouts of the nrf this won't be visible there. Sometimes it is then in the features, but it also does not seem to be there. It can be an issue getting all relevant information on those pages without overcrowding it. According to the mbed-src it should print a message on your serial terminal, does it not do this? This is not something the compiler can already warn about.

FastPWM won't be able to help you (besides that it has no support for the NRF currently), since it uses the same hardware. SoftPWM should work for you if the period is not too short.

Accepted Answer

Thank you (I'd accept your answer but the thanks button is broken for me)

Where did you see (#define NO_PWMS 3) ?

No notice in serial out. Maybe because on the nRF there isn't a fixed serial out. I can add printf which causes serial out to be defined but by default those pins are GPIO (I was testing PWM on them):

  • Enabling serial out on nRF, but need at least one of DEBUG() implemented:
    • #define DEBUG(...) { printf(VA_ARGS); }
  • Even with DEBUG() serial out there isn't a notice (None expected since not always available)
  • Maybe need an error variable where such things can be flagged and checked by run time code (an array of enum flags, or a 32bit with bit flags)??
posted by Paul Russell 20 Feb 2015

That was found here: http://developer.mbed.org/users/mbed_official/code/mbed-src/file/5831be29b0ad/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/pwmout_api.c. And it does call an error message there, but I don't know how it is implemented on the NRF. If you are using those pins for PWM then for sure nothing is going to be printed ;)

posted by Erik - 20 Feb 2015

I have also found this to be limitation - 4 channels would be useful for robotics (controlling 2 H-bridges)

posted by Franco Giangregorio 21 Feb 2015