Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use pwm in nrf52832 for rgb led #21278

Closed
pankaj18 opened this issue Dec 10, 2019 · 6 comments
Closed

How to use pwm in nrf52832 for rgb led #21278

pankaj18 opened this issue Dec 10, 2019 · 6 comments

Comments

@pankaj18
Copy link

The sample code is given for Hexiwear K64. How to use this code for nrf52832 board and external RGB led using pwm. Which pins are used and how to change given code

#if defined(DT_ALIAS_RED_PWM_LED_PWMS_CONTROLLER) &&
defined(DT_ALIAS_RED_PWM_LED_PWMS_CHANNEL) &&
defined(DT_ALIAS_GREEN_PWM_LED_PWMS_CONTROLLER) &&
defined(DT_ALIAS_GREEN_PWM_LED_PWMS_CHANNEL) &&
defined(DT_ALIAS_BLUE_PWM_LED_PWMS_CONTROLLER) &&
defined(DT_ALIAS_BLUE_PWM_LED_PWMS_CHANNEL)
/* Get the defines from dt (based on aliases 'red-pwm-led', 'green-pwm-led' &

  • 'blue-pwm-led')
    */
    #define PWM_DEV0 DT_ALIAS_RED_PWM_LED_PWMS_CONTROLLER
    #define PWM_CH0 DT_ALIAS_RED_PWM_LED_PWMS_CHANNEL
    #define PWM_DEV1 DT_ALIAS_GREEN_PWM_LED_PWMS_CONTROLLER
    #define PWM_CH1 DT_ALIAS_GREEN_PWM_LED_PWMS_CHANNEL
    #define PWM_DEV2 DT_ALIAS_BLUE_PWM_LED_PWMS_CONTROLLER
    #define PWM_CH2 DT_ALIAS_BLUE_PWM_LED_PWMS_CHANNEL
    #else
    #error "Choose supported board or add new board for the application"
    #endif
@pankaj18 pankaj18 added the bug The issue is a bug, or the PR is fixing a bug label Dec 10, 2019
@jfischer-no jfischer-no added question and removed bug The issue is a bug, or the PR is fixing a bug labels Dec 11, 2019
@carlescufi
Copy link
Member

@mbolivar perhaps you can shed some light here?

@mbolivar
Copy link
Contributor

@pankaj18 where is this code from? I'm really not clear what the question is.

@henrikbrixandersen
Copy link
Member

The code in question (rgb_led sample, likely) depends on device tree aliases for the pwm-leds nodes corresponding to the RGB LED to work.

Which board are you trying to compile for?

@mbolivar
Copy link
Contributor

(rgb_led sample, likely)

Yep, that makes sense.

@pankaj18 did you read the device tree documentation?

https://docs.zephyrproject.org/latest/guides/dts/index.html

It explains what an "alias" is.

What you need to set an alias to depends on your board.

@mbolivar
Copy link
Contributor

mbolivar commented Jan 8, 2020

@pankaj18 did you read the device tree documentation?

Ping

@henrikbrixandersen
Copy link
Member

@pankaj18 Thank you for submitting the question. If the above answers did not solve your problem, please reopen this issue with any follow-up questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants