Zephyr PWM and GPIO in System Off

Hi,

I am developing on a nRF52840dk. I control a LED2 (line P0.14) with PWM in normal operation and want to leave the LED2 ON when I go to System Off mode.

I tried setting the line to constant active with the Zephyr PWM driver by setting the pulse equal to period.

I tried setting the line to constant inactive with the Zephyr PWM driver by setting the pulse equal to 0 and then setting the active level with the GPIO driver.

In both cases the LED was off after going to System Off.

I can't find any obvious way to do what I want.

Parents
  • Hi,

    I tried setting the line to constant inactive with the Zephyr PWM driver by setting the pulse equal to 0 and then setting the active level with the GPIO driver.

    In this case, did you check that the GPIO was at the correct level before system off?

  • I can check register values before, and after setting the GPIO pin

    NRF_PWM0->ENABLE: 0x00000001
    NRF_PWM0->PSEL.OUT[0]: 0x0000000E
    NRF_GPIO->PIN_CNF[14]: 0x00000003
    NRF_GPIO->OUTSET: 0x00004060
    GPIO P0.14 set: 1
    NRF_PWM0->ENABLE: 0x00000001
    NRF_PWM0->PSEL.OUT[0]: 0x0000000E
    NRF_GPIO->PIN_CNF[14]: 0x00000003
    NRF_GPIO->OUTSET: 0x00000060

    Yes the GPIO pin 14 is set to active level.

  • Hi,

    Try setting NRF_PWM0->PSEL.OUT[0] to 0xFFFFFFFF , before you configure the GPIO as output and set it to the desired level.

  • I tried and it didn't work. The LED still went off after going system off. And 1 is is still in the NRF_PWM0->ENABLE.

    The ways I found to keep the LED on in system off is to assign different pin for pwm0_sleep pinctrl, but it is not a viable option for my project, as I use all gpio pins and I don't want to cause a problem with strange pin assignments.


    Just to clarify, calling gpio_pin_set_dt() does make LED go brighter, so constant level can be set with gpio api. But LED is not kept on in system off.






  • I have found a way to make it work.

    I have removed the low-power-enable; from the pwm0_sleep pin configuration node. And I did not use gpio driver api to set constant active level on the pin. Setting the pulse equal to the period with pwm driver api sets the relevant gpio out to the active level. 

    EDIT: Unfortunately, it is not completely solved. I cannot control whether GPIO pin should be active or inactive when the device goes to System Off. Regardless of the GPIO OUT values or previous PWM pulse configuration (to 0 or to period) the pin will be active in System Off. 

    Any advice on how to control it?

Reply
  • I have found a way to make it work.

    I have removed the low-power-enable; from the pwm0_sleep pin configuration node. And I did not use gpio driver api to set constant active level on the pin. Setting the pulse equal to the period with pwm driver api sets the relevant gpio out to the active level. 

    EDIT: Unfortunately, it is not completely solved. I cannot control whether GPIO pin should be active or inactive when the device goes to System Off. Regardless of the GPIO OUT values or previous PWM pulse configuration (to 0 or to period) the pin will be active in System Off. 

    Any advice on how to control it?

Children
No Data
Related